mirror of
https://github.com/nasa/openmct.git
synced 2025-05-06 10:38:23 +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(
|
return dialogService.getUserInput(
|
||||||
wizard.getFormModel()
|
wizard.getFormModel(),
|
||||||
|
wizard.getInitialFormValue()
|
||||||
).then(persistResult, doNothing);
|
).then(persistResult, doNothing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,32 +33,53 @@ define(
|
|||||||
* show in the create dialog
|
* show in the create dialog
|
||||||
*/
|
*/
|
||||||
getFormModel: function () {
|
getFormModel: function () {
|
||||||
var parentRow = Object.create(parent),
|
var sections = [];
|
||||||
sections = [];
|
|
||||||
|
|
||||||
sections.push({
|
sections.push({
|
||||||
name: "Properties",
|
name: "Properties",
|
||||||
rows: properties.map(function (property) {
|
rows: properties.map(function (property, index) {
|
||||||
// Property definition is same as form row definition
|
// Property definition is same as form row definition
|
||||||
var row = Object.create(property.getDefinition());
|
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;
|
return row;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure there is always a "save in" section
|
// Ensure there is always a "save in" section
|
||||||
parentRow.name = "Save In";
|
sections.push({ name: 'Location', rows: [{
|
||||||
parentRow.cssclass = "selector-list";
|
name: "Save In",
|
||||||
parentRow.control = "_locator";
|
control: "locator",
|
||||||
parentRow.key = "createParent";
|
key: "createParent"
|
||||||
sections.push({ label: 'Location', rows: [parentRow]});
|
}]});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sections: sections,
|
sections: sections,
|
||||||
name: "Create a New " + type.getName()
|
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
|
* Based on a populated form, get the domain object which
|
||||||
* should be used as a parent for the newly-created object.
|
* should be used as a parent for the newly-created object.
|
||||||
|
@ -74,16 +74,16 @@
|
|||||||
{
|
{
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"control": "_textfield",
|
"control": "textfield",
|
||||||
"label": "Title",
|
"name": "Title",
|
||||||
"key": "name",
|
"key": "name",
|
||||||
"property": "name",
|
"property": "name",
|
||||||
"pattern": "\\S+",
|
"pattern": "\\S+",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"control": "_checkbox",
|
"control": "checkbox",
|
||||||
"label": "Display title by default",
|
"name": "Display title by default",
|
||||||
"key": "displayTitle",
|
"key": "displayTitle",
|
||||||
"property": [ "display", "title" ]
|
"property": [ "display", "title" ]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user