Skip to content
Merged
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
6 changes: 4 additions & 2 deletions app/controllers/dashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ app.controller("DashboardController", function ($controller, $scope, UserService
$scope.showPublic = function () {
var user = UserService.getCurrentUser();
var publicView = false;
if (user.role === 'ROLE_ANONYMOUS' || user.role === 'ROLE_USER') {
if (user.role === undefined || user.role === null) {
publicView = true;
} else if (user.role === 'ROLE_ANONYMOUS' || user.role === 'ROLE_USER') {
publicView = true;
}
return publicView;
Expand All @@ -38,4 +40,4 @@ app.controller("DashboardController", function ($controller, $scope, UserService

NoteRepo.page();

});
});
2 changes: 1 addition & 1 deletion app/controllers/noteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ app.controller('NoteController', function ($controller, $scope, Note, NoteRepo,
toolbar: "undo redo | formatselect bold italic separator | alignleft aligncenter alignright | numlist bullist | forecolor backcolor"
};

});
});
4 changes: 2 additions & 2 deletions app/repo/noteRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.repo("NoteRepo", function NoteRepo($q, WsApi, Note, ServiceRepo, TableFactor
});
};

noteRepo.page = function () {
noteRepo.page = function () {
return $q(function (resolve) {
safePage(resolve);
});
Expand Down Expand Up @@ -86,4 +86,4 @@ app.repo("NoteRepo", function NoteRepo($q, WsApi, Note, ServiceRepo, TableFactor

return noteRepo;

});
});
127 changes: 127 additions & 0 deletions tests/mocks/models/mockNote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
var mockNote1 = {
"active": true,
"author": {
"lastName": "Daniels",
"firstName": "Jack",
"id": 234567891,
"usename": "4253938752821",
"email": "aggieJack@library.tamu.edu",
"role": "ROLE_ADMIN",
"netId": "aggieJack",
"notes": []
},
"body": "<p>This is <strong>Jack's</strong> note.</p>",
"id": 123456789,
"lastModified": 1529618244432,
"noteType": "ENHANCEMENT",
"pinned": false,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jack's Note",
"type": "note",
};

var mockNote2 = {
"active": true,
"author": {
"lastName": "Daniels",
"firstName": "Jill",
"id": 876543219,
"usename": "1425393875282",
"email": "aggieJill@library.tamu.edu",
"role": "ROLE_USER",
"netId": "aggieJill",
"notes": []
},
"body": "<p>This is <strong>Jill's</strong> note.</p>",
"id": 987654321,
"lastModified": 1234567890120,
"noteType": "ISSUE",
"pinned": true,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jill's Note",
"type": "note",
"withinSchedule": false
};

var mockNote3 = {
"active": false,
"author": {
"lastName": "Smith",
"firstName": "Jacob",
"id": 928374651,
"usename": "8214253938752",
"email": "jsmith@library.tamu.edu",
"role": "ROLE_USER",
"netId": "jsmith",
"notes": []
},
"body": "<p>This is <strong>Jacob's</strong> note.</p>",
"id": 192837465,
"lastModified": 1529679921989,
"noteType": "REPORT",
"pinned": false,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jacob's Note",
"type": "note",
"withinSchedule": true
};

angular.module('mock.note', []).service('Note', function ($q) {
return function () {
this.clearValidationResults = function () {

};
return this;
};
});
11 changes: 11 additions & 0 deletions tests/mocks/models/mockOverallStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var mockOverallStatus = function () {
return this;
};

angular.module('mock.overallStatusPublic', []).service('OverallStatusPublic', function () {
return mockOverallStatus;
});

