raimund@1386: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@1386: * Software engineering by Intevation GmbH raimund@1386: * raimund@1386: * This file is Free Software under the GNU GPL (v>=3) raimund@1386: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@1386: * the documentation coming with IMIS-Labordaten-Application for details. raimund@1386: */ raimund@1386: raimund@1386: /** raimund@1386: * Window with information about history of probe/messung objects.. raimund@1386: */ raimund@1386: Ext.define('Lada.view.window.AuditTrail', { raimund@1386: extend: 'Ext.window.Window', raimund@1386: raimund@1386: layout: 'fit', raimund@1386: raimund@1386: width: 300, raimund@1386: height: 300, raimund@1386: raimund@1386: type: null, raimund@1386: raimund@1386: objectId: null, raimund@1386: raimund@1393: dateItems: [ raimund@1393: "probeentnahme_beginn", raimund@1393: "probeentnahme_ende", raimund@1393: "solldatum_beginn", raimund@1393: "solldatum_ende", raimund@1393: "messzeitpunkt", raimund@1393: "datum" raimund@1393: ], raimund@1393: raimund@1386: raimund@1386: /** raimund@1386: * This function initialises the Window raimund@1386: */ raimund@1386: initComponent: function() { raimund@1386: var me = this; raimund@1386: var i18n = Lada.getApplication().bundle; raimund@1386: me.on({ raimund@1386: show: function() { raimund@1386: me.initData(); raimund@1386: } raimund@1386: }); raimund@1386: raimund@1386: me.title = i18n.getMsg("audit.title"); raimund@1386: me.buttons = [{ raimund@1386: text: i18n.getMsg('close'), raimund@1386: scope: me, raimund@1386: handler: me.close raimund@1386: }]; raimund@1386: me.items = [{ raimund@1386: border: 0, raimund@1386: //autoscroll: true, raimund@1386: overflowY: 'auto', raimund@1386: items: [{ raimund@1386: border: 0, raimund@1386: name: 'auditcontainer' raimund@1386: }] raimund@1386: }]; raimund@1386: me.callParent(arguments); raimund@1386: }, raimund@1386: raimund@1386: initData: function() { raimund@1386: if (this.type === null || this.objectId === null) { raimund@1386: return; raimund@1386: } raimund@1386: Ext.Ajax.request({ raimund@1386: url: 'lada-server/rest/audit/' + this.type + '/' + this.objectId, raimund@1386: method: 'GET', raimund@1386: scope: this, raimund@1386: success: this.loadSuccess, raimund@1386: failure: this.loadFailure raimund@1386: }); raimund@1386: }, raimund@1386: raimund@1386: loadSuccess: function(response) { tom@1406: var i18n = Lada.getApplication().bundle; raimund@1386: var json = Ext.decode(response.responseText); raimund@1386: var container = this.down('panel[name=auditcontainer]'); tom@1406: if (!json.success) { tom@1406: var html = '
' + i18n.getMsg(json.message.toString()) tom@1406: + '
'; raimund@1386: container.update(html); raimund@1386: } tom@1406: else { tom@1406: if (this.type === 'probe') { tom@1406: var html = this.createHtmlProbe(json); tom@1406: container.update(html); tom@1406: } tom@1406: else if (this.type === 'messung') { tom@1406: container.update(this.createHtmlMessung(json)); tom@1406: } raimund@1386: } raimund@1386: }, raimund@1386: raimund@1386: createHtmlProbe: function(json) { raimund@1386: var i18n = Lada.getApplication().bundle; raimund@1386: var html = 'Probe: ' + json.data.identifier + '
Keine Ă„nderungen
'; raimund@1386: } raimund@1386: else { raimund@1386: for (var i = 0; i < audit.length; i++) { raimund@1386: html += '' + i18n.getMsg('date') + ': ' +
raimund@1386: (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '';
raimund@1386: if (!Ext.isObject(audit[i].identifier)) {
raimund@1386: if (audit[i].type !== 'probe') {
raimund@1386: html += '
' + i18n.getMsg(audit[i].type) + ': ';
raimund@1386: html += audit[i].identifier;
raimund@1386: }
raimund@1386: }
raimund@1386: else {
raimund@1386: html += '
' + i18n.getMsg('messung') + ': ' +
raimund@1386: audit[i].identifier.messung + ' -> ' +
raimund@1386: i18n.getMsg(audit[i].type) + ': ' +
raimund@1386: audit[i].identifier.identifier;
raimund@1386:
raimund@1386: }
tom@1407: html += this.createHtmlChangedFields(audit[i]);
raimund@1386: }
raimund@1386: }
raimund@1386: return html;
raimund@1386: },
raimund@1386:
raimund@1386: createHtmlMessung: function(json) {
raimund@1386: var i18n = Lada.getApplication().bundle;
raimund@1386: var html = '
Messung: ' + json.data.identifier + '
Keine Ă„nderungen
'; raimund@1386: } raimund@1386: else { raimund@1386: for (var i = 0; i < audit.length; i++) { raimund@1386: html += '' + i18n.getMsg('date') + ': ' +
raimund@1386: (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '';
raimund@1386: if (audit[i].type !== 'messung') {
raimund@1386: html += '
' + i18n.getMsg(audit[i].type) + ': ';
raimund@1386: html += audit[i].identifier;
raimund@1386: }
tom@1407: html += this.createHtmlChangedFields(audit[i]);
raimund@1386: }
raimund@1386: }
raimund@1386: return html;
tom@1407: },
tom@1407:
tom@1407: createHtmlChangedFields: function(audit) {
tom@1407: var i18n = Lada.getApplication().bundle;
tom@1407: html = '
' + i18n.getMsg(audit.action)
tom@1407: + '