Merge "Allow the Subscribe directive to work without a list of subscriptions"
This commit is contained in:
commit
b61fbb908b
@ -21,8 +21,7 @@ angular.module('sb.story').controller('StoryDetailController',
|
|||||||
function ($log, $rootScope, $scope, $state, $stateParams, $modal, Session,
|
function ($log, $rootScope, $scope, $state, $stateParams, $modal, Session,
|
||||||
Preference, TimelineEvent, Comment, TimelineEventTypes, story,
|
Preference, TimelineEvent, Comment, TimelineEventTypes, story,
|
||||||
Story, creator, tasks, Task, DSCacheFactory, User, $q,
|
Story, creator, tasks, Task, DSCacheFactory, User, $q,
|
||||||
storyboardApiBase, SubscriptionList, CurrentUser,
|
storyboardApiBase, SessionModalService, moment, $document) {
|
||||||
SessionModalService, moment, $document) {
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var pageSize = Preference.get('story_detail_page_size');
|
var pageSize = Preference.get('story_detail_page_size');
|
||||||
@ -510,12 +509,4 @@ angular.module('sb.story').controller('StoryDetailController',
|
|||||||
},
|
},
|
||||||
handleServiceError);
|
handleServiceError);
|
||||||
};
|
};
|
||||||
|
|
||||||
//GET subscriptions
|
|
||||||
var cuPromise = CurrentUser.resolve();
|
|
||||||
|
|
||||||
cuPromise.then(function(user){
|
|
||||||
$scope.storySubscriptions = SubscriptionList.subsList(
|
|
||||||
'story', user);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -56,8 +56,7 @@
|
|||||||
<i class="fa fa-pencil"></i>
|
<i class="fa fa-pencil"></i>
|
||||||
</a>
|
</a>
|
||||||
<subscribe resource="story"
|
<subscribe resource="story"
|
||||||
resource-id="story.id"
|
resource-id="story.id">
|
||||||
subscriptions="storySubscriptions">
|
|
||||||
</subscribe>
|
</subscribe>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-link"
|
class="btn btn-link"
|
||||||
|
@ -188,23 +188,22 @@ angular.module('sb.util').directive('subscribe',
|
|||||||
|
|
||||||
$scope.resolving = true;
|
$scope.resolving = true;
|
||||||
|
|
||||||
cuPromise.then(
|
cuPromise.then(function () {
|
||||||
function () {
|
angular.forEach($scope.subscriptions, function(sub) {
|
||||||
angular.forEach($scope.subscriptions,
|
if ($scope.resourceId === sub.target_id) {
|
||||||
function(subscription) {
|
setSubscription(sub);
|
||||||
if ($scope.resourceId ===
|
|
||||||
subscription.target_id) {
|
|
||||||
setSubscription(subscription);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
$scope.resolving = false;
|
$scope.resolving = false;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On initialization, resolve.
|
// On initialization, resolve.
|
||||||
|
if (!!$scope.subscriptions) {
|
||||||
$scope.subscriptions.$promise.then(resolveSubsList);
|
$scope.subscriptions.$promise.then(resolveSubsList);
|
||||||
|
} else {
|
||||||
|
resolveSubscription();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user