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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Apr 16 16:43:30 CEST 2020


On 4/16/20 2:31 PM, Thomas Lamprecht wrote:
> This allows to write our often used:
> 
>> {
>>     xtype: me.isCreate ? 'someEditableField' : 'displayfield',
>>     ...
>> }
> 
> In a more schematic way, as it can now be controlled by either our
> CBind mixin or ExtJS native data binding.
> 
> Use a Field container to add both, they editable and they display,
> variants of a form field. As default use "textfield" for the editable
> and "displayfield" xtype for the read only one.
> 
> Pass all but the editConfig and editable members of our initial
> config to the display field, allow further to configure the editable
> field with an editConfig object, which overwrites the config
> properties inherited from the displayConfig/parent config.
> 
> This gives full control while not enforcing to specify anything extra
> for most default cases.
> 
> Enforce initial state of the fields even if the databinding would
> handle it to avoid glitches after first render for simple boolean expression
> cases.
> 
>> {
>>     xtype: 'pmxDisplayEditField',
>>     cbind: {
>>         editable: '{isCreate}',
>>     },
>>     name: 'tokenid',
>>     fieldLabel: gettext('Token ID'),
>>     value: me.tokenid,
>>     allowBlank: false,
>> }
> 
> Here, cbind could also be a bind or a native boolean expression.
> 
> For something else than a texfield one would use the editConfig, e.g.:
>> {
>>     ....
>>     editConfig: {
>>         xtype: 'pveUserSelector',
>>         allowBlank: false,
>>     },
>> },
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> 
> changes v1 -> v2:
> * fix applying data binding when the instances has it's own bind config already
> * bind value to ensure it's synced between both fields
> * drop array use from "alias" definition, but keep it as ExtJS uses it
>   primarily and we too for >3/4 of our definitions
> 
>  Makefile            |  1 +
>  form/DisplayEdit.js | 77 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 78 insertions(+)
>  create mode 100644 form/DisplayEdit.js
> 

Applied, with Dominiks suggested change (thanks!).





More information about the pve-devel mailing list