diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/backup/schema.js b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/backup/schema.js index 1fa1aae5c9..9fe899944e 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/backup/schema.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/backup/schema.js @@ -13,21 +13,22 @@ * See the License for the specific language governing permissions and * * limitations under the License. * * ------------------------------------------------------------------------- */ -import { string, boolean, number, ObjectSchema } from 'yup' +import { ObjectSchema, boolean, number, string } from 'yup' +import { + BACKUP_INCREMENT_MODE_OPTIONS, + BACKUP_MODE_OPTIONS, + FS_FREEZE_OPTIONS, + INPUT_TYPES, + T, +} from 'client/constants' import { Field, Section, arrayToOptions, - getObjectSchemaFromFields, disableFields, + getObjectSchemaFromFields, } from 'client/utils' -import { - T, - INPUT_TYPES, - FS_FREEZE_OPTIONS, - BACKUP_MODE_OPTIONS, -} from 'client/constants' const BACKUP_VOLATILE_FIELD = { name: 'BACKUP_CONFIG.BACKUP_VOLATILE', @@ -80,12 +81,36 @@ const MODE_FIELD = { grid: { xs: 12, md: 6 }, } +const INCREMENT_MODE = { + name: 'BACKUP_CONFIG.INCREMENT_MODE', + label: T.IncrementMode, + type: INPUT_TYPES.SELECT, + dependOf: MODE_FIELD.name, + htmlType: (mode) => + mode !== BACKUP_MODE_OPTIONS[T.Increment] && INPUT_TYPES.HIDDEN, + values: arrayToOptions(Object.keys(BACKUP_INCREMENT_MODE_OPTIONS), { + addEmpty: true, + getText: (type) => type, + getValue: (type) => BACKUP_INCREMENT_MODE_OPTIONS[type], + }), + validation: string() + .trim() + .default(() => undefined), + grid: { xs: 12, md: 6 }, +} + /** @type {Section[]} Sections */ export const SECTIONS = (oneConfig, adminGroup) => [ { id: 'backup-configuration', fields: disableFields( - [BACKUP_VOLATILE_FIELD, FS_FREEZE_FIELD, KEEP_LAST_FIELD, MODE_FIELD], + [ + BACKUP_VOLATILE_FIELD, + FS_FREEZE_FIELD, + KEEP_LAST_FIELD, + MODE_FIELD, + INCREMENT_MODE, + ], 'BACKUP_CONFIG', oneConfig, adminGroup @@ -99,7 +124,10 @@ export const FIELDS = [ FS_FREEZE_FIELD, KEEP_LAST_FIELD, MODE_FIELD, + INCREMENT_MODE, ] +console.log({ FIELDS }) + /** @type {ObjectSchema} Graphics schema */ export const BACKUP_SCHEMA = getObjectSchemaFromFields(FIELDS) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup.js index 6789fee6fc..6334a002ac 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup.js @@ -39,7 +39,8 @@ define(function(require) { backup_volatile: "#backup-volatile", fs_freeze: "#fs-freeze", keep_last: "#keep-last", - mode: "#mode" + mode: "#mode", + increment_mode: "#increment-mode" } /* @@ -72,7 +73,17 @@ define(function(require) { return TemplateHTML(); } - function _onShow(context) { + function _onShow(dialog) { + dialog.off("change", idsElements.mode) + dialog.on('change', idsElements.mode, function() { + var value = $(this).val() + var parent = $(idsElements.increment_mode, dialog).parent().closest('div') + if(value === "INCREMENT" && parent.hasClass("hide")){ + parent.removeClass("hide") + }else{ + parent.addClass("hide") + } + }); } function _setup(context) { @@ -86,6 +97,7 @@ define(function(require) { var fsFreeze = _getValue(idsElements.fs_freeze, context); var keepLast = _getValue(idsElements.keep_last, context); var mode = _getValue(idsElements.mode, context); + var increment_mode = _getValue(idsElements.increment_mode, context); if (backupVolatile){ backupConfigJSON['BACKUP_VOLATILE'] = 'YES' @@ -103,6 +115,10 @@ define(function(require) { backupConfigJSON['MODE'] = mode } + if (increment_mode !== ''){ + backupConfigJSON['INCREMENT_MODE'] = increment_mode + } + return { 'BACKUP_CONFIG' : backupConfigJSON} } @@ -119,6 +135,7 @@ define(function(require) { function _fill(context, templateJSON) { if(templateJSON && templateJSON.BACKUP_CONFIG){ var configs = templateJSON.BACKUP_CONFIG + console.log("dsadas", configs) if(configs && configs.BACKUP_VOLATILE && configs.BACKUP_VOLATILE === 'YES'){ $(idsElements.backup_volatile, context).click(); } @@ -130,6 +147,13 @@ define(function(require) { } if(configs && configs.MODE){ _fillBootValue(idsElements.mode, context, configs.MODE); + if(configs.MODE==="INCREMENT"){ + var parent = $(idsElements.increment_mode, context).parent().closest('div') + parent.hasClass("hide") && parent.removeClass("hide") + if(configs && configs.INCREMENT_MODE){ + _fillBootValue(idsElements.increment_mode, context, configs.INCREMENT_MODE); + } + } } } } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup/html.hbs index d846786ff9..7d68c73668 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/backup/html.hbs @@ -44,7 +44,7 @@ - +