-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix embedded list validation #1286
base: master
Are you sure you want to change the base?
Changes from 1 commit
0a7a034
acb4050
8604b8b
ccaa44d
54c3d01
550798a
f91be33
7eeb6ff
343eda7
ec3c185
0f49b53
5198d9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ export default function maEmbeddedListField() { | |
filterFunc = () => true; | ||
} | ||
scope.fields = targetFields; | ||
scope.formName = []; | ||
// scope.formNamex = [] | ||
scope.targetEntity = targetEntity; | ||
scope.entries = Entry | ||
.createArrayFromRest(scope.value || [], targetFields, targetEntityName, targetEntity.identifier().name()) | ||
|
@@ -45,6 +47,9 @@ export default function maEmbeddedListField() { | |
scope.remove = entry => { | ||
scope.entries = scope.entries.filter(e => e !== entry); | ||
}; | ||
scope.init = ($index) => { | ||
scope.formName[$index] = scope.$parent.form?scope.$parent.form['subform_' + $index] : ""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coding style: please add spaces before and after |
||
} | ||
scope.$watch('entries', (newEntries, oldEntries) => { | ||
if (newEntries === oldEntries) { | ||
return; | ||
|
@@ -55,22 +60,25 @@ export default function maEmbeddedListField() { | |
}, | ||
template: ` | ||
<div class="row"><div class="col-sm-12"> | ||
<ng-form ng-repeat="entry in entries track by $index" class="subentry" name="subform_{{$index}}" ng-init="formName = 'subform_' + $index"> | ||
<div class="remove_button_container"> | ||
<a class="btn btn-default btn-sm" ng-click="remove(entry)"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span> <span translate="REMOVE"></span></a> | ||
</div> | ||
<div class="form-field form-group" ng-repeat="field in ::fields track by $index"> | ||
<ma-field field="::field" value="entry.values[field.name()]" entry="entry" entity="::targetEntity" form="formName" datastore="::datastore()"></ma-field> | ||
<ng-form ng-repeat="entry in entries track by $index" class="subentry" name="subform_{{$index}}" > | ||
<div ng-init="init($index)"> | ||
<div class="remove_button_container"> | ||
<a class="btn btn-default btn-sm" ng-click="remove(entry)"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span> <span translate="REMOVE"></span></a> | ||
</div> | ||
<div class="form-field form-group" ng-init="tmpFormName = formName[$parent.$index]" ng-repeat="field in ::fields track by $index"> | ||
<ma-field field="::field" value="entry.values[field.name()]" entry="entry" entity="::targetEntity" form="::tmpFormName" datastore="::datastore()"></ma-field> | ||
</div> | ||
<hr/> | ||
</div> | ||
<hr/> | ||
</ng-form> | ||
<div class="form-group"> | ||
<div class="col-sm-offset-2 col-sm-10"> | ||
<a class="btn btn-default btn-sm" ng-click="addNew()"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> <span translate="ADD_NEW" translate-values="{ name: field().name() }"></span></a> | ||
</div> | ||
</div> | ||
</div></div>` | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An indentation is missing here. |
||
</div>` | ||
}; | ||
} | ||
|
||
maEmbeddedListField.$inject = []; | ||
maEmbeddedListField.$inject = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing file end of line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out code, please remove.