Skip to content

Commit c30509b

Browse files
committed
WIP
1 parent 126f416 commit c30509b

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/client/js/controllers/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module fng.controllers {
99
$http.get('/api/models').then(function (response) {
1010
$scope.models = response.data;
1111
}, function () {
12-
$location.path('/404');
12+
$location.search({}).path('/404');
1313
});
1414

1515
$scope.newUrl = function (model) {

src/client/js/services/record-handler.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ module fng.services {
584584
}
585585
}
586586
title = title.trimEnd() + (formsAngular.title.suffix || '');
587-
$window.document.title = title.replace(/<\/?[^>]+(>|$)/g, "");;
587+
$window.document.title = title.replace(/<\/?[^>]+(>|$)/g, "");
588588
}
589589
}
590590
}, true);
@@ -673,6 +673,10 @@ module fng.services {
673673
// want to know that an error has occurred. This value is NOT used anywhere in forms-angular.
674674
$scope.phase = "error";
675675
$scope.showError(errorMessage);
676+
} else if (response.status === 404) {
677+
$location
678+
.search({})
679+
.path('/404');
676680
} else {
677681
let msg = response.data;
678682
if (typeof msg !== "string") {
@@ -745,7 +749,7 @@ module fng.services {
745749
$scope.dataEventFunctions.onReadError($scope.id, e);
746750
} else {
747751
if (e.status === 404) {
748-
$location.path("/404");
752+
$location.search({}).path("/404");
749753
} else {
750754
$scope.handleHttpError(e);
751755
}
@@ -863,7 +867,7 @@ module fng.services {
863867

864868
setData,
865869

866-
setUpLookupOptions: function setUpLookupOptions(lookupCollection, schemaElement, $scope, ctrlState, handleSchema) {
870+
setUpLookupOptions: function setUpLookupOptions(lookupCollection, schemaElement, $scope, ctrlState) {
867871
const optionsList = $scope[schemaElement.options] = [];
868872
const idList = $scope[schemaElement.ids] = [];
869873
const dataRequest = !!schemaElement.filter

src/server/data_form.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,9 @@ export class FormsAngular {
869869
} else {
870870
if (formName) {
871871
try {
872-
formSchema = req.resource.model.schema.statics['form'](formName, req);
872+
formSchema = req.resource.model.schema.statics['form'](encodeURIComponent(formName), req);
873873
} catch (e) {
874-
return res.status(500).send(e.message);
874+
return res.status(404).send(e.message);
875875
}
876876
}
877877
let paths = this.preprocess(req.resource, req.resource.model.schema.paths, formName, formSchema).paths;
@@ -975,7 +975,7 @@ export class FormsAngular {
975975
aggregationParam: any | any[],
976976
hiddenFields,
977977
findFuncQry: any,
978-
req? : Express.Request): Promise<any[]> {
978+
req? : any): Promise<any[]> {
979979
let that = this;
980980
let array = Array.isArray(aggregationParam) ? aggregationParam : [aggregationParam];
981981
let retVal = [];

test/unit/baseControllerSpec.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ describe('BaseCtrl', function () {
3939
});
4040

4141
it('should handle an invalid model', function () {
42-
inject(function (_$httpBackend_, $rootScope, $controller) {
42+
inject(function (_$httpBackend_, $rootScope, $controller, $location) {
4343
$httpBackend = _$httpBackend_;
4444
$httpBackend.when('GET', '/api/schema/collection').respond(function () {
4545
return [404, 'Some error', {}];
4646
});
4747
scope = $rootScope.$new();
4848
ctrl = $controller('BaseCtrl', {$scope: scope, RoutingService});
4949
$httpBackend.flush();
50-
expect(scope.alertTitle).toBe('Error!');
51-
expect(scope.errorMessage.toString()).toBe('404 Some error');
52-
50+
expect($location.path()).toBe('/404');
5351
});
5452
});
5553

0 commit comments

Comments
 (0)