Commit Graph

43 Commits

Author SHA1 Message Date
Dominik Csapak
9a3c1cb408 add pmxRoleSelector
copied+refactored from pve-manager
for use with other projects

also show privs now in the combobox

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-19 21:19:26 +02:00
Thomas Lamprecht
a307714b53 displayedit: fixup to correct version
it seems I made an error and applied an older version..
Apply the correct one[0] with Dominiks comment addressed[1].

[0]: https://pve.proxmox.com/pipermail/pve-devel/2020-April/043037.html
[1]: https://pve.proxmox.com/pipermail/pve-devel/2020-April/043043.html

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-19 21:14:52 +02:00
Dominik Csapak
0391dee1a2 add Realm model and RealmComboBox
copied from pve-manager, with adaptions for modern js
(let, parameter destructuring,...)

and dropped the not needed 'needOTP' method

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-05-18 17:03:32 +02:00
Thomas Lamprecht
dcc46d6d81 drop unused comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-05-05 14:50:51 +02:00
Dominik Csapak
731df80da0 DateTimeField: implement set{Max, Min}Value
this sets the max/min value for the underlying date and time fields,
and allowing to only change the value respecting both current date
and time fields
e.g.
if the new maxValue is 2020-10-10 12:00
and the current value is 2020-10-09 15:00
do not allow to set the date to 2020-10-10
and vice versa (if the new limit is on the same day, limit the time range)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-24 17:02:31 +02:00
Thomas Lamprecht
a46c2eb11f 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>
2020-04-16 15:33:18 +02:00
Dominik Csapak
5003213241 open picker for all comboboxes on focus, even if they are editable
when a combobox was editable, a click inside did not open the picker,
but it would if the combobox was not editable.

Since this is
 1. Inconsistent
 2. Inconvenient (the user has to specifically press the arrow)

we already had this implemented for our ComboGrid, but not for
regular comboboxes

This patch moves the code for this to an override for ComboBox, which
our ComboGrid then inherits (so we do not need it there anymore)

while at it, do some non-significant code-cleanup
 * whitespace fixes
 * don't shadow 'me' in the focus callback
 * fix typo in comment

Originally this was implemented in pve-manager, commit
851c032d69ad5ae23725dd1add9e4084ebc12650

https://git.proxmox.com/?p=pve-manager.git;a=commitdiff;h=851c032d69ad5ae23725dd1add9e4084ebc12650

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Originally-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-04-16 14:39:38 +02:00
Thomas Lamprecht
4645c3d413 form: add Proxmox.form.field.ExpireDate
Behaves like a 'datefield' but treats the 0/empty value as "never",
and sets all defaults for behaving like one would expect from a date
expire field.

This allows to replaces hacks (e.g. [0]) from our various expire date
fields, mostly in PVE/PMG user accounts, and also for the soon to be
applied API token gui.

[0]: https://git.proxmox.com/?p=pve-manager.git;a=blob;f=www/manager6/dc/UserEdit.js;h=40c4044fd9364c9bcb8787507068378ed9936f67;hb=806edfe19f049f07db2628c68e4e5702bbedd9d7#l159

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-31 18:13:20 +02:00
Stefan Reiter
6f5e0ea655 ComboGrid: fix validation for !allowBlank disabled fields
Used in "Add USB to VM" dialog for example.

This was broken before 15206214d9 "ComboGrid: fix on-load validation for blank
values" (only the one you enabled first was validated, the other always showed
as valid), and afterwards too, but in a different way (both are now immediately
marked invalid until you select and unselect them) - which is how I noticed.

With this the validation now works correctly.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-02-05 08:40:45 +01:00
Stefan Reiter
15206214d9 ComboGrid: fix on-load validation for blank values
Commit f32aa3df74 fixed marking multi-select fields with where the store
did not contain a valid value after loading.

However, it introduced a bug for single-select fields where the value
(before the store-load) was explicitly set to be empty (when that should
be invalid because of allowBlank === false).

