From aa2c426ed0348027aeeb48411f031417ee9b97c7 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Mon, 15 Oct 2018 16:22:41 -0400 Subject: [PATCH] Added pinAdded event, getCurrentPins function --- app/pins/pinSvc.js | 9 +++++++++ app/ui/composerController.js | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/pins/pinSvc.js b/app/pins/pinSvc.js index 648edb85..8efeafba 100644 --- a/app/pins/pinSvc.js +++ b/app/pins/pinSvc.js @@ -543,6 +543,8 @@ function pinSvc($translate, timeSvc, stateSvc, MapManager, $uibModal) { // pin.endDate = new Date(); svc.addStorypinToMap(pin); + PubSub.publish("pinAdded"); + return pin; }; @@ -656,6 +658,12 @@ function pinSvc($translate, timeSvc, stateSvc, MapManager, $uibModal) { }); }; + /** + * Get pins from the current chapter + * @returns {Array|*} An array of Pins + */ + svc.getCurrentPins = () => svc.getPins(stateSvc.getChapterIndex()); + /** * When the user clicks on save it will reflect his changes on the map. */ @@ -717,6 +725,7 @@ function pinSvc($translate, timeSvc, stateSvc, MapManager, $uibModal) { } } stateSvc.setStoryPinsToConfig(featureCollections); + PubSub.publish("pinAdded"); }; /** diff --git a/app/ui/composerController.js b/app/ui/composerController.js index 5f4a8b37..71e16d71 100644 --- a/app/ui/composerController.js +++ b/app/ui/composerController.js @@ -283,15 +283,7 @@ function composerController( const endDate = $scope.formatDates(pin.endTime); const storyLayerStartDate = $scope.formatDates(date); - let shouldShow = false; - if (moment(storyLayerStartDate).isSameOrAfter(startDate)) { - // TODO: Show StoryPin. - shouldShow = true; - } - if (moment(storyLayerStartDate).isSameOrAfter(endDate)) { - // TODO: Hide Storypin. - shouldShow = false; - } + const shouldShow = moment(storyLayerStartDate).isSameOrAfter(startDate) && !moment(storyLayerStartDate).isAfter(endDate); if (shouldShow) { pin.show();