[Forms] Adjust Create form formats

Adjust formats used in Create forms to match those used
by the mct-form directive. Integration of forms bundle,
WTD-593.
This commit is contained in:
Victor Woeltjen 2014-12-03 12:52:51 -08:00
parent d0e29befa6
commit ccdd1bcd57
3 changed files with 37 additions and 15 deletions

View File

@ -63,7 +63,8 @@ define(
}
return dialogService.getUserInput(
wizard.getFormModel()
wizard.getFormModel(),
wizard.getInitialFormValue()
).then(persistResult, doNothing);
}

View File

@ -33,32 +33,53 @@ define(
* show in the create dialog
*/
getFormModel: function () {
var parentRow = Object.create(parent),
sections = [];
var sections = [];
sections.push({
name: "Properties",
rows: properties.map(function (property) {
rows: properties.map(function (property, index) {
// Property definition is same as form row definition
var row = Object.create(property.getDefinition());
// But pull an initial value from the model
row.value = property.getValue(model);
// Use index as the key into the formValue;
// this correlates to the indexing provided by
// getInitialFormValue
row.key = index;
return row;
})
});
// Ensure there is always a "save in" section
parentRow.name = "Save In";
parentRow.cssclass = "selector-list";
parentRow.control = "_locator";
parentRow.key = "createParent";
sections.push({ label: 'Location', rows: [parentRow]});
sections.push({ name: 'Location', rows: [{
name: "Save In",
control: "locator",
key: "createParent"
}]});
return {
sections: sections,
name: "Create a New " + type.getName()
};
},
/**
* Get the initial value for the form being described.
* This will include the values for all properties described
* in the structure.
*
* @returns {object} the initial value of the form
*/
getInitialFormValue: function () {
// Start with initial values for properties
var formValue = properties.map(function (property) {
return property.getValue(model);
});
// Include the createParent
formValue.createParent = parent;
return formValue;
},
/**
* Based on a populated form, get the domain object which
* should be used as a parent for the newly-created object.

View File

@ -74,16 +74,16 @@
{
"properties": [
{
"control": "_textfield",
"label": "Title",
"control": "textfield",
"name": "Title",
"key": "name",
"property": "name",
"pattern": "\\S+",
"required": true
},
{
"control": "_checkbox",
"label": "Display title by default",
"control": "checkbox",
"name": "Display title by default",
"key": "displayTitle",
"property": [ "display", "title" ]
}