Fix the logic to correctly detect all scenarios (with def being the
value selected before the store loaded, i.e. undefined or an empty
array):

  !allowBlank &&
    ( def is an array but empty || def is not an array and falsy )

Also use correct error message (localized by ExtJS itself).

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-01-30 16:14:03 +01:00
Dominik Csapak
f32aa3df74 ComboGrid: correctly set/mark multiSelect fields
in fields with 'multiSelect: true', we get an array as value instead
of a string, but a check of !![] results in true (since an array
is an object), so we have to explicitely check for arraylength
in 'setValue' (for correctly showing the trigger) and in the
load handler (to not set an empty field wrongfully to invalid)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-11-25 18:42:04 +01:00
Dominik Csapak
013cbd6425 fix #2421: ComboGrid: correctly validate multiSelect variant
on multiSelect we have to check the values that is in the values
array, but we get the 'displaystring' in the validator so we
have to get the 'real' value (aka the underlying array of values)
before checking if they are in the store

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-11-25 18:18:43 +01:00
Tim Marx
35eec238b2 fix comboBox validation when forceSelection is true
Prevent the comboBox from displaying a validation error although
forceSelection is true. If you change a valid selection by removing
characters manually and click somewhere else, the comboBox restores
the selection with the previous value. The validation logic then
checked the restored value, but couldn't find it in the store,
because the store is still filtered with the erroneous query.

We now clear the local filter before the actual check to prevent
this.

[Thomas]:
This was fixed in the 6.2 based GPL release of ExtJS, and can be seen
as backport.

Signed-off-by: Tim Marx <t.marx@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-25 17:43:23 +02:00
Thomas Lamprecht
c59a0a3e43 combogrid: fix validation if valueField is different than displayField
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-08-16 12:44:33 +02:00
Dominik Csapak
94953ba8ea ComboGrid: add trigger to delete from ComboGrid
when we have a combogrid that may be empty, we now show a
little 'x' where the user can delete the content

this is not shown when the field is not allowed to be empty

we add a new css for this because triggers need a background image
with a very specific layout:

110x22px which is 5 icons in one image for the various states
(normal, hover, active, focused, focused hover)

the icon is taken from the theme-crisp
form/tag-field-item-close.png but rearranged to fit the size

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-08-13 15:37:26 +02:00
Thomas Lamprecht
1ccb53ecdb combogrid: add handling for historic set values currently not available
We can often run into situations where a value set in the past is not
valid anymore. An example could be a deleted network bridge, e.g., we
set the vNIC of a VM to 'vmbr1' but then we decide to obsolete that
and delete that one, one would now expect that the field gets marked
as invalid when editing the VM's vNIC, so add that behavior.

As sometimes this can be valid and wanted behavior (e.g., usb
passthrough, which is hot-pluggable), also add a switch do restore
the old behavior.

Note that the empty value is not handled by this change, we let the
existing "allowBlank" config switch handle that one.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-18 15:55:38 +02:00
Thomas Lamprecht
f59a7b2350 combogrid: always set the initial value, even if not found
as else one lies to the user and only creates strange behavior,
one should see the values even if not there anymore, if this is a
invalid state is left for a later patch.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-07-17 16:17:59 +02:00
Oguz Bektas
c8b66b2bfd KVComboBox: add setComboItems function
this allows to change the comboItems of a KVComboBox on the run

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-07-11 15:00:14 +02:00
Dominik Csapak
8311c0b1af node network: refactor bond mode array generation
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-07-10 12:26:54 +02:00
Thomas Lamprecht
1dd799589b network selector: allow to select IP too
not only CIDR.. maybe it could make sense to add a small child class
which  overwrites just the displayField and valueField to address

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-27 21:51:02 +02:00
Thomas Lamprecht
227159eca2 combogrid: add deleteEmpty and skipEmptyText
Slightly adapted from the proxmox textfield version of this

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-27 14:21:46 +02:00
Thomas Lamprecht
b69c301a94 textfield: validate after allowBlank 2019-06-27 14:21:17 +02:00
Thomas Lamprecht
a8131b5bce combo grid: add setAllowBlank to help bindings
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-26 16:05:56 +02:00
Thomas Lamprecht
e6bf8a81ac followup: network selector: refactor cidr6 merge logic
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-12 13:07:32 +02:00
Thomas Lamprecht
ce8c5365c2 followup: network selector: reorder columns and adapt widths
and use format_boolean to render the active column
also hide the type column by default, it often is not too important,
and can be derived from the interface name, e.g., vmbrX -> bridge,
bondX -> bond, etc.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-12 13:03:25 +02:00
Tim Marx
607c37efd1 add network selector widget
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-12 11:17:44 +02:00
Thomas Lamprecht
ec0798689f form: proxmox textfield: support binding 'allowBlank'
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-11-28 12:17:57 +01:00
Dominik Csapak
39d9914990 ComboGrid: open picker also when focusing an editable field
port commit
851c032d69ad5ae23725dd1add9e4084ebc12650
from pve-manager

