Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

addons for pac customizations/case for nested arrays #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"devDependencies": {
"angular-ui-ace": "bower",
"angular-schema-form-datepicker": ">= 0.1.0",
"angular-schema-form-colorpicker": ">= 0.1.0",
"jquery": "~2.1.1",
"angular-mocks": ">= 1.2",
"tx-tinymce": ">= 0.0.5",
Expand Down
32 changes: 28 additions & 4 deletions dist/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,9 @@ angular.module('schemaForm').provider('schemaFormDecorators',
// but be nice to existing ng-if.
if (form.condition) {

var evalExpr = 'evalExpr(form.condition,{ form: form, model: model, "arrayIndex": arrayIndex})';
var evalExpr = 'evalExpr(form.condition,{ form: form, model: model, "arrayIndex": arrayIndex, "customizationIndex": customizationIndex})';
if (form.key) {
evalExpr = 'evalExpr(form.condition, { form: form, model: model, "arrayIndex": arrayIndex, "modelValue": model' + sfPath.stringify(form.key) + '})';
evalExpr = 'evalExpr(form.condition, { form: form, model: model, "arrayIndex": arrayIndex, "customizationIndex": customizationIndex, "modelValue": model' + sfPath.stringify(form.key) + '})';
}

angular.forEach(element.children(), function(child) {
Expand Down Expand Up @@ -1723,7 +1723,12 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf

scope.setArrayIndex = function(index) {
console.log(':: setArrayIndex ::', index);
scope.arrayIndex = index;
if (form.type === "cn-pac-customizations") {
copy.customizationIndex = index;
}
else {
scope.arrayIndex = index;
}
};

// We create copies of the form on demand, caching them for
Expand All @@ -1732,7 +1737,12 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf
if (!formDefCache[index]) {
if (subForm) {
var copy = angular.copy(subForm);
copy.arrayIndex = index;
if (form.type === "cn-pac-customizations") {
copy.customizationIndex = index;
}
else {
copy.arrayIndex = index;
}
schemaForm.traverseForm(copy, setIndex(index));
formDefCache[index] = copy;
}
Expand Down Expand Up @@ -1792,6 +1802,20 @@ angular.module('schemaForm').directive('sfArray', ['sfSelect', 'schemaForm', 'sf
return list;
};

scope.appendTemplateToArray = function() {
var len = list.length;
var copy = scope.copyWithIndex(len);
var template = _.cloneDeep(list[0]);
template.rules = {placements: {publisher_platforms: []}};
console.log(" :: TEMPLATE COPY ::");
console.log(template);
scope.$emit('schemaFormBeforeAppendToArray', copy);
list.push(template);
scope.validateArray();
scope.$emit('schemaFormAfterAppendToArray', copy);
return list;
}

scope.deleteFromArray = function(index) {
scope.$emit('schemaFormBeforeDeleteFromArray', scope, index, list);

Expand Down
2 changes: 1 addition & 1 deletion dist/schema-form.min.js

Large diffs are not rendered by default.

Loading