Skip to content

Commit d776e4d

Browse files
author
Sandro Tajè
committed
new template slot
1 parent d745771 commit d776e4d

6 files changed

+69
-38
lines changed

dist/angular-uikit.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

+13-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ <h1 class="uk-article-title">Sortable</h1>
4646
<article class="uk-article">
4747
<h1 class="uk-article-title">JSON Table Form</h1>
4848
<form name="form" ng-submit="save(mt.machineType)">
49-
<uk-ng-json-table-form model="vm.jsonTableModel" structure="vm.structure" can-reorder="true" submit-on-enter="true" read-only="false"></uk-ng-json-table-form>
50-
{{form.$valid}}
49+
<uk-ng-json-table-form model="vm.jsonTableModel" structure="vm.structure" can-reorder="true" submit-on-enter="true" read-only="false">
50+
<custom-template>
51+
ciao
52+
{{m[s.property]}}
53+
</custom-template>
54+
</uk-ng-json-table-form>
5155
</form>
5256

5357

@@ -90,7 +94,8 @@ <h1 class="uk-article-title">JSON Table Form</h1>
9094
id: 1,
9195
label: "Units"
9296
},
93-
priority: 1
97+
priority: 1,
98+
template: "TEMPLATEEE"
9499
}, {
95100
name: "ciao2",
96101
keyValueObject: 1,
@@ -117,6 +122,11 @@ <h1 class="uk-article-title">JSON Table Form</h1>
117122
}];
118123

119124
vm.structure = [
125+
{
126+
"type": "template",
127+
"label": "template",
128+
"property": "template"
129+
},
120130
{
121131
"label": "Image",
122132
"property": "thumbnail",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-uikit",
3-
"version": "1.3.18",
3+
"version": "1.4.0",
44
"description": "Angular Uikit binding",
55
"main": "./dist/angular-uikit.min.js",
66
"scripts": {

src/angular-uikit-jsontableform.html

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
</div>
140140
</div>
141141

142+
<div ng-switch-when="template" my-ng-init="transcludeTemplate"></div>
142143

143144
<!-- DEFAULT -->
144145

src/angular-uikit-jsontableform.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ export default function ukNgJsonTableForm($compile, $timeout) {
1818
compact: "=?",
1919
oddIteration: "=?"
2020
},
21+
transclude: {
22+
template: "?customTemplate"
23+
},
2124
templateUrl: function (elm, attrs) {
22-
return !attrs.compact || attrs.compact==='false' ? templateUrl : compactTemplateUrl
25+
return !attrs.compact || attrs.compact === 'false' ? templateUrl : compactTemplateUrl
2326
},
24-
link: function (scope, element, attrs) {
27+
link: function (scope, element, attrs, ctrl, $transcludeFn) {
28+
29+
30+
scope.transcludeTemplate = function (element) {
31+
$transcludeFn(element.scope(), function (clone) {
32+
element.append(clone);
33+
}, null, 'template')
34+
}
2535

2636
if (scope.compact) {
27-
if(scope.oddIteration==undefined)
37+
if (scope.oddIteration == undefined)
2838
scope.oddIteration = false;
2939
scope.arraysStructure = [];
3040
scope.valuesStructure = [];
@@ -54,7 +64,7 @@ export default function ukNgJsonTableForm($compile, $timeout) {
5464
});
5565
});
5666
};
57-
67+
5868
scope.getHeaders = function (struct) {
5969
var firstRow = [];
6070
var secondRow = [];
@@ -68,7 +78,7 @@ export default function ukNgJsonTableForm($compile, $timeout) {
6878
arr.forEach(function (s) {
6979
if (s.type != 'array') {
7080
if (first) {
71-
firstRow.push({colspan: 1});
81+
firstRow.push({ colspan: 1 });
7282
}
7383
secondRow.push(s);
7484
} else {
@@ -85,7 +95,7 @@ export default function ukNgJsonTableForm($compile, $timeout) {
8595
});
8696
};
8797
recur(struct);
88-
return {firstRow: firstRow, secondRow: secondRow};
98+
return { firstRow: firstRow, secondRow: secondRow };
8999
};
90100

91101
scope.objectify = function (el) {

src/angular-uikit.js

+37-27
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,41 @@ import ukNgNotAllowArrayDuplicate from './angular-uikit-notallowarrayduplicate';
88
import hxSubmitOnEnter from './angular-uikit-hx-submit-on-enter';
99

1010
angular.module('angularUikit', [])
11-
.directive('ukNgAutocomplete', ukNgAutocomplete)
12-
.directive('ukNgPagination', ukNgPagination)
13-
.directive('ukNgJsonTableForm', ukNgJsonTableForm)
14-
.directive('ukNgCalendar', ukNgCalendar)
15-
.directive('ukNgSortableItem', ukNgSortableItem)
16-
.directive('ukNgSortable', ukNgSortable)
17-
.directive('ukNgNotAllowArrayDuplicate', ukNgNotAllowArrayDuplicate)
18-
.directive('hxSubmitOnEnter', hxSubmitOnEnter)
19-
.directive('isolateForm', function() {
20-
return {
21-
restrict: 'A',
22-
require: '?form',
23-
link: function(scope, element, attrs, formController) {
24-
if (!formController) {
25-
return;
26-
}
27-
28-
var parentForm = formController.$$parentForm; // Note this uses private API
29-
if (!parentForm) {
30-
return;
31-
}
32-
33-
// Remove this form from parent controller
34-
parentForm.$removeControl(formController);
35-
}
36-
};
37-
});
11+
.directive('ukNgAutocomplete', ukNgAutocomplete)
12+
.directive('ukNgPagination', ukNgPagination)
13+
.directive('ukNgJsonTableForm', ukNgJsonTableForm)
14+
.directive('ukNgCalendar', ukNgCalendar)
15+
.directive('ukNgSortableItem', ukNgSortableItem)
16+
.directive('ukNgSortable', ukNgSortable)
17+
.directive('ukNgNotAllowArrayDuplicate', ukNgNotAllowArrayDuplicate)
18+
.directive('hxSubmitOnEnter', hxSubmitOnEnter)
19+
.directive('isolateForm', function () {
20+
return {
21+
restrict: 'A',
22+
require: '?form',
23+
link: function (scope, element, attrs, formController) {
24+
if (!formController) {
25+
return;
26+
}
27+
28+
var parentForm = formController.$$parentForm; // Note this uses private API
29+
if (!parentForm) {
30+
return;
31+
}
32+
33+
// Remove this form from parent controller
34+
parentForm.$removeControl(formController);
35+
}
36+
};
37+
})
38+
.directive('myNgInit', function () {
39+
return {
40+
scope: {
41+
myNgInit: '&'
42+
},
43+
link: function (scope, element, attributes) {
44+
scope.myNgInit()(element);
45+
}
46+
};
47+
});;
3848
;

0 commit comments

Comments
 (0)