Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

Commit

Permalink
Merge 2058864 into d9c8a96
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Sep 29, 2015
2 parents d9c8a96 + 2058864 commit af746a4
Show file tree
Hide file tree
Showing 14 changed files with 1,070 additions and 5 deletions.
Binary file modified app/images/side-tab-icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@
<script src="scripts/controllers/editorial-comments.js"></script>
<script src="scripts/directives/editorial-comment.js"></script>
<script src="scripts/services/editorial-comments.js"></script>
<script src="scripts/services/ArticlesList.js"></script>
<script src="scripts/controllers/pane-articles-lists.js"></script>
<!-- endbuild -->
</body>
</html>
167 changes: 167 additions & 0 deletions app/scripts/controllers/pane-articles-lists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
(function () {
'use strict';

/**
* Constructor function for the articles lists modal controller.
*
* @class ModalCtrl
*/
function ModalCtrl($modalInstance, $sce, info, $rootScope) {
var self = this,
url;

switch(info.action) {
case 'edit':
url = [
AES_SETTINGS.API.rootURI,
'/admin/playlists/',
info.articleId,
'/',
info.language,
'/editor-view/', info.articlesListId
].join('');

break;
case 'attach':
url = [
AES_SETTINGS.API.rootURI,
'/admin/playlists/',
info.articleId,
'/',
info.language,
'/editor-view'
].join('');

break;
default:
url = '';
}

self.url = $sce.trustAsResourceUrl(url);

/**
* Closes the modal.
*
* @method close
*/
self.close = function () {
$rootScope.$broadcast('close-articles-lists-modal');
$modalInstance.close();
};
}

/**
* AngularJS controller for the ArticlesLists pane.
*
* @class PaneArticlesListsCtrl
*/
angular.module('authoringEnvironmentApp')
.controller('PaneArticlesListsCtrl', [
'$q',
'$modal',
'$scope',
'article',
'modalFactory',
'ArticlesList',
'toaster',
'TranslationService',
function (
$q,
$modal,
$scope,
articleService,
modalFactory,
ArticlesList,
toaster,
TranslationService) {
var self = this,
article = articleService.articleInstance;

// retrieve all articlesLists assigned to the article
self.assignedArticlesLists = ArticlesList.getAllByArticle(
article.articleId, article.language
);

$scope.$on('close-articles-lists-modal', function(event) {
self.assignedArticlesLists = ArticlesList.getAllByArticle(
article.articleId, article.language
);
});

/**
* Open iframe to the articles lists editor in newscoop admin.
*
* @method openArticlesListsEditor
*/
self.openArticlesListsEditor = function (
action,
articlesListId
) {
$modal.open({
templateUrl: 'views/modal-articles-lists-editor.html',
controller: ModalCtrl,
controllerAs: 'modalArticlesListsEditorCtrl',
windowClass: 'featuredArticlesModal',
resolve: {
info: function () {
return {
articleId: article.articleId,
language: article.languageData.id,
action: action,
articlesListId: articlesListId
};
}
}
});
};

/**
* Asks user to confirm unassigning a articlesList from the article
* then unassignes the articlesList, if the action is confirmed.
*
* @method confirmUnassignArticlesList
* @param articlesList {Object} articlesList to unassign
*/
self.confirmUnassignArticlesList = function (articlesList) {
var modal,
title,
text;

title = TranslationService.trans(
'aes.msgs.articleslists.unassign.popupHead'
);
text = TranslationService.trans(
'aes.msgs.articleslists.unassign.popup'
);

modal = modalFactory.confirmLight(title, text);

modal.result.then(function () {
return articlesList.removeFromArticle(
article.articleId,
article.language,
articlesList).then(function () {
_.remove(
self.assignedArticlesLists,
{id: articlesList.id}
);
toaster.add({
type: 'sf-info',
message: TranslationService.trans(
'aes.msgs.articleslists.unassign.success'
)
});
}, function () {
toaster.add({
type: 'sf-error',
message: TranslationService.trans(
'aes.msgs.articleslists.unassign.error'
)
});
});
}, $q.reject);
};
}
]);

}());
12 changes: 12 additions & 0 deletions app/scripts/localization/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,15 @@
Translator.add("aes.label.pinarticle", "Pin article", "messages", "en");
Translator.add("aes.label.switches", "Switches", "messages", "en");
Translator.add("aes.label.topics", "Topics", "messages", "en");
Translator.add("aes.label.articleslists", "Featured Articles Lists", "messages", "en");
Translator.add("aes.label.addtopic", "Add new topic", "messages", "en");
Translator.add("aes.label.selectparent", "select parent topic", "messages", "en");
Translator.add("aes.label.addexistingtopics", "Add existing topic(s)", "messages", "en");
Translator.add("aes.label.addexistingarticleslists", "Add an article to the existing list(s)", "messages", "en");
Translator.add("aes.label.topicname", "Topic name", "messages", "en");
Translator.add("aes.label.assignedtopics", "Assigned Topics", "messages", "en");
Translator.add("aes.label.assignedarticleslists", "Assigned Lists", "messages", "en");
Translator.add("aes.label.unassignarticleslist", "Unassign an article from the Featured Articles List", "messages", "en");
Translator.add("aes.label.customfields", "Custom fields", "messages", "en");
Translator.add("aes.label.nofields", "There are no metadata fields for this type of article", "messages", "en");
Translator.add("aes.label.searchmedia", "Search Media Archive", "messages", "en");
Expand Down Expand Up @@ -570,6 +574,14 @@
Translator.add("aes.msgs.topics.unassign.popup", "Should you change your mind, the topic can always be re-assigned again.", "messages", "en");
Translator.add("aes.msgs.topics.unassign.success", "Topic(s) unassigned successfully.", "messages", "en");
Translator.add("aes.msgs.topics.unassign.error", "Failed to unassign topic(s) from the article.", "messages", "en");
Translator.add("aes.msgs.articleslists.add.success", "The articles list(s) have been added and assigned successfully to this article.", "messages", "en");
Translator.add("aes.msgs.articleslists.add.error", "Failed to add and assign new articles list(s) to the article.", "messages", "en");
Translator.add("aes.msgs.articleslists.assign.success", "The articles list has been assigned successfully to this article", "messages", "en");
Translator.add("aes.msgs.articleslists.assign.error", "Assigning the articles list to this article failed.", "messages", "en");
Translator.add("aes.msgs.articleslists.unassign.popupHead", "Do you really want to unassign this articles list from the article?", "messages", "en");
Translator.add("aes.msgs.articleslists.unassign.popup", "Should you change your mind, the articles list can always be re-assigned again.", "messages", "en");
Translator.add("aes.msgs.articleslists.unassign.success", "Articles List(s) unassigned successfully.", "messages", "en");
Translator.add("aes.msgs.articleslists.unassign.error", "Failed to unassign articles list(s) from the article.", "messages", "en");
Translator.add("aes.msgs.slideshows.unassign.popupHead", "Do you really want to unassign this slideshow from the article?", "messages", "en");
Translator.add("aes.msgs.slideshows.unassign.popup", "Should you change your mind, the slideshow can always be re-assigned again.", "messages", "en");
Translator.add("aes.msgs.slideshows.unassign.success", "Slideshow unassigned successfully.", "messages", "en");
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/routing/fos_js_routes.js

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions app/scripts/services/ArticlesList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
'use strict';

