[pve-devel] [PATCH proxmox-widget-toolkit] form: add Proxmox.form.field.DisplayEdit

Dominik Csapak d.csapak at proxmox.com
Thu Apr 2 10:15:40 CEST 2020


i forgot the nit inline, now really ^^

[snip]
>>
>>   Makefile            |  1 +
>>   form/DisplayEdit.js | 71 +++++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 72 insertions(+)
>>   create mode 100644 form/DisplayEdit.js
>>
>> diff --git a/Makefile b/Makefile
>> index 703b570..a729b95 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -15,6 +15,7 @@ JSSRC=                    \
>>       data/ObjectStore.js        \
>>       data/RRDStore.js        \
>>       data/TimezoneStore.js        \
>> +    form/DisplayEdit.js        \
>>       form/ExpireDate.js        \
>>       form/IntegerField.js        \
>>       form/TextField.js        \
>> diff --git a/form/DisplayEdit.js b/form/DisplayEdit.js
>> new file mode 100644
>> index 0000000..9b3f1c0
>> --- /dev/null
>> +++ b/form/DisplayEdit.js
>> @@ -0,0 +1,71 @@
>> +Ext.define('Proxmox.form.field.DisplayEdit', {
>> +    extend: 'Ext.form.FieldContainer',
>> +    alias: ['widget.pmxDisplayEditField'],

i would like to use
xtype: 'pmxDisplayEditField',
here

>> +    mixins: ['Proxmox.Mixin.CBind' ],
>> +
>> +    viewModel: {
>> +    data: {
>> +        editable: false,
>> +    },
>> +    },
>> +
>> +    displayType: 'displayfield',
>> +
>> +    editConfig: {},
>> +    editable: false,
>> +    setEditable: function(editable) {
>> +    let me = this;
>> +    let vm = me.getViewModel();
>> +
>> +    me.editable = editable;
>> +    vm.set('editable', editable);
>> +    },
>> +
>> +    layout: 'hbox',
>> +    defaults: {
>> +    hideLabel: true
>> +    },
>> +
>> +    initComponent: function() {
>> +    let me = this;
>> +
>> +    let displayConfig = {
>> +        xtype: me.displayType,
>> +        bind: {
>> +        hidden: '{editable}',
>> +        disabled: '{editable}',
>> +        },
>> +    };
>> +    Ext.applyIf(displayConfig, me.initialConfig);
>> +    delete displayConfig.editConfig;
>> +    delete displayConfig.editable;
>> +
>> +    let editConfig = me.editConfig;
>> +    Ext.applyIf(editConfig, {
>> +        xtype: 'textfield',
>> +        bind: {
>> +        hidden: '{!editable}',
>> +        disabled: '{!editable}',
>> +        },
>> +    });
>> +    Ext.applyIf(editConfig, displayConfig);
>> +
>> +    // avoid glitch, start off correct even before viewmodel fixes it
>> +    editConfig.disabled = editConfig.hidden = !me.editable;
>> +    displayConfig.disabled = displayConfig.hidden = !!me.editable;
>> +
>> +    editConfig.name = displayConfig.name = me.name;
>> +
>> +    Ext.apply(me, {
>> +        items: [
>> +        displayConfig,
>> +        editConfig,
>> +        ],
>> +    });
>> +
>> +    me.callParent();
>> +
>> +    me.getViewModel().set('editable', me.editable);
>> +    },
>> +
>> +});
>>
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 




More information about the pve-devel mailing list