diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-07-28 17:14:51 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-07-28 17:19:51 +0200 |
commit | 5dd2b5c6dcd51438f71da05af399999ba512e0ca (patch) | |
tree | e9f10561cda118a143211dabc6a524c89e9fd446 /ogcp/static/js/ogcp.js | |
parent | 4b4edf4aeeed5d6177c1d78812a497e7ad1a206d (diff) |
Add full scheme partitioning support
The initial "Partition & Format" (aka setup) form only allows to modify
one partition at a time. This commit updates it to allow to modify the
whole disk partition schema in one go, without pop-ups and transitions.
This is a remake of the previous form using FieldList de WTForms and
javascript to duplicate / remove FieldList adapted to the attributes
available in WTForms.
Diffstat (limited to 'ogcp/static/js/ogcp.js')
-rw-r--r-- | ogcp/static/js/ogcp.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index f9c8e56..00ab61c 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -53,3 +53,25 @@ function updateScopes(scopes) { function unfoldAll() { $('#scopes .collapse').collapse('show'); } + +function AddPartition(evt) { + const target = $($(evt).data("target")); + const oldrow = target.find("[data-toggle=fieldset-entry]:last"); + const row = oldrow.clone(true, true); + const elem_id = row.find(":input")[0].id; + const elem_prefix = elem_id.replace(/(.*)-(\d{1,4})/m, '$1')// max 4 digits for ids in list + const elem_num = parseInt(elem_id.replace(/(.*)-(\d{1,4})/m, '$2')) + 1; + // Increment WTForms unique identifiers + row.children(':input').each(function() { + const id = $(this).attr('id').replace(elem_prefix+'-' + (elem_num - 1), + elem_prefix+'-' + (elem_num)); + $(this).attr('name', id).attr('id', id).val('').removeAttr("checked"); + }); + row.show(); + oldrow.after(row); +} + +function RemovePartition(evt) { + const target = $(evt).parent().parent(); + target.remove(); +} |