]> git.proxmox.com Git - proxmox-widget-toolkit.git/commit - form/DisplayEdit.js
form: add Proxmox.form.field.DisplayEdit
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 31 Mar 2020 16:14:36 +0000 (18:14 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 Apr 2020 13:33:18 +0000 (15:33 +0200)
commita46c2eb11ff10cc401c3e99ce531300dbb8e0d6a
tree34e76aa05e51873dafd69955bac6fb70e137c7bf
parent50032132415f97eab8e55eb831346507e4aba352
form: add Proxmox.form.field.DisplayEdit

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@proxmox.com>
Makefile
form/DisplayEdit.js [new file with mode: 0644]