Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jkmarx/fix bug event refresh #2868

Merged
merged 4 commits into from
Jul 17, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
vm.getGroups = getGroups;
vm.groups = [];
vm.groupInvites = {};
vm.refreshEvents = false;
activate();

function activate () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
it('Variables should be initialized', function () {
expect(ctrl.groups).toEqual([]);
expect(ctrl.groupInvites).toEqual({});
expect(ctrl.refreshEvents).toEqual(false);
});

describe('getGroups', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
modalInstance.result.then(function () {
// user confirmed deletion
getDataSets();
vm.dashboardParentCtrl.refreshEvents = true;
});
}

Expand Down Expand Up @@ -161,6 +162,7 @@
function () {
// when modal is closed
getDataSets();
vm.dashboardParentCtrl.refreshEvents = true;
});
}

Expand Down
22 changes: 21 additions & 1 deletion refinery/ui/source/js/dashboard/controllers/history-card-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
.module('refineryDashboard')
.controller('HistoryCardCtrl', HistoryCardCtrl);

HistoryCardCtrl.$inject = ['eventsService'];
HistoryCardCtrl.$inject = ['$scope', 'eventsService'];

function HistoryCardCtrl (
$scope,
eventsService
) {
var vm = this;
Expand All @@ -39,5 +40,24 @@
vm.events = response;
});
}

/*
* ---------------------------------------------------------
* Watchers
* ---------------------------------------------------------
*/
vm.$onInit = function () {
$scope.$watchCollection(
function () {
return vm.ParentCtrl.refreshEvents;
},
function () {
if (vm.ParentCtrl.refreshEvents) {
getUserEvents();
vm.ParentCtrl.refreshEvents = false;
}
}
);
};
}
})();
3 changes: 3 additions & 0 deletions refinery/ui/source/js/dashboard/directives/history-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
.module('refineryDashboard')
.component('rpHistoryCard', {
controller: 'HistoryCardCtrl',
require: {
ParentCtrl: '^rpDashboard'
},
templateUrl: ['$window', function ($window) {
return $window.getStaticUrl('partials/dashboard/partials/history-card.html');
}]
Expand Down
25 changes: 22 additions & 3 deletions refinery/ui/source/js/dashboard/directives/history-card.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
$templateCache,
$window
) {
$templateCache.put(
$window.getStaticUrl('partials/dashboard/views/dashboard.html'),
'<div id="dashboard"><rp-history-card></rp-history-card></div>'
);

$templateCache.put(
$window.getStaticUrl('partials/dashboard/partials/history-card.html'),
'<div id="tools-list"></div>'
'<div id="events-list"></div>'
);
$httpBackend
.whenGET(
Expand All @@ -25,14 +30,28 @@
'/events/'
).respond(200, []);

$httpBackend
.whenGET(
settings.appRoot +
settings.refineryApi +
'/extended_groups/members/?format=json&id=id'
).respond(200, []);

$httpBackend
.whenGET(
settings.appRoot +
settings.refineryApiV2 +
'/data_sets/?format=json'
).respond(200, []);

var scope = $rootScope.$new();
var template = '<rp-history-card></rp-history-card>';
var template = '<rp-dashboard></rp-dashboard>';
directiveElement = $compile(template)(scope);
scope.$digest();
}));

it('generates the appropriate HTML', function () {
expect(directiveElement.html()).toContain('tools-list');
expect(directiveElement.html()).toContain('events-list');
expect(directiveElement.html()).toContain('</div>');
});
});
Expand Down