commit message:

    ComboBoxes provided by UI frameworks normally show their selection
    possibilities once focused, ExtJS does this too but not on editable
    (and thus filterable) input fields. Add a logic which allows this too
    and streamlines the behavior of ComboGrid/Box like components.

    To avoid a glitch, where clicking the "picker trigger" (the down
    arrow which normally toggles the selection picker) would first focus
    the element - thus expanding it - and only then causing a toggle
    which collapses it again, we overwrite the 'Ext.form.trigger.Trigger'
    onMouseDown so that we can skip a expansion on this event.

    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-11 14:48:13 +01:00
Dominik Csapak
3ab80554c6 ComboGrid: improve setting 'editable' default value
port commit
bff876ecb5f3388b7d65c491680b9a40574e4744
from pve-manager

commit message:

    This allows child classes to use another default, the initialConfig
    didn't allowed that.
    This is also the ExtJS like way to set defaults.

    Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-11 14:48:13 +01:00
Dominik Csapak
fa6dc53bcc add missing BondModeSelector to widget toolkit
this is needed for the node/NetworkEdit.js

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-11-14 11:35:48 +01:00
Dietmar Maurer
f6f0066aff LanguageSelector.js - add language selector 2017-10-04 11:16:22 +02:00
Dietmar Maurer
00ecc6db47 DateTimeField.js - relay change events 2017-09-21 09:36:36 +02:00
Dietmar Maurer
2e7bd1dcba form/DateTimeField.js - new widget to select Date with Time 2017-09-20 12:42:42 +02:00
Dietmar Maurer
a0ba293c12 add RRDTypeSelector class
Mostly copied from pve-manager.

- added gettext translations
- changed class and state name
2017-08-29 06:25:25 +02:00
Dietmar Maurer
f0372135cd try to use real config properties
to generate getter/setter functions (required for bind)
2017-03-29 18:47:19 +02:00
Dietmar Maurer
a4eeb5939d KVComboBox.js: use correct namespace 2017-03-27 13:02:18 +02:00
Dietmar Maurer
066babdc65 form/ComboGrid.js: imported from pve-manager 2017-03-27 11:04:46 +02:00
Dietmar Maurer
211267b8cc KVComboBox: imported from pve-manager 2017-02-25 10:20:12 +01:00
Dietmar Maurer
b2d1d61fec rename pveintegerfield to proxmoxintegerfield 2017-02-24 09:15:20 +01:00
Dietmar Maurer
2cebd14b9d rename integerfield to pveintegerfiled, implement deleteEmpty 2017-02-24 08:59:06 +01:00
Dietmar Maurer
d44fdf59f9 add integer field 2017-02-24 08:32:30 +01:00
Dietmar Maurer
fccec7c6c2 add Checkbox.js
Copied from pve-manager
2017-01-31 17:17:12 +01:00
Dietmar Maurer
a0ec162067 add TextField.js
Copied from pve-manager
2017-01-31 17:13:26 +01:00