9a4506b1440f696db45d9cf1cf444123622c8461
[Pman.BAdmin] / Pman.Dialog.BAdminStaffGroups.bjs
1 {
2  "name" : "Pman.Dialog.BAdminStaffGroups",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/Pman.BAdmin/Pman.Dialog.BAdminStaffGroups.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "4910043d0b2c8c864a0e8672716fee94" : "Is a Member",
10   "566a352f95c879ff26e50bad767a28dc" : "Group Membership",
11   "6b79852e4370cae80ee551e0671616bb" : "Manage Users Group",
12   "28974c2c793e780427dfb571b26443e6" : "Group Name",
13   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
14   "c9cc8cce247e49bae79f15173ce97354" : "Save"
15  },
16  "items" : [
17   {
18    "listeners" : {
19     "show" : "function (_self)\n{\n    this.setTitle(\"Manage Membership for \" + _this.data.name);\n}",
20     "render" : "function (_self)\n{\n    _this.dialog = this;\n}"
21    },
22    "String cls" : "add-user-dialog",
23    "string fit_content" : true,
24    "xtype" : "Modal",
25    "$ xns" : "Roo.bootstrap",
26    "String title" : "Manage Users Group",
27    "items" : [
28     {
29      "listeners" : {
30       "render" : "function (_self)\n{\n    _this.layout = _self;\n}"
31      },
32      "xtype" : "Border",
33      "$ xns" : "Roo.bootstrap.layout",
34      "items" : [
35       {
36        "alwaysShowTabs" : true,
37        "String tabPosition" : "top",
38        "xtype" : "Region",
39        "$ xns" : "Roo.bootstrap.layout",
40        "* prop" : "center"
41       },
42       {
43        "listeners" : {
44         "activate" : "function (_self)\n{\n    if(_this.option_grid){\n        _this.option_grid.store.load({});\n    }\n    \n}",
45         "render" : "function (_self)\n{\n    _this.option_panel = this;\n    \n    \n}"
46        },
47        "fitToFrame" : true,
48        "xtype" : "Grid",
49        "String region" : "center",
50        "$ xns" : "Roo.bootstrap.panel",
51        "fitContainer" : true,
52        "String title" : "Group Membership",
53        "Boolean background" : false,
54        "items" : [
55         {
56          "listeners" : {
57           "cellclick" : "function (_self, el, rowIndex, columnIndex, e)\n{\n    var di = _this.option_grid.colModel.getDataIndex(columnIndex);\n    \n    /*\n    if (di != 'is_in_group') {\n        return;\n    }\n     */\n    var rec = _this.option_grid.store.getAt(rowIndex);\n    \n    if(rec.data.name == 'Administrators' && _this.data.id == Pman.Login.authUser.id){\n        Roo.bootstrap.MessageBox.alert('Error', 'You can not remove yourself from Administrators group');\n        return;\n    }\n    \n    rec.set('is_in_group', rec.data.is_in_group * 1 == 1 ? 0 : 1);\n    rec.commit();\n\n}",
58           "render" : "function (_self)\n{\n    _this.option_grid = this;\n    \n    this.store.load({})\n}"
59          },
60          "Boolean footerShow" : false,
61          "String cls" : "table-fixed",
62          "xtype" : "Table",
63          "$ xns" : "Roo.bootstrap",
64          "cellSelection" : true,
65          "Boolean loadMask" : true,
66          "* prop" : "grid",
67          "boolean condensed" : true,
68          "rowSelection" : false,
69          "items" : [
70           {
71            "Boolean singleSelect" : true,
72            "xtype" : "RowSelectionModel",
73            "$ xns" : "Roo.bootstrap.Table",
74            "* prop" : "sm"
75           },
76           {
77            "listeners" : {
78             "update" : "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n    \n    var params = {\n        user_ids : _this.data.id,\n        _action : (record.data.is_in_group * 1 == 0) ? 'sub' : 'add',\n        group_id : record.data.id\n    };\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Core_group',\n        method : 'POST',\n        params : params,\n        success : function() { \n            //_this.option_grid.ds.load({});\n        }\n  });\n}",
79             "beforeload" : "function (_self, options)\n{ \n    options.params = options.params || {};\n    \n    if(_this.data.id * 1 < 1){\n        _this.option_grid.el.mask('Please save the member first');\n        this.removeAll();\n        return false;\n    }\n    options.params.limit = 200;\n    options.params._is_in_group = _this.data.id;\n\n}"
80            },
81            "$ Object sortInfo" : "{ direction : 'ASC', field: 'id' }",
82            "xtype" : "Store",
83            "boolean remoteSort" : true,
84            "$ xns" : "Roo.data",
85            "* prop" : "store",
86            "items" : [
87             {
88              "$ url" : "baseURL + '/Roo/core_group'",
89              "xtype" : "HttpProxy",
90              "$ xns" : "Roo.data",
91              "String method" : "GET",
92              "* prop" : "proxy"
93             },
94             {
95              "$ Array fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'display_name',\n        'type': 'string'\n    },\n    {\n        'name': 'is_in_group',\n        'type': 'int'\n    }\n]",
96              "xtype" : "JsonReader",
97              "String root" : "data",
98              "$ xns" : "Roo.data",
99              "String id" : "id",
100              "* prop" : "reader"
101             }
102            ]
103           },
104           {
105            "String header" : "Is a Member",
106            "String cursor" : "pointer",
107            "String dataIndex" : "is_in_group",
108            "xtype" : "ColumnModel",
109            "Number xs" : 3,
110            "String align" : "center",
111            "$ xns" : "Roo.grid",
112            "$ renderer" : "function(v) {  \n\n    var state = v > 0 ?  'check-' : '';\n    var cls = v > 0 ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n         \n }",
113            "Boolean sortable" : false,
114            "* prop" : "cm[]"
115           },
116           {
117            "String header" : "Group Name",
118            "cursor" : "pointer",
119            "String dataIndex" : "display_name",
120            "xtype" : "ColumnModel",
121            "Number xs" : 9,
122            "$ xns" : "Roo.grid",
123            "$ renderer" : "function(v,x,r) \n{\n    var vv = v.length ? v : r.data.name;\n    \n    return String.format('{0}', vv);\n}",
124            "Boolean sortable" : true,
125            "* prop" : "cm[]"
126           }
127          ]
128         }
129        ]
130       }
131      ]
132     },
133     {
134      "listeners" : {
135       "click" : "function (_self, e)\n{\n    _this.dialog.hide(); \n}"
136      },
137      "xtype" : "Button",
138      "$ xns" : "Roo.bootstrap",
139      "String html" : "Cancel",
140      "* prop" : "buttons[]"
141     },
142     {
143      "listeners" : {
144       "click" : "function (_self, e)\n{\n    if(!_this.form.isValid()){\n        //Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');\n        return;\n    }\n    \n    var myID = _this.form.findField('id').getValue() * 1;\n    var myName = _this.form.findField('name').getValue();\n\n    if (_this.form.findField('company_id') && !_this.form.findField('company_id').getValue()) {\n        Roo.bootstrap.MessageBox.alert(\"Error\", \"Select a Company\");\n        return;\n    }\n        \n       // validate password match (only needed if we are not using generated one..\n    if (_this.form.findField('passwd1') \n            && _this.form.findField('passwd1').getValue().length > 0 \n            && _this.form.findField('passwd1').inputEl().dom.type == \"password\") {\n            \n        var p1 = _this.form.findField('passwd1').getValue();\n        var p2 = _this.form.findField('passwd2').getValue();\n            \n            \n        if (Pman.Login.authUser.id < 0 && !p1.length) {\n            Roo.bootstrap.MessageBox.alert(\"Error\", \"You must create a password for the admin account\");\n            return;\n        }\n            \n            \n        if (p1.length || p2.length) {\n            if (p1 != p2) {\n                Roo.bootstrap.MessageBox.alert(\"Error\", \"Passwords do not match\");\n                return;\n            }\n        }\n            \n        \n    }\n    \n    // get the list of record with tick\n    \n    _this.form.doAction(\"submit\");\n    \n    return;\n\n}"
145      },
146      "String weight" : "primary",
147      "xtype" : "Button",
148      "$ xns" : "Roo.bootstrap",
149      "String html" : "Save",
150      "* prop" : "buttons[]"
151     }
152    ]
153   }
154  ]
155 }