/**
* A factory which creates an article articlesList model.
*
* @class ArticlesList
*/
angular.module('authoringEnvironmentApp').factory('ArticlesList', [
'$http',
'$q',
function (
$http,
$q) {
var ArticlesList = function () {}; // articlesList constructor

/**
* Converts raw data object to a ArticlesList instance.
*
* @method createFromApiData
* @param data {Object} raw object containing articlesList data
* @return {Object} created ArticlesList instance
*/
ArticlesList.createFromApiData = function (data) {
var articlesList = new ArticlesList();

articlesList.id = parseInt(data.id);
articlesList.title = data.title;
articlesList.notes = (data.notes) ? data.notes : null;
articlesList.maxItems =
(data.maxItems) ? parseInt(data.maxItems) : null;
articlesList.text = articlesList.title;

return articlesList;
};

/**
* Retrieves a list of all articlesLists assigned to a specific article.
*
* Initially, an empty array is returned, which is later filled with
* data on successful server response. At that point the given promise
* is resolved (exposed as a $promise property of the returned array).
*
* @method getAllByArticle
* @param number {Number} article ID
* @param language {String} article language code, e.g. 'de'
* @return {Object} array of article articlesLists
*/
ArticlesList.getAllByArticle = function (number, language) {
var articlesLists = [],
deferredGet = $q.defer(),
url;

articlesLists.$promise = deferredGet.promise;

url = Routing.generate(
'newscoop_gimme_articles_getarticle_language_playlists',
{number: number, language: language},
true
);

$http.get(url)
.success(function (response) {
response.items.forEach(function (item) {
item = ArticlesList.createFromApiData(item);
articlesLists.push(item);
});
deferredGet.resolve();
}).error(function (responseBody) {
deferredGet.reject(responseBody);
});

return articlesLists;
};

/**
* Unassignes articlesList from article.
*
* @method removeFromArticle
* @param number {Number} article ID
* @param language {String} article language code (e.g. 'de')
* @return {Object} promise object that is resolved on successful server
* response and rejected on server error response
*/
ArticlesList.prototype.removeFromArticle = function(
number,
language,
articlesList) {
var deferred = $q.defer(),
linkHeader;

linkHeader = [
'<',
Routing.generate(
'newscoop_gimme_articles_getarticle',
{number: number, language: language},
false
),
'; rel="article">'
].join('');

$http({
url: Routing.generate(
'newscoop_gimme_articles_lists_unlinkarticle',
{id: articlesList.id},
true
),
method: 'UNLINK',
headers: {link: linkHeader}
})
.success(function () {
deferred.resolve();
})
.error(function (responseBody) {
deferred.reject(responseBody);
});

return deferred.promise;
};

return ArticlesList;
}
]);
11 changes: 11 additions & 0 deletions app/scripts/services/panes.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ angular.module('authoringEnvironmentApp').factory('panes', [
active: false,
selected: true
},
{
name: 'Articles Lists',
id: 'articles-lists',
icon: 'featuredarticles',
template: 'views/pane-articles-lists.html',
position: 'right',
size: 'small',
visible: false,
active: false,
selected: true
},
{
name: 'Editorial Comments',
id: 'editorial-comments',
Expand Down
15 changes: 12 additions & 3 deletions app/styles/aes-icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
.active .big-icon-info, .active a:hover .big-icon-info{
background-position: -70px -156px;
}
.big-icon-relatedarticles {
.big-icon-featuredarticles {
background-position: 0 -182px;
}
a:hover .big-icon-relatedarticles {
a:hover .big-icon-featuredarticles {
background-position: -35px -182px;
}
.active .big-icon-relatedarticles, .active a:hover .big-icon-relatedarticles {
.active .big-icon-featuredarticles, .active a:hover .big-icon-featuredarticles {
background-position: -70px -182px;
}
.big-icon-slideshows {
Expand All @@ -103,6 +103,15 @@
.active .big-icon-editorial_comments, .active a:hover .big-icon-editorial_comments {
background-position: -70px -236px;
}
.big-icon-relatedarticles {
background-position: 0 -260px;
}
a:hover .big-icon-relatedarticles {
background-position: -35px -260px;
}
.active .big-icon-relatedarticles, .active a:hover .big-icon-relatedarticles {
background-position: -70px -260px;
}

/* Font awesome */
.fa {
Expand Down
Loading

0 comments on commit af746a4

Please sign in to comment.