add permissions & viewMode to loadConfig (#27)
* add permissions & viewMode to loadConfig
This commit is contained in:
Родитель
0de0170131
Коммит
096572546f
|
@ -70,6 +70,8 @@ export interface IReportLoadConfiguration {
|
|||
settings?: ISettings;
|
||||
pageName?: string;
|
||||
filters?: (IBasicFilter | IAdvancedFilter)[];
|
||||
permissions?: Permissions;
|
||||
viewMode?: ViewMode;
|
||||
}
|
||||
|
||||
export const validateReportLoad = validate(loadSchema, {
|
||||
|
@ -405,3 +407,16 @@ export interface ISelection {
|
|||
regions: IIdentityValue<IEqualsDataReference | IBetweenDataReference>[];
|
||||
filters: (IBasicFilter | IAdvancedFilter)[];
|
||||
}
|
||||
|
||||
export enum Permissions {
|
||||
Read = 0,
|
||||
ReadWrite = 1,
|
||||
Copy = 2,
|
||||
Create = 4,
|
||||
All = 7
|
||||
}
|
||||
|
||||
export enum ViewMode {
|
||||
View,
|
||||
Edit
|
||||
}
|
||||
|
|
|
@ -39,6 +39,18 @@
|
|||
]
|
||||
},
|
||||
"invalidMessage": "filters property is invalid"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "number",
|
||||
"enum": [0, 1, 2, 3],
|
||||
"default": 0,
|
||||
"invalidMessage": "permissions property is invalid"
|
||||
},
|
||||
"viewMode": {
|
||||
"type": "number",
|
||||
"enum": [0, 1],
|
||||
"default": 0,
|
||||
"invalidMessage": "viewMode property is invalid"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
@ -16,6 +16,8 @@ describe('Unit | Models', function () {
|
|||
const idInvalidTypeMessage = models.loadSchema.properties.id.messages.type;
|
||||
const filtersInvalidMessage = models.loadSchema.properties.filters.invalidMessage;
|
||||
const pageNameInvalidTypeMessage = models.loadSchema.properties.pageName.messages.type;
|
||||
const permissionsInvalidMessage = models.loadSchema.properties.permissions.invalidMessage;
|
||||
const viewModeInvalidMessage = models.loadSchema.properties.viewMode.invalidMessage;
|
||||
|
||||
it(`should return errors with one containing message '${accessTokenRequiredMessage}' if accessToken is not defined`, function () {
|
||||
// Arrange
|
||||
|
@ -187,6 +189,74 @@ describe('Unit | Models', function () {
|
|||
// Assert
|
||||
testForExpectedMessage(errors, pageNameInvalidTypeMessage);
|
||||
});
|
||||
|
||||
it(`should return errors with one containing message '${permissionsInvalidMessage}' if permissions is not a number`, function () {
|
||||
// Arrange
|
||||
const testData = {
|
||||
load: {
|
||||
id: 'fakeId',
|
||||
accessToken: 'fakeAccessToken',
|
||||
permissions: "SomeString"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const errors = models.validateReportLoad(testData.load);
|
||||
|
||||
// Assert
|
||||
testForExpectedMessage(errors, permissionsInvalidMessage);
|
||||
});
|
||||
|
||||
it(`should return errors with one containing message '${permissionsInvalidMessage}' if permissions is invalid`, function () {
|
||||
// Arrange
|
||||
const testData = {
|
||||
load: {
|
||||
id: 'fakeId',
|
||||
accessToken: 'fakeAccessToken',
|
||||
permissions: 5
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const errors = models.validateReportLoad(testData.load);
|
||||
|
||||
// Assert
|
||||
testForExpectedMessage(errors, permissionsInvalidMessage);
|
||||
});
|
||||
|
||||
it(`should return errors with one containing message '${viewModeInvalidMessage}' if viewMode is not a number`, function () {
|
||||
// Arrange
|
||||
const testData = {
|
||||
load: {
|
||||
id: 'fakeId',
|
||||
accessToken: 'fakeAccessToken',
|
||||
viewMode: "ViewModeString"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const errors = models.validateReportLoad(testData.load);
|
||||
|
||||
// Assert
|
||||
testForExpectedMessage(errors, viewModeInvalidMessage);
|
||||
});
|
||||
|
||||
it(`should return errors with one containing message '${viewModeInvalidMessage}' if viewMode is invalid`, function () {
|
||||
// Arrange
|
||||
const testData = {
|
||||
load: {
|
||||
id: 'fakeId',
|
||||
accessToken: 'fakeAccessToken',
|
||||
viewMode: 5
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
const errors = models.validateReportLoad(testData.load);
|
||||
|
||||
// Assert
|
||||
testForExpectedMessage(errors, viewModeInvalidMessage);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateDashboardLoad', function () {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
},
|
||||
"globalDependencies": {
|
||||
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
|
||||
"jasmine": "registry:dt/jasmine",
|
||||
"jsen": "registry:dt/jsen#0.0.0+20160328204314",
|
||||
"karma-jasmine": "registry:dt/karma-jasmine#0.0.0+20160316155526"
|
||||
"karma-jasmine": "registry:dt/karma-jasmine"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче