Skip to content

Instantly share code, notes, and snippets.

@adam12
Created January 6, 2016 16:35
Show Gist options
  • Save adam12/372589880abe806eda75 to your computer and use it in GitHub Desktop.
Save adam12/372589880abe806eda75 to your computer and use it in GitHub Desktop.
ctrl.createField = function (e) {
e.preventDefault();
ctrl.vm.ContractSectionId = args.contractSection.Id;
var saveField = function () {
return Field.save(ctrl.vm).result
}
saveField()
.then(function (value) {
for (var i = 0; i < ctrl.contract.ContractSections.length; i++) {
if (ctrl.contractSection.Id == ctrl.contract.ContractSections[i].Id) {
ctrl.contract.ContractSections[i].Fields.push(value);
}
}
//ctrl.contract.ContractSections.forEach(function (section, index) {
// if (ctrl.contractSection.Id == section.Id) {
// section.Fields.push(value);
// }
//})
Contract.store.sync(ctrl.contract);
//m.redraw.strategy('all');
m.redraw(true)
})
}
for (var i = 0; i < ctrl.section.Fields.length; i++) {
fields.push(m.component(inputField, {
contract: ctrl.contract,
properties: ctrl.section.Fields[i],
editMode: ctrl.editMode,
key: 'field' + ctrl.section.Fields[i].Id
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment