Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
|
||||
#reportListFilterTerm {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
#reportListFilterApply {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
#reportEditResult {
|
||||
background-color: #d3d3d345;
|
||||
}
|
||||
|
||||
#reportEditResult[error="true"] {
|
||||
color: orangered;
|
||||
background-color: #d3d3d345;
|
||||
}
|
||||
|
||||
#dirtyWarning {
|
||||
color: var(--warning-color);
|
||||
background-color: var(--warning);
|
||||
visibility: hidden;
|
||||
}
|
||||
#dirtyWarning[dirty="true"] {
|
||||
display: inline;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 95%;
|
||||
height: 100%;
|
||||
vertical-align: top;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
textarea[readonly] {
|
||||
background-color: #d3d3d345;
|
||||
}
|
||||
|
||||
.textarea-label {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.playbutton {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
td.input-label {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
width: 95%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
p.inputwarning {
|
||||
color: red;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
input[type='button'].button-add,
|
||||
#report-view-input-param-submit {
|
||||
background-color: var(--button-primary-background);
|
||||
color: var(--button-primary-color);
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
}
|
||||
.form-group input[type="text"] {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
.form-group small {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.parameter-view {
|
||||
cursor: pointer;
|
||||
border-style: solid;
|
||||
border-width: .8em;
|
||||
border-color: var(--mainmenu-active-color);
|
||||
background-color: var(--mainmenu-active-color);
|
||||
color: var(--mainmenu-color);
|
||||
border-radius: .5em;
|
||||
margin: 1px 3px 1px 3px;
|
||||
padding: 0 .5em 0 .5em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.column-view {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-message {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.form-table {
|
||||
width: 95%;
|
||||
border-collapse:separate;
|
||||
border-spacing: 0 10px;
|
||||
}
|
||||
input.double-col {
|
||||
width: 95%;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
input.half-col {
|
||||
width: 35%;
|
||||
display: inline;
|
||||
}
|
||||
#transferUrlAdress {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.dialog-table {
|
||||
border-collapse:separate;
|
||||
border-spacing: 0 20px;
|
||||
}
|
||||
|
||||
a.table-button-col-edit,
|
||||
a.table-button-col-delete,
|
||||
a.table-button-edit,
|
||||
a.table-button-delete {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#chartIntervalValue {
|
||||
display: inline;
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
#chartIntervalMode {
|
||||
display: inline;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
#report_shareduser_wrapper {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.rightside {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.vertical-top {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#sharedUserFind {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.incolumn {
|
||||
box-sizing: content-box;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.svg-favorite svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.svg-favorite.favorite-on .svg-fill {
|
||||
fill: #ffb628;
|
||||
}
|
||||
|
||||
.report .tooltip-content {
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.report .custom-report {
|
||||
border-bottom: 3px solid var(--green);
|
||||
}
|
||||
|
||||
.report .original-report {
|
||||
}
|
||||
|
||||
.report #view-input-parameters .form-group {
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
.report #view-input-parameters .form-group label{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.report #report-view-input-param-submit,
|
||||
.report #view-input-parameters .form-group input {
|
||||
display: inline-block;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.report a.reportbutton {
|
||||
background-color: var(--grey);
|
||||
}
|
||||
|
||||
.report-edit-inactive {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.report-edit-active {
|
||||
visibility: visible;
|
||||
}
|
||||
@@ -0,0 +1,872 @@
|
||||
|
||||
/**
|
||||
* Run SQL Query and receive feedback about the success.
|
||||
*/
|
||||
var ReportDebugger = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
url: {
|
||||
ajaxRunSql: 'index.php?module=report&action=edit&cmd=ajaxTryQuery'
|
||||
},
|
||||
|
||||
selector: {
|
||||
resultTextBox: '#reportEditResult',
|
||||
queryTextBox: '#reportEditQuery',
|
||||
runDebugButton: '#structureRun',
|
||||
paramViewElement: '.parameter-view',
|
||||
},
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(me.selector.runDebugButton).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.ajaxDebugRequest();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
* @param {boolean} error
|
||||
*/
|
||||
showDebugMessage: function(message, error = false) {
|
||||
var $textArea = $(me.selector.resultTextBox);
|
||||
if (error === true) {
|
||||
$textArea.attr('error', 'true');
|
||||
} else {
|
||||
$textArea.attr('error', 'false');
|
||||
}
|
||||
$textArea.text(message);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
ajaxDebugRequest: function() {
|
||||
var params = {};
|
||||
$(me.selector.paramViewElement).each(function (index, element) {
|
||||
params[$(element).data('key')] = $(element).data('value');
|
||||
});
|
||||
var sql = $(me.selector.queryTextBox).val();
|
||||
$.ajax({
|
||||
url: me.url.ajaxRunSql,
|
||||
data:{
|
||||
statement: sql,
|
||||
parameters: params
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
App.loading.close();
|
||||
if (data.messagetype === 'error') {
|
||||
me.showDebugMessage(data.message, true);
|
||||
} else {
|
||||
me.showDebugMessage(data.message);
|
||||
}
|
||||
if (data.error) {
|
||||
throw('request error: ' + data.error);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* Add/Edit/Remove columns
|
||||
*/
|
||||
var ReportColumns = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
columnDialog: '#editColumnDialog',
|
||||
dialogMessageBox: '#editColMessage',
|
||||
inputFormId: '#reportEditId',
|
||||
inputId: '#editColId',
|
||||
inputKey: '#editColKey',
|
||||
inputTitle: '#editColTitle',
|
||||
inputWidth: '#editColWidth',
|
||||
inputAlign: '#editColAlignment',
|
||||
inputSort: '#editColSort',
|
||||
inputFormat: '#edit-col-format',
|
||||
inputFormatStatement: '#edit-col-format-statement',
|
||||
inputFormatRow: '#edit-col-format-statement-row',
|
||||
inputSum: '#chkColSum',
|
||||
inputSequence: '#editColSequence',
|
||||
buttonAddColumn: '#btnAddColumn',
|
||||
buttonAutoCreate: '#btnAutoCreateColumns',
|
||||
buttonDeleteAll: '#btnDeleteAllColumns',
|
||||
allColumnViews: 'a.table-button-col-edit',
|
||||
allColumnDelete: 'a.table-button-col-delete',
|
||||
dataTable: '#report_columns',
|
||||
resultTextBox: '#reportEditResult',
|
||||
queryTextBox: '#reportEditQuery',
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxGetColumn: 'index.php?module=report&action=edit&cmd=ajaxGetColumn',
|
||||
ajaxSaveColumn: 'index.php?module=report&action=edit&cmd=ajaxSaveColumn',
|
||||
ajaxDeleteColumn: 'index.php?module=report&action=edit&cmd=ajaxDeleteColumn',
|
||||
ajaxDeleteAllColumns: 'index.php?module=report&action=edit&cmd=ajaxDeleteColumn',
|
||||
ajaxAutoCreateColumns: 'index.php?module=report&action=edit&cmd=ajaxAutoCreateColumns'
|
||||
},
|
||||
|
||||
storage: {
|
||||
$dialog: null,
|
||||
formId: 0
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.storage.$dialog = $(me.selector.columnDialog);
|
||||
me.storage.formId = $(me.selector.inputFormId).data('form-id');
|
||||
me.dialogInit();
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogInit: function () {
|
||||
me.storage.$dialog.dialog({
|
||||
modal: true,
|
||||
bgiframe: true,
|
||||
closeOnEscape: false,
|
||||
minWidth: 500,
|
||||
minHeight: 320,
|
||||
maxHeight: 700,
|
||||
autoOpen: false,
|
||||
buttons: [
|
||||
{
|
||||
text: 'ABBRECHEN',
|
||||
click: function () {
|
||||
me.dialogClose();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'SPEICHERN',
|
||||
click: function () {
|
||||
me.dialogSave();
|
||||
}
|
||||
}],
|
||||
open: function () {
|
||||
$(me.selector.inputKey).trigger('focus');
|
||||
},
|
||||
close: function () {
|
||||
//me.dialogReset();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id data-id of the Column to be edited
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
dialogOpen: function (id = 0) {
|
||||
if (me.storage.formId < 1 && id < 1) {
|
||||
alert('Bitte speichern Sie zuerst den Bericht.');
|
||||
return;
|
||||
}
|
||||
if (id < 1) {
|
||||
me.dialogReset();
|
||||
me.storage.$dialog.dialog('open');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetColumn,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.dialogReset();
|
||||
me.setDialogData(data);
|
||||
App.loading.close();
|
||||
me.storage.$dialog.dialog('open');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogClose: function () {
|
||||
me.storage.$dialog.dialog('close');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogReset: function () {
|
||||
me.dialogSetMessage('');
|
||||
me.setDialogData(null);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogSave: function () {
|
||||
me.ajaxSaveColumn(me.getDialogData());
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogDelete: function () {
|
||||
var deleteId = me.storage.$dialog.find(me.selector.inputId).val();
|
||||
me.ajaxDeleteColumn(deleteId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
dialogSetMessage: function(message) {
|
||||
me.storage.$dialog.find(me.selector.dialogMessageBox).text(message);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
getDialogData: function() {
|
||||
return {
|
||||
reportId: me.storage.formId,
|
||||
id: me.storage.$dialog.find(me.selector.inputId).val(),
|
||||
key_name: me.storage.$dialog.find(me.selector.inputKey).val(),
|
||||
title: me.storage.$dialog.find(me.selector.inputTitle).val(),
|
||||
width: me.storage.$dialog.find(me.selector.inputWidth).val(),
|
||||
alignment: me.storage.$dialog.find(me.selector.inputAlign).val(),
|
||||
sorting: me.storage.$dialog.find(me.selector.inputSort).val(),
|
||||
format_type: me.storage.$dialog.find(me.selector.inputFormat).val(),
|
||||
format_statement: me.storage.$dialog.find(me.selector.inputFormatStatement).val(),
|
||||
sum: ((me.storage.$dialog.find(me.selector.inputSum).prop('checked') === true) ? 1 : 0),
|
||||
sequence: me.storage.$dialog.find(me.selector.inputSequence).val()
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
setDialogData: function(data) {
|
||||
if (data == null) {
|
||||
data = {};
|
||||
}
|
||||
me.storage.$dialog.find(me.selector.inputId).val('id' in data ? data.id : '');
|
||||
me.storage.$dialog.find(me.selector.inputKey).val('key_name' in data ? data.key_name : '');
|
||||
me.storage.$dialog.find(me.selector.inputTitle).val('title' in data ? data.title : '');
|
||||
me.storage.$dialog.find(me.selector.inputWidth).val('width' in data ? data.width : '');
|
||||
me.storage.$dialog.find(me.selector.inputAlign).val(
|
||||
(('alignment' in data && data.alignment !== '') ? data.alignment : 'left')
|
||||
);
|
||||
me.storage.$dialog.find(me.selector.inputSort).val(
|
||||
(('sorting' in data && data.sorting !== '') ? data.sorting : 'numeric')
|
||||
);
|
||||
me.storage.$dialog.find(me.selector.inputFormat).val('format_type' in data ? data.format_type : null);
|
||||
me.storage.$dialog.find(me.selector.inputFormatStatement)
|
||||
.val('format_statement' in data ? data.format_statement : null);
|
||||
me.storage.$dialog.find(me.selector.inputSum).prop('checked', 'sum' in data ? data.sum : false);
|
||||
me.storage.$dialog.find(me.selector.inputSequence).val('sequence' in data ? data.sequence : '');
|
||||
me.toggleReportStatementField();
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(me.selector.buttonAddColumn).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.dialogOpen(0)
|
||||
});
|
||||
$(me.selector.buttonAutoCreate).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.autoCreateColumns();
|
||||
});
|
||||
$(me.selector.buttonDeleteAll).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
var confirmValue = confirm('Wirklich alle Spalten Löschen?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
me.ajaxDeleteColumn(0, true);
|
||||
});
|
||||
$(me.selector.inputFormat).on('change', function (event) {
|
||||
me.toggleReportStatementField();
|
||||
});
|
||||
$(document).on('click', me.selector.allColumnViews, function (event) {
|
||||
var id = $(event.currentTarget).data('column-id');
|
||||
me.dialogOpen(id);
|
||||
});
|
||||
$(document).on('click', me.selector.allColumnDelete, function (event) {
|
||||
var id = $(event.currentTarget).data('column-id');
|
||||
if (id > 0) {
|
||||
var confirmValue = confirm('Wirklich Löschen?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
me.ajaxDeleteColumn(id);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
tableRefresh: function () {
|
||||
if ($.fn.DataTable.isDataTable(me.selector.dataTable)) {
|
||||
$(me.selector.dataTable).DataTable().ajax.reload();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} dialogData
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ajaxSaveColumn: function(dialogData) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxSaveColumn,
|
||||
data: dialogData,
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (response) {
|
||||
me.dialogClose();
|
||||
me.tableRefresh();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
me.dialogSetMessage(xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
* @param {boolean} deleteAll
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ajaxDeleteColumn: function(id, deleteAll = false) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxDeleteColumn,
|
||||
data:{
|
||||
id:id,
|
||||
delete_all:deleteAll,
|
||||
report_id: me.storage.formId
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.tableRefresh();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
toggleReportStatementField: function() {
|
||||
var formatType = me.storage.$dialog.find(me.selector.inputFormat).val();
|
||||
if (formatType === 'custom') {
|
||||
me.storage.$dialog.find(me.selector.inputFormatRow)
|
||||
.removeClass('report-edit-inactive')
|
||||
.addClass('report-edit-active');
|
||||
} else {
|
||||
me.storage.$dialog.find(me.selector.inputFormatRow)
|
||||
.removeClass('report-edit-active')
|
||||
.addClass('report-edit-inactive');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
autoCreateColumns: function() {
|
||||
if (me.storage.formId < 1) {
|
||||
alert('Bitte speichern Sie zuerst den Bericht.')
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: me.url.ajaxAutoCreateColumns,
|
||||
data:{
|
||||
id:me.storage.formId
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
console.log('response', data);
|
||||
if (data.success === true) {
|
||||
me.tableRefresh();
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* Add/Edit/Remove params
|
||||
*/
|
||||
var ReportParams = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
storage: {
|
||||
$dialog: null,
|
||||
formId: 0
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxGetParam: 'index.php?module=report&action=edit&cmd=ajaxGetParam',
|
||||
ajaxSaveParam: 'index.php?module=report&action=edit&cmd=ajaxSaveParam',
|
||||
ajaxDeleteParam: 'index.php?module=report&action=edit&cmd=ajaxDeleteParam'
|
||||
},
|
||||
|
||||
selector: {
|
||||
dialog: '#editParamDialog',
|
||||
dialogMessageBox: '#editParamMessage',
|
||||
inputReportId: '#reportEditId',
|
||||
inputId: '#editParamId',
|
||||
inputVarname: '#editParamVarname',
|
||||
inputValue: '#editParamValue',
|
||||
inputLabel: '#editParamLabel',
|
||||
inputDescription: '#editParamDescription',
|
||||
inputOptions: '#editParamOptions',
|
||||
inputControl: '#editParamControl',
|
||||
inputEditable: '#chkParamEditable',
|
||||
buttonAddParameter: '#btnAddParam',
|
||||
allParamViews: '#paramListing > .parameter-view',
|
||||
paramsView: '#paramListing'
|
||||
},
|
||||
|
||||
template: {
|
||||
paramView: '<div class="parameter-view" data-id="{id}" data-key="{varname}" data-value="{value}">' +
|
||||
'{varname}={value}</div>'
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.storage.formId = $(me.selector.inputReportId).data('form-id');
|
||||
me.storage.$dialog = $(me.selector.dialog);
|
||||
me.dialogInit();
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogInit: function () {
|
||||
me.storage.$dialog.dialog({
|
||||
modal: true,
|
||||
bgiframe: true,
|
||||
closeOnEscape: false,
|
||||
minWidth: 500,
|
||||
minHeight: 420,
|
||||
maxHeight: 700,
|
||||
autoOpen: false,
|
||||
buttons: [
|
||||
{
|
||||
text: 'LÖSCHEN',
|
||||
click: function () {
|
||||
me.dialogDelete();
|
||||
me.dialogClose();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'ABBRECHEN',
|
||||
click: function () {
|
||||
me.dialogClose();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'SPEICHERN',
|
||||
click: function () {
|
||||
me.dialogSave();
|
||||
}
|
||||
}],
|
||||
open: function () {
|
||||
$(me.selector.inputVarname).trigger('focus');
|
||||
},
|
||||
close: function () {
|
||||
//me.dialogReset();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
dialogOpen: function (id = 0) {
|
||||
if (me.storage.formId < 1 && id < 1) {
|
||||
alert('Bitte speichern Sie zuerst den Bericht.');
|
||||
return;
|
||||
}
|
||||
if (id < 1) {
|
||||
me.dialogReset();
|
||||
me.storage.$dialog.dialog('open');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetParam,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.dialogReset();
|
||||
me.setDialogData(data)
|
||||
App.loading.close();
|
||||
me.storage.$dialog.dialog('open');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogClose: function () {
|
||||
me.storage.$dialog.dialog('close');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogReset: function () {
|
||||
me.dialogSetMessage('');
|
||||
me.setDialogData(null);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogSave: function () {
|
||||
var varname = me.storage.$dialog.find(me.selector.inputVarname).val().toUpperCase();
|
||||
me.storage.$dialog.find(me.selector.inputVarname).val(varname);
|
||||
me.ajaxSaveParam(me.getDialogData());
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogDelete: function () {
|
||||
var confirmValue = confirm('Wirklich Löschen?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
var deleteId = me.storage.$dialog.find('#editParamId').val();
|
||||
me.ajaxDeleteParam(deleteId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
dialogSetMessage: function(message = '') {
|
||||
me.storage.$dialog.find(me.selector.dialogMessageBox).text(message);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
getDialogData: function() {
|
||||
return {
|
||||
reportId: me.storage.formId,
|
||||
paramId: me.storage.$dialog.find(me.selector.inputId).val(),
|
||||
varname: me.storage.$dialog.find(me.selector.inputVarname).val(),
|
||||
value: me.storage.$dialog.find(me.selector.inputValue).val(),
|
||||
label: me.storage.$dialog.find(me.selector.inputLabel).val(),
|
||||
description: me.storage.$dialog.find(me.selector.inputDescription).val(),
|
||||
options: me.storage.$dialog.find(me.selector.inputOptions).val(),
|
||||
control_type: me.storage.$dialog.find(me.selector.inputControl).val(),
|
||||
editable: (me.storage.$dialog.find(me.selector.inputEditable).prop('checked') === true ? 1 : 0)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
setDialogData: function(data) {
|
||||
if (data == null) {
|
||||
data = {};
|
||||
}
|
||||
me.storage.$dialog.find(me.selector.inputId).val('id' in data ? data.id : '');
|
||||
me.storage.$dialog.find(me.selector.inputVarname).val('varname' in data ? data.varname : '');
|
||||
me.storage.$dialog.find(me.selector.inputValue).val('default_value' in data ? data.default_value : '');
|
||||
me.storage.$dialog.find(me.selector.inputLabel).val('displayname' in data ? data.displayname : '');
|
||||
me.storage.$dialog.find(me.selector.inputDescription).val('description' in data ? data.description : '');
|
||||
me.storage.$dialog.find(me.selector.inputOptions).val('options' in data ? data.options : '');
|
||||
// me.storage.$dialog.find(me.selector.inputControl).val('control_type' in data ? data.control_type : '');
|
||||
me.storage.$dialog.find(me.selector.inputControl).val(
|
||||
(('control_type' in data && data.control_type !== '') ? data.control_type : 'text')
|
||||
);
|
||||
me.storage.$dialog.find(me.selector.inputEditable).prop(
|
||||
'checked',
|
||||
('editable' in data ? data.editable : false)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(me.selector.buttonAddParameter).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.dialogOpen();
|
||||
});
|
||||
$(document).on('click', me.selector.allParamViews, function (event) {
|
||||
var id = $(event.target).data('id');
|
||||
me.dialogOpen(id);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} varname
|
||||
* @param {string} value
|
||||
* @param {number} id
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
updateParameterView: function(varname, value, id) {
|
||||
var $view = $(me.selector.paramsView);
|
||||
var $existing = $view.find('div[data-id="'+id+'"]');
|
||||
|
||||
if ($existing === null || $existing.length === 0) {
|
||||
var htmlElement = (me.template.paramView + '')
|
||||
.replace('{id}', id)
|
||||
.replace(new RegExp('\\{varname\\}', 'g'), varname)
|
||||
.replace(new RegExp('\\{value\\}', 'g'), value);
|
||||
$view.append(htmlElement);
|
||||
} else {
|
||||
$existing.text(varname + '=' + value);
|
||||
$existing.attr('data-key', varname);
|
||||
$existing.attr('data-value', value);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
removeParameterView: function(id) {
|
||||
$(me.selector.paramsView + ' > div[data-id="'+id+'"]').remove();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} dialogData
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ajaxSaveParam: function(dialogData) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxSaveParam,
|
||||
data: dialogData,
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (response) {
|
||||
me.updateParameterView(dialogData.varname, dialogData.value, response.id);
|
||||
me.dialogClose();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
me.dialogSetMessage(xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
ajaxDeleteParam: function(id) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxDeleteParam,
|
||||
data:{
|
||||
id:id
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.removeParameterView(id);
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* Mark query field as yellow if not saved
|
||||
*/
|
||||
var ChangesHighlight = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
storage: {
|
||||
initQuery: '',
|
||||
$queryBox: null,
|
||||
$hint: null
|
||||
},
|
||||
|
||||
selector: {
|
||||
queryTextBox: '#reportEditQuery',
|
||||
runDebugButton: '#structureRun',
|
||||
dirtyHint: '#dirtyWarning',
|
||||
},
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.storage.$queryBox = $(me.selector.queryTextBox);
|
||||
me.storage.$hint = $(me.selector.dirtyHint);
|
||||
me.storage.initQuery = me.storage.$queryBox.val();
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(me.selector.queryTextBox).on('input propertychange', function (event) {
|
||||
me.updateHighlight();
|
||||
});
|
||||
},
|
||||
|
||||
updateHighlight: function () {
|
||||
if (me.storage.$queryBox.val() !== me.storage.initQuery) {
|
||||
me.storage.$queryBox.attr('dirty', 'true');
|
||||
me.storage.$hint.attr('dirty', 'true');
|
||||
} else {
|
||||
me.storage.$queryBox.attr('dirty', 'false');
|
||||
me.storage.$hint.attr('dirty', 'false');
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function () {
|
||||
if($('#report_edit_form').length === 0) {
|
||||
return;
|
||||
}
|
||||
ReportColumns.init();
|
||||
ReportDebugger.init();
|
||||
ReportParams.init();
|
||||
ChangesHighlight.init();
|
||||
});
|
||||
@@ -0,0 +1,437 @@
|
||||
|
||||
/**
|
||||
* Copy/Delete a Report
|
||||
*/
|
||||
var TileView = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
keyElement: '#report_list_main',
|
||||
tileView: '#reportTileView',
|
||||
filterButton: '#reportListFilterApply',
|
||||
filterCategory: '#reportListFilterCategory',
|
||||
filterCategorySelect: '#reportListFilterCategory > ul.ui-autocomplete',
|
||||
filterOwn: '#report-list-filter-own',
|
||||
filterFavorites: '#report-list-filter-favorites',
|
||||
filterTerm: '#reportListFilterTerm',
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxGetTiles: 'index.php?module=report&action=list&cmd=ajaxTiles',
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
if($(me.selector.keyElement).length === 0) {
|
||||
return;
|
||||
}
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
registerEvents: function () {
|
||||
$(me.selector.filterButton).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.reloadTiles();
|
||||
});
|
||||
$(me.selector.filterCategory).on('blur', function (event) {
|
||||
me.reloadTiles();
|
||||
});
|
||||
$(me.selector.filterOwn).on('change', function (event) {
|
||||
me.reloadTiles();
|
||||
});
|
||||
$(me.selector.filterFavorites).on('change', function (event) {
|
||||
me.reloadTiles();
|
||||
});
|
||||
},
|
||||
|
||||
getFilterSettings: function () {
|
||||
return {
|
||||
filter_category: $(me.selector.filterCategory).val(),
|
||||
filter_term: $(me.selector.filterTerm).val(),
|
||||
filter_own: $(me.selector.filterOwn).prop('checked'),
|
||||
filter_favorites: $(me.selector.filterFavorites).prop('checked'),
|
||||
}
|
||||
},
|
||||
|
||||
reloadTiles: function () {
|
||||
console.log('filter: ', me.getFilterSettings());
|
||||
var $tileView = $(me.selector.tileView);
|
||||
if ($tileView.length === 0) {
|
||||
return;
|
||||
}
|
||||
var $parent = $tileView.parent();
|
||||
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetTiles,
|
||||
method: 'post',
|
||||
data: me.getFilterSettings(),
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$tileView.remove();
|
||||
$parent.append(data.html);
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
return {
|
||||
init: me.init,
|
||||
reload: me.reloadTiles,
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* Input of Parameters for the report
|
||||
*/
|
||||
var ParameterInput = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
downloadButtons: '.report .download-csv-button.active',
|
||||
tile: '.report .tile-body'
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
if (typeof ReportParameterInputDialog.open !== "function") {
|
||||
throw 'ReportParameterInputDialog required';
|
||||
}
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
registerEvents: function () {
|
||||
$(document).on('click', me.selector.downloadButtons, function (event) {
|
||||
event.preventDefault();
|
||||
var id = $(event.currentTarget).data('report-id');
|
||||
var format = $(event.currentTarget).data('format');
|
||||
var onClose = function (data, command) {
|
||||
|
||||
var url = 'index.php?module=report&action=download&id='+id+'&format=' + format;
|
||||
if(data !== null) {
|
||||
var paramString = $.param(data);
|
||||
url = url + '&' + paramString
|
||||
}
|
||||
window.location.href = url;
|
||||
};
|
||||
ReportParameterInputDialog.open(id, 'report-list', onClose, 'Parameter', 'DOWNLOAD');
|
||||
});
|
||||
|
||||
// DEACTIVATED
|
||||
//$(document).on('click', me.selector.tile, function (event) {
|
||||
// event.preventDefault();
|
||||
// var id = $(event.currentTarget).data('id');
|
||||
// var onClose = function (data, command) {
|
||||
// var url = 'index.php?module=report&action=view&cmd=view&id='+id;
|
||||
// if(data !== null) {
|
||||
// var paramString = $.param(data);
|
||||
// url = url + '&' + paramString
|
||||
// }
|
||||
// window.location.href = url;
|
||||
// };
|
||||
// ReportParameterInputDialog.open(id, 'report-list', onClose, 'Parameter', 'WEITER');
|
||||
//});
|
||||
},
|
||||
|
||||
};
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* Copy/Delete a Report
|
||||
*/
|
||||
var ReportListDataTable = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
allCopyButtons: 'a.table-button-copy',
|
||||
allDeleteButtons: 'a.table-button-delete',
|
||||
allChartButtons: 'a.chart-button',
|
||||
dataTable: '#report_list',
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxCopyReport: 'index.php?module=report&action=create&cmd=ajaxCopyReport',
|
||||
ajaxDeleteReport: 'index.php?module=report&action=delete&cmd=ajaxDeleteReport',
|
||||
ajaxGetChart: 'index.php?module=report&action=list&cmd=getchart',
|
||||
},
|
||||
|
||||
storage: {
|
||||
TileView: null,
|
||||
},
|
||||
|
||||
init: function (tileView) {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.storage.TileView = tileView;
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(document).on('click', me.selector.allCopyButtons, function (event) {
|
||||
var id = $(event.currentTarget).data('report-id');
|
||||
if (id > 0) {
|
||||
var confirmValue = confirm('Bericht kopieren?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
me.ajaxCopyReport(id);
|
||||
}
|
||||
});
|
||||
$(document).on('click', me.selector.allDeleteButtons, function (event) {
|
||||
var id = $(event.currentTarget).data('report-id');
|
||||
if (id > 0) {
|
||||
var confirmValue = confirm('Wirklich Löschen?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
me.ajaxDeleteReport(id);
|
||||
}
|
||||
});
|
||||
$(document).on('click', me.selector.allChartButtons, function (event) {
|
||||
console.log('event fired');
|
||||
var id = $(event.currentTarget).data('report-id');
|
||||
if (id > 0) {
|
||||
me.openChartReport(id);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
refreshTable: function () {
|
||||
if ($.fn.DataTable.isDataTable(me.selector.dataTable)) {
|
||||
$(me.selector.dataTable).DataTable().ajax.reload();
|
||||
}
|
||||
if ($(me.selector.tileView !== null)) {
|
||||
me.storage.TileView.reload();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} id
|
||||
*/
|
||||
ajaxCopyReport: function (id = 0) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxCopyReport,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.refreshTable();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
if (xhr.status === 401) {
|
||||
alert('Ihnen fehlt die Berechtigung.');
|
||||
} else {
|
||||
console.log(status, httpStatus, xhr.responseText);
|
||||
alert('Fehler beim Kopieren.');
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} id
|
||||
*/
|
||||
ajaxDeleteReport: function (id = 0) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxDeleteReport,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.refreshTable();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
if (xhr.status === 403) {
|
||||
alert('Dieser Bericht ist schreibgeschützt.');
|
||||
} else if (xhr.status === 401) {
|
||||
alert('Ihnen fehlt die Berechtigung.');
|
||||
} else {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} id
|
||||
*/
|
||||
openChartReport: function (id = 0) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetChart,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
if(typeof data.html != 'undefined') {
|
||||
$('#dialogReportChartContent').html(data.html);
|
||||
ChartHelper.initChart($('#dialogReportChartContent div.chart-wrapper').first());
|
||||
$('#dialogReportChart').dialog(
|
||||
{
|
||||
modal: true,
|
||||
autoOpen: true,
|
||||
minWidth: 940,
|
||||
title:'',
|
||||
buttons: {
|
||||
'OK': function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
close: function(event, ui){
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
if (xhr.status === 403) {
|
||||
alert('Dieser Bericht ist schreibgeschützt.');
|
||||
} else {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
};
|
||||
return {
|
||||
init: me.init,
|
||||
reloadTiles: me.reloadTiles,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
||||
/**
|
||||
* Copy/Delete a Report
|
||||
*/
|
||||
var FavoriteIcon = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
allFavoriteIcons: '.svg-favorite',
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxSetFavorite: 'index.php?module=report&action=list&cmd=ajaxSetFavorite',
|
||||
ajaxGetFavorite: 'index.php?module=report&action=list&cmd=ajaxGetFavorite',
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
registerEvents: function () {
|
||||
$(document).on('click', me.selector.allFavoriteIcons, function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var id = $(event.currentTarget).data('id');
|
||||
var favorite = parseInt($(event.currentTarget).data('favorite')) === 1;
|
||||
// if (id > 0) {
|
||||
// var confirmValue = confirm('Bericht kopieren?');
|
||||
// if (confirmValue === false) {
|
||||
// return;
|
||||
// }
|
||||
me.switchFavoriteIcon($(event.currentTarget));
|
||||
// }
|
||||
});
|
||||
},
|
||||
|
||||
switchFavoriteIcon: function ($target) {
|
||||
var id = $target.data('id');
|
||||
var favorite = parseInt($target.data('favorite')) === 1;
|
||||
|
||||
$.ajax({
|
||||
url: me.url.ajaxSetFavorite,
|
||||
method: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
set_favorite: !favorite
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.is_favorite === true) {
|
||||
$target.addClass('favorite-on');
|
||||
$target.data('favorite', 1);
|
||||
} else {
|
||||
$target.removeClass('favorite-on');
|
||||
$target.data('favorite', 0);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
init: me.init,
|
||||
reload: me.reloadTiles,
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
TileView.init();
|
||||
ReportListDataTable.init(TileView);
|
||||
FavoriteIcon.init();
|
||||
ParameterInput.init();
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
var ReportMenuPopup = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
storage: {
|
||||
menulinks: null,
|
||||
menuPopup: null
|
||||
},
|
||||
openMenuPopup: function (reportId)
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php?module=report&action=view&cmd=getreportpopup',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { report_id: reportId },
|
||||
success: function(data) {
|
||||
if(typeof data.html != 'undefined')
|
||||
{
|
||||
$('#reportMenuPopupContent').html(data.html);
|
||||
$(me.storage.menuPopup).dialog('open');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
me.storage.menuPopup = $('#reportMenuPopup');
|
||||
if(me.storage.menuPopup.length === 0) {
|
||||
return;
|
||||
}
|
||||
me.storage.menuLinks = $('ul#submenu li a.reportpopup');
|
||||
if(me.storage.menuLinks.length === 0) {
|
||||
return;
|
||||
}
|
||||
$(me.storage.menuPopup).dialog(
|
||||
{
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
minWidth: 940,
|
||||
title: '',
|
||||
buttons: {
|
||||
'OK': function () {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
me.storage.menuLinks.on('click',function(){
|
||||
me.openMenuPopup($(this).data('reportid'));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
$(document).on('ready',function(){
|
||||
ReportMenuPopup.init();
|
||||
});
|
||||
@@ -0,0 +1,328 @@
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add/Edit/Remove columns
|
||||
*/
|
||||
var ReportParameterInputDialog = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
template: {
|
||||
dialog: '<div id="{dialog_id}" style="display:none;" title="{dialog_title}">\n' +
|
||||
'\t<form method="post">\n' +
|
||||
'\t\t<div>\n' +
|
||||
'\t\t\t<fieldset>\n' +
|
||||
'\t\t\t\t<table class="input-control-pane" width="100%">\n' +
|
||||
'\t\t\t\t</table>\n' +
|
||||
'\t\t\t</fieldset>\n' +
|
||||
'\t\t</div>\n' +
|
||||
'\t</form>\n' +
|
||||
'</div>',
|
||||
|
||||
inputField:'<tr>' +
|
||||
'<td><label for="{id}">{label}:</label></td>\n' +
|
||||
'<td><input type="text" name="{varname}" id="{id}" width="80%"></td>\n' +
|
||||
'</tr>',
|
||||
|
||||
selectField:'<tr>' +
|
||||
'<td><label for="{id}">{label}:</label></td>\n' +
|
||||
'<td><select type="text" name="{varname}" id="{id}" width="80%">' +
|
||||
'{options}' +
|
||||
'</select></td>\n' +
|
||||
'</tr>',
|
||||
selectOption: '<option value="{optvalue}">{optdisplay}</option>'
|
||||
},
|
||||
|
||||
selector: {
|
||||
dialog: '',
|
||||
inputPanel: '',
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxGetInputParams: 'index.php?module=report&action=list&cmd=ajaxGetInputParameters',
|
||||
ajaxDownload: 'index.php?module=report&action=download',
|
||||
},
|
||||
|
||||
storage: {
|
||||
$dialog: null,
|
||||
$fieldSet: null,
|
||||
formId: 0,
|
||||
fields: {},
|
||||
submitButtonText: ''
|
||||
},
|
||||
|
||||
createDialog: function (prefix, onClose = me.onClose, title = 'Parameter', submitButtonText = 'OK') {
|
||||
|
||||
var dialogId = prefix + '-parameter-input-dialog';
|
||||
me.selector.dialog = '#' + dialogId;
|
||||
|
||||
if ($(me.selector.dialog).length === 0) {
|
||||
var htmldialog = (me.template.dialog + '')
|
||||
.replace('{dialog_id}', dialogId)
|
||||
.replace('{dialog_title}', title);
|
||||
$('body').append(htmldialog);
|
||||
}
|
||||
|
||||
if (typeof onClose !== 'function') {
|
||||
throw 'function onClose required for parameter dialog';
|
||||
}
|
||||
me.onClose = onClose;
|
||||
|
||||
me.selector.inputPanel = me.selector.dialog + ' .input-control-pane';
|
||||
me.storage.submitButtonText = submitButtonText;
|
||||
|
||||
if ($(me.selector.dialog).length === 0) {
|
||||
throw 'Dialog markup does not exitst';
|
||||
}
|
||||
me.storage.$dialog = $(me.selector.dialog);
|
||||
me.storage.$fieldSet = $(me.selector.inputPanel);
|
||||
me.dialogInit(submitButtonText);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogInit: function (submitButtonText) {
|
||||
me.storage.$dialog.dialog({
|
||||
modal: true,
|
||||
bgiframe: true,
|
||||
closeOnEscape: false,
|
||||
minWidth: 800,
|
||||
minHeight: 120,
|
||||
maxHeight: 700,
|
||||
autoOpen: false,
|
||||
buttons: [
|
||||
{
|
||||
text: 'ABBRECHEN',
|
||||
click: function () {
|
||||
me.dialogClose();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: submitButtonText,
|
||||
click: function () {
|
||||
me.dialogCommit();
|
||||
}
|
||||
}],
|
||||
open: function () {
|
||||
//$(me.selector.inputKey).trigger('focus');
|
||||
},
|
||||
close: function () {
|
||||
//me.dialogReset();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id data-id of the Column to be edited
|
||||
*
|
||||
* @param {string} prefix
|
||||
* @param {function} onClose
|
||||
* @param {string} title
|
||||
* @param {string} submitButtonText
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
open: function (id = 0, prefix, onClose = me.onClose, title = 'Parameter', submitButtonText = 'OK') {
|
||||
me.createDialog(prefix, onClose, title, submitButtonText);
|
||||
me.storage.formId = id;
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetInputParams,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.dialogInitFields(data.params);
|
||||
if (me.storage.fields === null || $.isEmptyObject(me.storage.fields)) {
|
||||
me.onClose(null, 'skip');
|
||||
} else {
|
||||
me.storage.$dialog.dialog('open');
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {array} params
|
||||
*/
|
||||
dialogInitFields: function (params) {
|
||||
me.dialogReset();
|
||||
params.forEach(me.addInputField);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} item
|
||||
* @param {int} index
|
||||
* @param {array} array
|
||||
*/
|
||||
addInputField: function (item, index, array) {
|
||||
if (item.editable !== true) {
|
||||
return;
|
||||
}
|
||||
var fieldname = item.varname;
|
||||
var guiId = 'inputParam' + item.varname;
|
||||
var label = item.displayname;
|
||||
if (label === null || label === '') {
|
||||
label = item.varname.toString().toUpperCase();
|
||||
}
|
||||
me.storage.fields[fieldname] = guiId;
|
||||
var htmlElement = '';
|
||||
if (item.options.length > 0 && item.control_type === 'combobox') {
|
||||
var htmlOptions = '';
|
||||
for ( var i = 0; i < item.options.length; i++ ) {
|
||||
var key = Object.keys(item.options[i])[0];
|
||||
var val = item.options[i][key];
|
||||
|
||||
var opt = (me.template.selectOption + '')
|
||||
.replace('{optvalue}', val)
|
||||
.replace('{optdisplay}', key);
|
||||
htmlOptions += opt;
|
||||
}
|
||||
|
||||
htmlElement = (me.template.selectField + '')
|
||||
.replace(new RegExp('\\{id\\}', 'g'), guiId)
|
||||
.replace('{varname}', item.varname)
|
||||
.replace('{label}', label)
|
||||
.replace('{options}', htmlOptions);
|
||||
me.storage.$fieldSet.append(htmlElement);
|
||||
}
|
||||
|
||||
if (item.control_type === '' || item.control_type === 'text') {
|
||||
htmlElement = (me.template.inputField + '')
|
||||
.replace(new RegExp('\\{id\\}', 'g'), guiId)
|
||||
.replace('{varname}', item.varname)
|
||||
.replace('{label}', label);
|
||||
me.storage.$fieldSet.append(htmlElement);
|
||||
}
|
||||
|
||||
if (item.control_type === 'date') {
|
||||
htmlElement = (me.template.inputField + '')
|
||||
.replace(new RegExp('\\{id\\}', 'g'), guiId)
|
||||
.replace('{varname}', item.varname)
|
||||
.replace('{label}', label);
|
||||
me.storage.$fieldSet.append(htmlElement);
|
||||
$('#' + guiId).datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
dayNamesMin: ['SO', 'MO', 'DI', 'MI', 'DO', 'FR', 'SA'],
|
||||
firstDay:1,
|
||||
showWeek: true,
|
||||
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
|
||||
});
|
||||
}
|
||||
|
||||
if (item.control_type === 'autocomplete_project') {
|
||||
me.createAutoComplete(fieldname, label, guiId, "index.php?module=ajax&action=filter&filtername=projektname");
|
||||
}
|
||||
|
||||
if (item.control_type === 'autocomplete_group') {
|
||||
me.createAutoComplete(fieldname, label, guiId, "index.php?module=ajax&action=filter&filtername=gruppe");
|
||||
}
|
||||
|
||||
if (item.control_type === 'autocomplete_address') {
|
||||
me.createAutoComplete(fieldname, label, guiId, "index.php?module=ajax&action=filter&filtername=adresse");
|
||||
}
|
||||
|
||||
if (item.control_type === 'autocomplete_article') {
|
||||
me.createAutoComplete(fieldname, label, guiId, "index.php?module=ajax&action=filter&filtername=artikelnummer");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} fieldname
|
||||
* @param {string} label
|
||||
* @param {string} guiId
|
||||
* @param {string} source
|
||||
*/
|
||||
createAutoComplete: function (fieldname, label, guiId, source) {
|
||||
var htmlAuto = (me.template.inputField + '')
|
||||
.replace(new RegExp('\\{id\\}', 'g'), guiId)
|
||||
.replace('{varname}', fieldname)
|
||||
.replace('{label}', label);
|
||||
me.storage.$fieldSet.append(htmlAuto);
|
||||
|
||||
var $element = $('#' + guiId);
|
||||
$element.autocomplete({
|
||||
source: source,
|
||||
select: function (event, ui) {
|
||||
var i = $element.val() + ui.item.value;
|
||||
var zahl = i.indexOf(",");
|
||||
|
||||
var text = i.slice(0, zahl);
|
||||
if (zahl <= 0)
|
||||
$element.val(ui.item.value);
|
||||
else {
|
||||
var j = $element.val();
|
||||
var zahlletzte = j.lastIndexOf(",");
|
||||
var text2 = j.substring(0, zahlletzte);
|
||||
|
||||
$element.val(text2 + "," + ui.item.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogClose: function () {
|
||||
me.storage.$dialog.dialog('close');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogReset: function () {
|
||||
me.storage.fields = {};
|
||||
me.storage.$fieldSet.empty();
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogCommit: function (command = 'commit') {
|
||||
me.onClose(me.getDialogData(), command);
|
||||
me.dialogClose();
|
||||
},
|
||||
|
||||
onClose: function (data, command) {
|
||||
console.log('no action defined');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
getDialogData: function() {
|
||||
var data = {
|
||||
id: me.storage.formId,
|
||||
};
|
||||
for(var field in me.storage.fields) {
|
||||
var input = $('#' + me.storage.fields[field]).val();
|
||||
if(input !== null && input !== '') {
|
||||
data[field] = input;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return {
|
||||
open: me.open,
|
||||
onClose: me.onClose
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,279 @@
|
||||
|
||||
|
||||
var SharingDialog = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
dialog: '#editSharingDialog',
|
||||
dataTable: '#report_shareduser',
|
||||
dialogMessage: '#dialogMessage',
|
||||
addUserButton: '#shareUserAddBtn',
|
||||
editUserButton: 'a.table-button-edit',
|
||||
deleteUserButton: 'a.table-button-delete',
|
||||
pageInputUser: '#sharedUserFind',
|
||||
inputUser: '#inputDialogUser',
|
||||
inputUserId: '#inputDialogUserId',
|
||||
inputReportId: '#inputDialogReportId',
|
||||
checkChart: '#chkDialogShareChart',
|
||||
checkFile: '#chkDialogShareFile',
|
||||
checkMenu: '#chkDialogShareMenu',
|
||||
checkTab: '#chkDialogShareTab'
|
||||
},
|
||||
|
||||
url: {
|
||||
ajaxGetSharedUser: 'index.php?module=report&action=share&cmd=ajaxGetShareUser',
|
||||
ajaxSaveSharedUser: 'index.php?module=report&action=share&cmd=ajaxSaveShareUser',
|
||||
ajaxDeleteSharedUser: 'index.php?module=report&action=share&cmd=ajaxDeleteShareUser'
|
||||
},
|
||||
|
||||
storage: {
|
||||
$dialog: null,
|
||||
formId: 0,
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
console.log('init sharing dialog');
|
||||
me.storage.$dialog = $(me.selector.dialog);
|
||||
if (me.storage.$dialog.length !== 1) {
|
||||
console.log('stop init sharing dialog');
|
||||
return;
|
||||
}
|
||||
|
||||
me.dialogInit();
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogInit: function () {
|
||||
me.storage.$dialog.dialog({
|
||||
modal: true,
|
||||
bgiframe: true,
|
||||
closeOnEscape: false,
|
||||
minWidth: 600,
|
||||
maxWidth: 600,
|
||||
minHeight: 120,
|
||||
maxHeight: 700,
|
||||
autoOpen: false,
|
||||
buttons: [
|
||||
{
|
||||
text: 'ABBRECHEN',
|
||||
click: function () {
|
||||
me.dialogClose();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'SPEICHERN',
|
||||
click: function () {
|
||||
me.dialogSave();
|
||||
}
|
||||
}],
|
||||
open: function () {
|
||||
$(me.selector.inputUser).trigger('focus');
|
||||
},
|
||||
close: function () {
|
||||
me.dialogReset();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} id data-id of the Column to be edited
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
dialogOpen: function (id = 0) {
|
||||
me.storage.formId = id;
|
||||
|
||||
if (id > 0) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxGetSharedUser,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.setDialogData(data);
|
||||
me.storage.$dialog.dialog('open');
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
me.dialogReset();
|
||||
var user = $(me.selector.pageInputUser).val();
|
||||
$(me.selector.inputUser).val(user);
|
||||
|
||||
me.storage.$dialog.dialog('open');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogClose: function () {
|
||||
me.storage.$dialog.dialog('close');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogReset: function () {
|
||||
me.setDialogData(null);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
dialogSave: function () {
|
||||
$.ajax({
|
||||
url: me.url.ajaxSaveSharedUser,
|
||||
data: me.getDialogData(),
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function (data) {
|
||||
me.tableRefresh();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
if (xhr.status === 400) {
|
||||
alert('Der Bericht ist für diesen Mitarbeiter schon freigegeben.');
|
||||
} else {
|
||||
alert('Fehler beim Speichern');
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
me.dialogClose();
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
getDialogData: function() {
|
||||
return {
|
||||
report_id: parseInt(me.storage.$dialog.find(me.selector.inputReportId).val()),
|
||||
id: me.storage.formId,
|
||||
user_id: me.storage.$dialog.find(me.selector.inputUserId).val(),
|
||||
name: me.storage.$dialog.find(me.selector.inputUser).val(),
|
||||
chart_enabled: (($(me.selector.checkChart).prop('checked') === true) ? 1 : 0),
|
||||
file_enabled: (($(me.selector.checkFile).prop('checked') === true) ? 1 : 0),
|
||||
menu_enabled: (($(me.selector.checkMenu).prop('checked') === true) ? 1 : 0),
|
||||
tab_enabled: (($(me.selector.checkTab).prop('checked') === true) ? 1 : 0)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
*/
|
||||
setDialogData: function(data) {
|
||||
if (data == null) {
|
||||
data = {
|
||||
report_id: 0,
|
||||
name: '',
|
||||
user_id: 0,
|
||||
chart_enabled: 0,
|
||||
file_enabled: 0,
|
||||
menu_enabled: 0,
|
||||
tab_enabled: 0
|
||||
};
|
||||
}
|
||||
$(me.selector.inputUser).val(data.name);
|
||||
$(me.selector.inputUserId).val(data.user_id);
|
||||
if (data.name !== '') {
|
||||
$(me.selector.inputUser).attr('disabled', true);
|
||||
} else {
|
||||
$(me.selector.inputUser).attr('disabled', false);
|
||||
}
|
||||
$(me.selector.checkChart).prop('checked', data.chart_enabled > 0);
|
||||
$(me.selector.checkFile).prop('checked', data.file_enabled > 0);
|
||||
$(me.selector.checkMenu).prop('checked', data.menu_enabled > 0);
|
||||
$(me.selector.checkTab).prop('checked', data.tab_enabled > 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
|
||||
$(document).on('click', me.selector.deleteUserButton, function (event) {
|
||||
var id = parseInt($(event.currentTarget).data('id'));
|
||||
if (id > 0) {
|
||||
var confirmValue = confirm('Wirklich Löschen?');
|
||||
if (confirmValue === false) {
|
||||
return;
|
||||
}
|
||||
me.ajaxDeleteSharedUser(id);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', me.selector.editUserButton, function (event) {
|
||||
var id = $(event.currentTarget).data('id');
|
||||
me.dialogOpen(id);
|
||||
});
|
||||
$(me.selector.addUserButton).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.dialogOpen(0);
|
||||
});
|
||||
},
|
||||
|
||||
tableRefresh: function () {
|
||||
if ($.fn.DataTable.isDataTable(me.selector.dataTable)) {
|
||||
$(me.selector.dataTable).DataTable().ajax.reload();
|
||||
}
|
||||
},
|
||||
|
||||
ajaxDeleteSharedUser: function (id) {
|
||||
$.ajax({
|
||||
url: me.url.ajaxDeleteSharedUser,
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
App.loading.open();
|
||||
},
|
||||
success: function () {
|
||||
me.tableRefresh();
|
||||
},
|
||||
error: function (xhr, status, httpStatus) {
|
||||
alert('Fehler beim Löschen');
|
||||
console.log(status + ' ' + httpStatus + ': ' + xhr.responseText);
|
||||
},
|
||||
complete: function () {
|
||||
App.loading.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
init: me.init
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function () {
|
||||
SharingDialog.init();
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
|
||||
|
||||
/**
|
||||
* Copy the generated link to clipboard
|
||||
*/
|
||||
var DownloadLinkToClipboar = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
keyElement: '#report_transfer_form',
|
||||
linkTextBox: '#transferUrlAdress',
|
||||
buttonCopyLink: '#transferUrlClipboard',
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
if($(me.selector.keyElement).length === 0) {
|
||||
return;
|
||||
}
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {void}
|
||||
*/
|
||||
registerEvents: function () {
|
||||
$(me.selector.buttonCopyLink).on('click', function (event) {
|
||||
event.preventDefault();
|
||||
me.copyToClipBoard($(me.selector.linkTextBox).val());
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
copyToClipBoard: function (text) {
|
||||
var textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
textArea.style.position="fixed";
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
try {
|
||||
var successful = document.execCommand('copy');
|
||||
} catch (err) {
|
||||
console.error('Unable to copy link to clipboard.');
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function () {
|
||||
DownloadLinkToClipboar.init();
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
|
||||
/**
|
||||
* Input Parameters
|
||||
*/
|
||||
var ParameterInput = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
if (typeof ReportParameterInputDialog.open !== "function") {
|
||||
throw 'ReportParameterInputDialog required';
|
||||
}
|
||||
var id = $('#tabs-1').data('id');
|
||||
var onClose = function (data, command) {
|
||||
var url = 'index.php?module=report&action=view&cmd=view&id=' + id;
|
||||
if(data !== null) {
|
||||
var paramString = $.param(data);
|
||||
url = url + '&' + paramString
|
||||
}
|
||||
window.location.href = url;
|
||||
};
|
||||
ReportParameterInputDialog.open(id, 'report-view', onClose, 'Parameter', 'WEITER');
|
||||
me.isInitialized = true;
|
||||
},
|
||||
};
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
/**
|
||||
* Input Parameters
|
||||
*/
|
||||
var LiveParameter = (function ($) {
|
||||
'use strict';
|
||||
|
||||
var me = {
|
||||
isInitialized: false,
|
||||
|
||||
selector: {
|
||||
inputFields: '.report .live-filter-input',
|
||||
selectFields: '.report .live-filter-select',
|
||||
dataTable: '#report_table',
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (me.isInitialized === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
me.registerEvents();
|
||||
me.isInitialized = true;
|
||||
},
|
||||
|
||||
registerEvents: function () {
|
||||
$(document).on('blur', me.selector.inputFields, function (event) {
|
||||
console.log('some param changed');
|
||||
|
||||
var varname = $(event.currentTarget).attr('name');
|
||||
var value = $(event.currentTarget).val();
|
||||
|
||||
console.log('start filter for ' + varname + '='+ value);
|
||||
me.setTableFilter(varname, value);
|
||||
});
|
||||
|
||||
$(document).on('xhr.dt', me.selector.dataTable, function (e, settings) {
|
||||
var api = new $.fn.dataTable.Api(settings);
|
||||
var $table = $(api.table().node());
|
||||
|
||||
console.log('xhr data', api.ajax.params());
|
||||
console.log(settings );
|
||||
});
|
||||
},
|
||||
|
||||
setTableFilter: function (varname, value) {
|
||||
if ($.fn.DataTable.isDataTable(me.selector.dataTable)) {
|
||||
|
||||
var $table = $(me.selector.dataTable);
|
||||
var table = $table.DataTable();
|
||||
var url = table.ajax.url();
|
||||
console.log('old url', url);
|
||||
var urlSplit = url.split('?');
|
||||
var path = urlSplit[0];
|
||||
var urlParams = new URLSearchParams(urlSplit[1]);
|
||||
|
||||
var postfixB64 = urlParams.get('postfix');
|
||||
var postfix = atob(postfixB64);
|
||||
|
||||
var oPostfix = JSON.parse(postfix);
|
||||
oPostfix[varname.toLowerCase()] = value;
|
||||
|
||||
var nPostfix = JSON.stringify(oPostfix);
|
||||
var nPostFixB64 = btoa(nPostfix);
|
||||
|
||||
urlParams.set('postfix', nPostFixB64);
|
||||
var nUrl = path + '?'+ urlParams.toString();
|
||||
console.log('new url ' + nUrl);
|
||||
table.ajax.url( 'foooooo' ).load();
|
||||
}
|
||||
},
|
||||
|
||||
refreshTable: function () {
|
||||
if ($.fn.DataTable.isDataTable(me.selector.dataTable)) {
|
||||
$(me.selector.dataTable).DataTable().ajax.reload();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
init: me.init,
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
// LiveParameter.init(); //Does not work for some reason
|
||||
});
|
||||
Reference in New Issue
Block a user