angular.module('mock.overallStatusFull', []).service('OverallStatusFull', function () {
return mockOverallStatus;
});
209 changes: 209 additions & 0 deletions tests/mocks/repo/mockNoteRepo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
var mockNotes = [
{
"active": true,
"author": {
"lastName": "Daniels",
"firstName": "Jack",
"id": 234567891,
"usename": "4253938752821",
"email": "aggieJack@library.tamu.edu",
"role": "ROLE_ADMIN",
"netId": "aggieJack",
"notes": []
},
"body": "<p>This is <strong>Jack's</strong> note.</p>",
"id": 123456789,
"lastModified": 1529618244432,
"noteType": "ENHANCEMENT",
"pinned": false,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jack's Note",
"type": "note",
},
{
"active": true,
"author": {
"lastName": "Daniels",
"firstName": "Jill",
"id": 876543219,
"usename": "1425393875282",
"email": "aggieJill@library.tamu.edu",
"role": "ROLE_USER",
"netId": "aggieJill",
"notes": []
},
"body": "<p>This is <strong>Jill's</strong> note.</p>",
"id": 987654321,
"lastModified": 1234567890120,
"noteType": "ISSUE",
"pinned": true,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jill's Note",
"type": "note",
"withinSchedule": false
},
{
"active": false,
"author": {
"lastName": "Smith",
"firstName": "Jacob",
"id": 928374651,
"usename": "8214253938752",
"email": "jsmith@library.tamu.edu",
"role": "ROLE_USER",
"netId": "jsmith",
"notes": []
},
"body": "<p>This is <strong>Jacob's</strong> note.</p>",
"id": 192837465,
"lastModified": 1529679921989,
"noteType": "REPORT",
"pinned": false,
"schedules": [],
"service": {
"id": 1,
"schedules": [],
"withinSchedule": false,
"name": "Cap",
"aliases": [],
"status": "UP",
"isAuto": false,
"isPublic": true,
"onShortList": true,
"serviceUrl": null,
"description": "Repository agnostic curation",
"website": "cap.library.tamu.edu",
"software": "Tomcat",
"projectId": 1,
"type": "service"
},
"title": "Jacob's Note",
"type": "note",
"withinSchedule": true
}
];

angular.module('mock.noteRepo', []).service('NoteRepo', function ($q) {
var NoteRepo = this;

NoteRepo.list = mockNotes;

NoteRepo.create = function (note) {
var defer = $q.defer();
note.id = NoteRepo.list.length + 1;
NoteRepo.list.push(note);
defer.resolve(note);
return defer.promise;
};

NoteRepo.update = function (note) {
var defer = $q.defer();
for (var i in NoteRepo.list) {
if (NoteRepo.list[i].id === note.id) {
angular.extend(NoteRepo.list[i], note);
note = NoteRepo.list[i];
break;
}
}
defer.resolve(note);
return defer.promise;
};

var updateNote = function (note) {
NoteRepo.update(note);
};

NoteRepo.getAll = function () {
var defer = $q.defer();
defer.resolve(NoteRepo.list);
return defer.promise;
};

NoteRepo.fetchById = function (noteId) {
var note = new Note();
for (var i in NoteRepo.list) {
if (NoteRepo.list[i].id === id) {
note = NoteRepo.list[i];
break;
}
}
return note;
};

NoteRepo.getPageSettings = function () {
var mockPageSettings = {
filters: {
active: [true]
},
sort: [{
property: 'service.name',
direction: 'ASC'
}, {
property: 'lastModified',
direction: 'DESC'
}]
};

return mockPageSettings;
};

NoteRepo.getTableParams = function () {
// @todo
return {};
};

NoteRepo.fetchPage = function (pageSettings) {
// @todo
return {};
};

var safePage = function(resolve) {
// @todo
};

NoteRepo.page = function () {
return $q(function (resolve) {
safePage(resolve);
});
};

var table = {
// @todo
};

return NoteRepo;
});
4 changes: 2 additions & 2 deletions tests/mocks/repo/mockUserRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ var mockUserRepo3 = {
};

angular.module('mock.userRepo', []).service('UserRepo', function ($q) {
return UserRepo;
});
return this;
});
Loading