[Lada-commits] [PATCH 1 of 2] Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js

Wald Commits scm-commit at wald.intevation.org
Wed Apr 8 17:04:20 CEST 2015


# HG changeset patch
# User Dustin Demuth <dustin at intevation.de>
# Date 1428499705 -7200
# Node ID 605bc34b45a057b9c8b90cf8087a5136186c9cfc
# Parent  a8da0a5bacf96a00a8efb6d8038f0eb3b4924d11
Disable the Fertig-Flag Checkbox in a Messung when the User is not the owner. Do not enable Form-Children when readonly is set to true. Parse login-response in app.js

diff -r a8da0a5bacf9 -r 605bc34b45a0 app.js
--- a/app.js	Wed Apr 08 12:45:37 2015 +0200
+++ b/app.js	Wed Apr 08 15:28:25 2015 +0200
@@ -19,6 +19,10 @@
     // references!
     name: 'Lada',
 
+    username: '',
+    userroles: '',
+    logintime: '',
+
     // Setting up translations. This is done using a ext-plgin which can be
     // found on https://github.com/elmasse/Ext.i18n.Bundle
     requires: [
@@ -98,13 +102,18 @@
                 'Es konnte keine erfolgreiche Verbindung zum lada server aufgebaut werden.');
     },
 
-    onLoginSuccess: function() {
+    onLoginSuccess: function(response) {
         /* Strip out the openid query params to look nicers. */
         window.history.pushState(this.name, this.name, window.location.pathname);
 
         Ext.create('Lada.view.Viewport');
 
-        /* Todo maybe parse username and such from login service response */
+        /* Parse Username and Timestamp */
+        var json = Ext.decode(response.responseText);
+        this.username = json.data.username;
+        this.userroles = json.data.roles;
+        this.logintime = json.data.servertime;
+
         Ext.create('Lada.store.Datenbasis', {
             storeId: 'datenbasis'
         });
diff -r a8da0a5bacf9 -r 605bc34b45a0 app/controller/form/Messung.js
--- a/app/controller/form/Messung.js	Wed Apr 08 12:45:37 2015 +0200
+++ b/app/controller/form/Messung.js	Wed Apr 08 15:28:25 2015 +0200
@@ -104,7 +104,10 @@
         else {
             form.owner.down('button[action=save]').setDisabled(true);
             form.owner.down('button[action=discard]').setDisabled(true);
-            form.owner.up('window').enableChildren();
+            //Only enable children if the form was not readOnly
+            if (!form.getRecord().get('readonly')) {
+                form.owner.up('window').enableChildren();
+            }
         }
     }
 });
diff -r a8da0a5bacf9 -r 605bc34b45a0 app/view/form/Messung.js
--- a/app/view/form/Messung.js	Wed Apr 08 12:45:37 2015 +0200
+++ b/app/view/form/Messung.js	Wed Apr 08 15:28:25 2015 +0200
@@ -172,5 +172,9 @@
         this.down('datetime[name=messzeitpunkt]').setReadOnly(value);
         this.down('numberfield[name=messdauer]').setReadOnly(value);
         this.down('chkbox[name=geplant]').setReadOnly(value);
+        if (!this.getForm().getRecord().get('owner')) {
+        //Only set this Field to Readonly when the User is NOT the Owner of the Record.
+            this.down('chkbox[name=fertig]').setReadOnly(value);
+        }
     }
 });


More information about the Lada-commits mailing list