Skip to content

Commit b2a4d90

Browse files
committed
news + Bugs
1 parent b7af974 commit b2a4d90

File tree

8 files changed

+59
-30
lines changed

8 files changed

+59
-30
lines changed

dist/lets.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/controllers/lets-crud-edit-detail.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
$scope.headers = headers;
1010
$scope.resource = Restangular.all(headers.route);
11+
12+
$scope.submit = function(){
13+
$scope._submit(this, true);
14+
}
15+
16+
$scope.cancel = function () {
17+
$modalInstance.dismiss('success');
18+
};
1119

1220
var parentScope = headers.parentScope;
1321
delete headers.parentScope;
@@ -21,14 +29,6 @@
2129

2230
$scope.fetchData(headers.id, true);
2331

24-
$scope.submit = function(){
25-
$scope._submit(this, true);
26-
}
27-
28-
$scope.cancel = function () {
29-
$modalInstance.dismiss('success');
30-
};
31-
3232
});
3333

3434
})();

src/controllers/lets-crud-edit.controller.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@
257257

258258
if (detail){
259259
if (!$scope.data.id) {
260-
var response = $scope.resource.customPOST($scope.data, $stateParams.id);
260+
var _id = $scope.headers.parentID || $stateParams.id;
261+
var response = $scope.resource.customPOST($scope.data, _id);
261262
var typeSave = "new";
262263
} else {
263264
var response = $scope.resource.customPUT($scope.data, $scope.data.id);
@@ -384,10 +385,12 @@
384385
if (!tab.fixedRoute){
385386
tab.fixedRoute = tab.route;
386387
}
388+
389+
var _route = $scope.headers.route_detail ? $scope.headers.route_detail : $scope.headers.route;
387390

388-
var parentModel = $scope.headers.parent_route ? $scope.headers.parent_route : $scope.headers.route.toLowerCase();
389-
tab.route = (id ? route : $scope.headers.route+tab.fixedRoute);
391+
tab.route = (id ? route : _route+tab.fixedRoute);
390392
tab.id = id ? id : null;
393+
tab.parentID = $scope.data.id;
391394

392395
fwModalService.createCRUDModal(tab, null, "CRUDEditDetailController", null, $scope);
393396
};

src/controllers/lets-crud-form-modal.controller.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010
$scope.headers = headers;
1111
$scope.resource = Restangular.all(headers.route);
1212

13-
var parentScope = headers.parentScope;
14-
delete headers.parentScope;
15-
if(headers.modal_id){
16-
$rootScope.$emit('open:'+headers.modal_id+'', $scope); // @deprecated
17-
18-
if (parentScope){
19-
parentScope.$emit('open:'+headers.modal_id+'', $scope);
20-
}
21-
}
22-
2313
$scope.cancel = function () {
2414
$modalInstance.dismiss('cancel');
2515
}
@@ -34,6 +24,16 @@
3424
$modalInstance.dismiss('cancel');
3525
});
3626

27+
var parentScope = headers.parentScope;
28+
delete headers.parentScope;
29+
if(headers.modal_id){
30+
$rootScope.$emit('open:'+headers.modal_id+'', $scope); // @deprecated
31+
32+
if (parentScope){
33+
parentScope.$emit('open:'+headers.modal_id+'', $scope);
34+
}
35+
}
36+
3737
$scope.fetchData();
3838

3939
});

src/directives/crud/lets-crud-list-table.directive.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
$scope.currentPage = 1;
2222
$scope.perPage = 15;
2323

24+
if( typeof(headers.get)!=="function" ){
25+
headers.get = function(name){
26+
for (var _x in headers.fields) {
27+
var field = headers.fields[_x];
28+
29+
if (field.name == name) {
30+
return field;
31+
}
32+
}
33+
}
34+
}
35+
2436
if ($scope.tab){
2537
$scope.resource = Restangular.all($scope.settings.url);
2638
if (!headers.settings){

src/services/framework/lets-fw-modal.service.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,22 @@
2121
controller: ctrl || 'CRUDFormModalController',
2222
resolve: {
2323
headers: function() {
24-
headers.parentScope = parentScope;
25-
return headers;
24+
var _headers = angular.copy(headers);
25+
_headers.parentScope = parentScope;
26+
27+
if( typeof(_headers.get)!=="function" ){
28+
_headers.get = function(name){
29+
for (var _x in _headers.fields) {
30+
var field = _headers.fields[_x];
31+
32+
if (field.name == name) {
33+
return field;
34+
}
35+
}
36+
}
37+
}
38+
39+
return _headers;
2640
},
2741
data: function() {
2842
try {

src/views/crud/crud-form-input.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="form-group" ng-repeat="field in fields | filter: filter" ng-if="!auto_layout">
2-
<label for="{{field.name}}" class="col-sm-2 control-label no-padding">{{field.label}}
2+
<label for="{{field.name}}" class="col-sm-2 control-label no-padding">{{field.label ? field.label : "&nbsp"}}
33
<span ng-if="field.required">*</span>
44
</label>
55
<div class="col-sm-9">
@@ -16,7 +16,7 @@
1616
"
1717
ng-if="auto_layout">
1818

19-
<label for="{{field.name}}" class="control-label">{{field.label}}
19+
<label for="{{field.name}}" class="control-label">{{field.label ? field.label : "&nbsp"}}
2020
<span ng-if="field.required">*</span>
2121
<i ng-if="field.help" class="fa fa-info-circle" title="{{field.help}}" style="cursor:help; font-size:12px;"></i>
2222
</label>

src/views/crud/crud-form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</div>
8181
</section>
8282

83-
<section ng-if="appSettings.NEW_GRID || tab.new_grid" grid="{{tab_name}}" crud-list-table settings="{headers:tab, tab:true, url:headers.route+'/details/'+data.id+'/'+tab_name, getscope:getscope, tab_name:tab_name}"></section>
83+
<section ng-if="appSettings.NEW_GRID || tab.new_grid" grid="{{tab_name}}" crud-list-table settings="{headers:tab, tab:true, url:(headers.route_detail ? headers.route_detail : headers.route)+'/details/'+data.id+'/'+tab_name, getscope:getscope, tab_name:tab_name}"></section>
8484
</div>
8585
<div ng-if="tab.templateUrl">
8686
<ng-include src="tab.templateUrl"></ng-include>

0 commit comments

Comments
 (0)