").css( { "flex" : "1 1 auto" } ).append( prdLinks.element() ));
return template.append( prdSection );
}
AssetBulkEditor.prototype.removeAssetSelection = function( removeKey ) {
let instance = this;
// console.log( "removeSelection : for assetSelectionKey " + removeKey );
let key = removeKey;
let selections = {
selectOperation : "deselectByKey",
key : key
}
Fse.Ajax.performAction( {
object : "CMA.updateAssetSelections",
data : selections
}).then(function (result) {
// success
// instance.selectedAssetsDataGrid.refresh();
instance.updateFilter();
});
}
AssetBulkEditor.prototype.updateFilter = function( ) {
let instance = this;
let selectedDataSource = Fse.Data.newDataSource( { object : "cma.assetListSelectionInfo", paginate : false, pageSize : 50, keyField : "selectionKey" , objectParams : { contentDomain : this.contentDomain} } );
selectedDataSource.load().done (function( items )
{
instance.options.selectionMetaData = items[0];
instance.selectedAssetsDataGrid.option( "dataSource", instance.options.selectionMetaData.selectionAssets );
if( instance.options.selectionMetaData.selectionCount > 0 ) {
instance.bulkSelectedAssets = instance.options.selectionMetaData.selectionAssets;
}
instance.updateSummary(instance.options.selectionMetaData.selectionAssets);
});
}
AssetBulkEditor.prototype.selectedAssetsTabTemplate = function( ) {
let instance = this;
instance.createSelectedAssetsDataGrid();
let template = $("
");
$("
").css( "padding", "10px 10px 10px 10px" ).appendTo(template);
// let gridDiv = $("
");
template.append(instance.selectedAssetsDataGrid.element());
instance.updateFilter();
//template = template.append($("
")).append( instance.selectedAssetsDataGrid.element() );
return template;
}
AssetBulkEditor.prototype.deleteRow = function (options){
let instance = this;
const key = options.key;
instance.removeAssetSelection( key.assetSelectionKey );
}
AssetBulkEditor.prototype.createSelectedAssetsDataGrid = function ()
{
let instance = this;
let columns = [];
columns.push( {dataField : "title", caption : "Title" , allowHeaderFiltering : false,
allowSearch: false} );
columns.push(
{ dataField : "fileExt", caption: 'Type',
width : 60,
alignment : 'center',
allowHeaderFiltering : false,
lookup : {
dataSource : { store : { type : "array", data : [
{ value : "docx", text : "docx" },
{ value : "doc", text : "doc" },
{ value : "pdf", text : "pdf" } ,
{ value : "gif", text : "gif" },
{ value : "bmp", text : "bmp" },
{ value : "png", text : "png" },
{ value : "jpg", text : "jpg" },
{ value : "html", text : "html" },
{ value : "xls", text : "xls" },
{ value : "xlsx", text : "xlsx" },
{ value : "csv", text : "csv" },
{ value : "xlsm", text : "xlsm" },
{ value : "ppt", text : "ppt" },
{ value : "pptx", text : "pptx" },
{ value : "pptm", text : "pptm" },
{ value : "txt", text : "txt" },
{ value : "dat", text : "dat" },
{ value : "mp3", text : "mp3" },
{ value : "mp4", text : "mp4" },
{ value : "mov", text : "mov" },
{ value : "avi", text : "avi" },
{ value : "wmv", text : "wmv" },
{ value : "flv", text : "flv" },
{ value : "mkv", text : "mkv" },
{ value : "vob", text : "vob" },
{ value : "3gp", text : "3gp" },
{ value : "mpeg", text : "mpeg" },
{ value : "mpg", text : "mpg" },
{ value : "zip", text : "zip" },
{ value : "rar", text : "rar" },
{ value : "7z", text : "7z" },
{ value : "tar", text : "tar" },
{ value : "gz", text : "gz" },
{ value : "eml", text : "eml" },
{ value : "msg", text : "msg" },
{ value : "psd", text : "psd" },
{ value : "ai", text : "ai" },
{ value : "indd", text : "indd" },
{ value : "eps", text : "eps" },
{ value : "css", text : "css" },
{ value : "tiff", text : "tiff" },
{ value : "tif", text : "tif" },
{ value : "svg", text : "svg" },
{ value : "jfif", text : "jfif" },
{ value : "ico", text : "ico" },
{ value : "log", text : "log" },
{ value : "potx", text : "potx" },
{ value : "potm", text : "potm" },
{ value : "ppsx", text : "ppsx" },
{ value : "ppsm", text : "ppsm" },
{ value : "dotx", text : "dotx" },
{ value : "dot", text : "dot" },
{ value : "docm", text : "docm" },
{ value : "xml", text :"xml" },
{ value : "xltx", text :"xltx" },
{ value :"mpeg", text :"mpeg"},
{ value : "wpl", text : "wpl" },
{ value : "oft", text : "oft" },
{ value : "fhprj", text : "fhprj" },
{ value : "php", text : "php" },
{ value : "pub", text : "pub" },
{ value : "webarc", text : "webarc" },
{ value : "xps", text : "xps" },
{ value : "vsd", text : "vsd" },
{ value : "xltm", text : "xltm" },
{ value : "ipa", text : "ipa" },
{ value : "ics", text : "ics" },
{ value : "pps", text : "pps" },
{ value : "m4v", text : "m4v" },
{ value : "msi", text : "msi" },
{ value : "css", text : "css" },
{ value : "wbk", text : "wbk" },
{ value : "htm", text : "htm" },
{ value : "ttf", text : "ttf" },
{ value : "msg", text : "msg" },
{ value : "mdi", text : "mdi" },
{ value : "mid", text : "mid" },
{ value : "mht", text : "mht" },
{ value : "tmp", text : "tmp" },
{ value : "xltx", text : "xltx" },
{ value : "jpeg", text : "jpeg" },
{ value : "swf", text : "swf" },
{ value : "xlsb", text : "xlsb" },
{ value : "rwz", text : "rwz" },
{ value : "zip", text : "zip" }
], key : "value" }},
valueExpr : "value",
displayExpr : "text"
},
cellTemplate(container, options) {
let fileExt = options.value.toLowerCase().trim();
let icon = instance.iconForFileExt( fileExt );
container.addClass('chart-cell');
if( icon ) {
container.append( $("
").addClass( "dx-icon-" + icon ).attr( "title", fileExt ));
} else {
container.append( fileExt );
}
}
} );
columns.push( {
caption: "Delete",
width: 60,
alignment: "center",
cellTemplate: function(container, options) {
$("")
.text("X")
.addClass("delete-link")
.css("cursor", "pointer")
.on("click", function() {
instance.deleteRow(options);
})
.appendTo(container);
}
});
// console.log(instance.options.selectionMetaData.selectionAssets);
let gridContainer = $("");
instance.selectedAssetsDataGrid = gridContainer.dxDataGrid( {
height : "100%",
columns : columns,
showBorders : true,
allowColumnResizing : true,
allowColumnReordering : true,
// allowSearch : false,
filterRow : { visible : true },
headerFilter: {
visible: true,
},
// searchPanel: { visible: false },
columnResizeMode : "nextColumn",
columnChooser : { enabled : false },
rowAlternationEnabled : true,
scrolling : { mode : "virtual" },
selection : {
mode : "single"
}
}).dxDataGrid( "instance" );
}
AssetBulkEditor.prototype.iconForFileExt = function( fileExt ) {
if( ! fileExt ) { return null };
fileExt = fileExt.toUpperCase().replace( /^\s+|\s+$/, "" );
let icon = null;
switch ( fileExt ) {
case 'PPTX' :
icon = "pptxfile";
break;
case 'PPT' :
icon = "pptfile";
break;
case 'CSV' :
icon = "textdocument";
break;
case 'DOCX' :
icon = "docxfile";
break;
case 'DOC' :
icon = "docfile";
break;
case 'PDF' :
icon = "pdffile";
break;
case 'XLS' :
icon = "xlsfile";
break;
case 'XLSX' :
icon = "xlsxfile";
break;
case 'JPG' :
case 'TIF' :
case 'PNG' :
icon = "photo";
break;
case 'MP4' :
icon = "video";
break;
case 'RTF' :
icon = "rtffile";
break;
case 'TXT' :
icon = "txtfile";
break;
default :
icon = "file";
break;
}
return icon;
}
AssetBulkEditor.prototype.updateSummary = function( d1 ) {
const total = d1.length;
// Count by file type
const counts = d1.reduce((acc, row) => {
let type = row.fileExt; // <-- change to your field name
// console.log("file ext" +type + "---");
switch (type.toLowerCase().trim()) {
case 'docx':
case 'doc': type = 'Word Document'; break;
case 'pdf': type = 'PDF Document'; break;
case 'xls':
case 'xlsx': type = 'Excel Spreadsheet'; break;
case 'ppt':
case 'pptx': type = 'PowerPoint Presentation'; break;
case 'csv': type = 'CSV File'; break;
case 'txt': type = 'Text File'; break;
case 'html': type = 'HTML Document'; break;
case 'png':
case 'jpg':
case 'jpeg':
case 'tif':
case 'tiff': type = 'Image File'; break;
case 'zip': type = 'Zip File'; break;
case 'mp4': type = 'Video File'; break;
case 'rtf': type = 'Rich Text Format'; break;
default:
type = 'Other';
}
acc[type] = (acc[type] || 0) + 1;
return acc;
}, {});
let summaryHtml = `
| Total Assets: ${total} |
Types:
${Object.keys(counts)
.map(type => `${counts[type]} ${type}`)
.join(" â ")}
|
`;
$("#summaryBar").html(summaryHtml);
}