Skip to content

Commit 599dd1a

Browse files
committed
multiEdit: extend field hide/show functionality
-Support passing isHidden option as closure, for conditional hide/show based on context -Adds new option format for isHidden option: return false == show field and all columns (default) return true == hide only header and form column return 2 == hide header and form, as well as returned item column -- these item columns will be skipped over entirely, not just hidden
1 parent ac04a9f commit 599dd1a

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎ui/scripts/network.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,12 @@
33683368
requireValidation: true,
33693369
buttonLabel: 'label.configure',
33703370
action: cloudStack.uiCustom.autoscaler(cloudStack.autoscaler)
3371+
},
3372+
isHidden: function(args) {
3373+
// return 2 == hide header and form, as well as returned item column
3374+
// return 2;
3375+
3376+
return false;
33713377
}
33723378
},
33733379

‎ui/scripts/ui/widgets/multiEdit.js‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
return true;
8686
}
8787

88+
var isHidden = $multi.find('th.' + fieldName).hasClass('always-hide');
89+
90+
if (isHidden) {
91+
return true;
92+
}
93+
8894
var $td = $('<td>').addClass(fieldName).appendTo($tr);
8995
var $input, val;
9096
var $addButton = $multi.find('form .button.add-vm:not(.custom-action)').clone();
@@ -264,7 +270,7 @@
264270

265271
// Align width to main header
266272
_medit.refreshItemWidths($multi);
267-
273+
268274
if (data._hideFields &&
269275
$.inArray(fieldName, data._hideFields) > -1) {
270276
$td.addClass('disabled');
@@ -891,7 +897,16 @@
891897
$td.attr('rel', fieldName);
892898
$td.appendTo($inputForm);
893899

894-
if (field.isHidden) {
900+
var isHidden = $.isFunction(field.isHidden) ?
901+
field.isHidden({ context: context }) : field.isHidden;
902+
903+
if (isHidden) {
904+
// return true == hide only header and form column
905+
// return 2 == hide header and form, as well as returned item column
906+
if (isHidden === 2) {
907+
$th.addClass('always-hide');
908+
}
909+
895910
$th.hide();
896911
$td.hide();
897912
}

0 commit comments

Comments
 (0)