|
|
@@ -49,27 +49,44 @@ function ESLMultiOperations(method) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function TemplateSelector() {
|
|
|
- $('.templateselector').on('shown.bs.modal', function () {
|
|
|
- let selectedLabels = $('#datatable').DataTable().rows({selected: true}).data().toArray();
|
|
|
- let labels = selectedLabels.map(v => [v[1], v[5]]);
|
|
|
- let listedTypes = selectedLabels.map(v => [v[5]]);
|
|
|
- console.log(listedTypes.uniq());
|
|
|
- //console.log(labels.countOccurrences(1, 31));
|
|
|
-
|
|
|
- /*
|
|
|
- OMGUtils.AjaxReq(`${BASEURL}/admin/templates/@dt/@clearcache`, {
|
|
|
- method: 'POST',
|
|
|
- body: JSON.stringify({"method": method, "labelid": labelID[1]})
|
|
|
- })
|
|
|
- .then(json => {
|
|
|
- if (json.err == 0)
|
|
|
- toastr.success(json.value);
|
|
|
- else
|
|
|
- toastr.error(json.value);
|
|
|
- })
|
|
|
- .catch(err => toastr.error(err.url, `${err.status} (${err.statusText})`));
|
|
|
- */
|
|
|
+/**
|
|
|
+ * Load html for template selector
|
|
|
+ *
|
|
|
+ * @param bool clearCache true clear cache
|
|
|
+ */
|
|
|
+function TemplateSelector(clearCache) {
|
|
|
+
|
|
|
+ $('.templateselector').on('hide.bs.modal', function () {
|
|
|
+ $('.templateselector .modal-body').html('');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.templateselector').on('show.bs.modal', function (e) {
|
|
|
+ let selectedRows = $('#datatable').DataTable().rows({selected: true}).data().toArray();
|
|
|
+ let dt_columns = selectedRows.map(v => v[5]);
|
|
|
+ let jsonData = JSON.stringify(dt_columns);
|
|
|
+
|
|
|
+ console.log(selectedRows.length);
|
|
|
+ if (selectedRows.length == 0) {
|
|
|
+ toastr.warning('Nessuna label selezionata');
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopImmediatePropagation();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ $('#spinnerloader').removeClass('d-none');
|
|
|
+
|
|
|
+ OMGUtils.AjaxReq(`${BASEURL}/admin/commands`, {
|
|
|
+ method: 'POST',
|
|
|
+ body: JSON.stringify({"method": 'TemplateSelector', "clearCache": clearCache, "dt": jsonData})
|
|
|
+ })
|
|
|
+ .then(json => {
|
|
|
+ if (json.err == 0)
|
|
|
+ $('.templateselector .modal-body').html(json.value);
|
|
|
+ else
|
|
|
+ toastr.error(json.value);
|
|
|
+ })
|
|
|
+ .catch(err => toastr.error(err.url, `${err.status} (${err.statusText})`))
|
|
|
+ .finally(() => $('#spinnerloader').addClass('d-none'));
|
|
|
});
|
|
|
|
|
|
$('.templateselector').modal('show');
|