mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
[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:
parent
d0e29befa6
commit
ccdd1bcd57
@ -63,7 +63,8 @@ define(
|
||||
}
|
||||
|
||||
return dialogService.getUserInput(
|
||||
wizard.getFormModel()
|
||||
wizard.getFormModel(),
|
||||
wizard.getInitialFormValue()
|
||||
).then(persistResult, doNothing);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user