]> git.proxmox.com Git - proxmox-backup.git/blame - www/form/PermissionPathSelector.js
ui: permission path selector: cbind typeAhead to editable
[proxmox-backup.git] / www / form / PermissionPathSelector.js
CommitLineData
d757021f
TL
1Ext.define('PBS.data.PermissionPathsStore', {
2 extend: 'Ext.data.Store',
3 alias: 'store.pbsPermissionPaths',
4 fields: ['value'],
5 autoLoad: false,
6 data: [
7 { 'value': '/' },
8 { 'value': '/access' },
9 { 'value': '/access/acl' },
10 { 'value': '/access/users' },
11 { 'value': '/datastore' },
12 { 'value': '/remote' },
13 { 'value': '/system' },
14 { 'value': '/system/disks' },
15 { 'value': '/system/log' },
16 { 'value': '/system/network' },
17 { 'value': '/system/network/dns' },
18 { 'value': '/system/network/interfaces' },
19 { 'value': '/system/services' },
20 { 'value': '/system/status' },
21 { 'value': '/system/tasks' },
22 { 'value': '/system/time' },
23 ],
24
25 constructor: function(config) {
26 let me = this;
27
28 config = config || {};
29 me.callParent([config]);
30
31 // TODO: this is but a HACK until we have some sort of resource
32 // storage like PVE
33 let datastores = Ext.data.StoreManager.lookup('pbs-datastore-list');
34
35 if (datastores) {
36 let donePaths = {};
37 me.suspendEvents();
38 datastores.each(function(record) {
39 let path = `/datastore/${record.data.store}`;
40 if (path !== undefined && !donePaths[path]) {
41 me.add({ value: path });
42 donePaths[path] = 1;
43 }
44 });
45 me.resumeEvents();
46
47 me.fireEvent('refresh', me);
48 me.fireEvent('datachanged', me);
49 }
50
51 me.sort({
52 property: 'value',
53 direction: 'ASC',
54 });
55 },
56});
57
58Ext.define('PBS.form.PermissionPathSelector', {
59 extend: 'Ext.form.field.ComboBox',
60 xtype: 'pbsPermissionPathSelector',
fdb4416b 61 mixins: ['Proxmox.Mixin.CBind'],
d757021f
TL
62
63 valueField: 'value',
64 displayField: 'value',
fdb4416b
TL
65 cbind: {
66 typeAhead: '{editable}',
67 },
d757021f
TL
68 anyMatch: true,
69 queryMode: 'local',
70
71 store: {
72 type: 'pbsPermissionPaths',
73 },
74 regexText: gettext('Invalid permission path.'),
75 regex: /\/((access|datastore|remote|system)\/.*)?/,
76});