Skip to content

Commit 7b7b640

Browse files
committed
Merge branch 'playlists' of https://github.com/takeit/Newscoop into takeit-playlists
2 parents 1a9fcfe + b541d03 commit 7b7b640

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

newscoop/src/Newscoop/NewscoopBundle/Resources/public/js/playlists/controllers/playlists.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ angular.module('playlistsApp').controller('PlaylistsController', [
162162
{number: $scope.articlePreview.number}
163163
);
164164

165+
if (isLimitReached()) {
166+
flashMessage(Translator.trans(
167+
'List limit reached! Remove some articles from the list before adding new ones.'
168+
), 'error');
169+
170+
return true;
171+
}
172+
165173
if (!exists) {
166174
var isInLogList = _.some(
167175
Playlist.getLogList(),
@@ -187,6 +195,14 @@ angular.module('playlistsApp').controller('PlaylistsController', [
187195
{number: number}
188196
);
189197

198+
if (isLimitReached()) {
199+
flashMessage(Translator.trans(
200+
'List limit reached! Remove some articles from the list before adding new ones.'
201+
), 'error');
202+
203+
return true;
204+
}
205+
190206
if (!exists) {
191207
var article = undefined,
192208
isInLogList;
@@ -214,6 +230,17 @@ angular.module('playlistsApp').controller('PlaylistsController', [
214230
flashMessage(Translator.trans('Item already exists in the list'), 'error');
215231
};
216232

233+
/**
234+
* Checks if playlist's limit is reached.
235+
*
236+
* @return {Boolean}
237+
*/
238+
var isLimitReached = function () {
239+
var limit = $scope.playlist.selected.maxItems;
240+
241+
return (limit && limit != 0 && $scope.featuredArticles.length >= limit);
242+
}
243+
217244
/**
218245
* Saves playlist from the article edit screen view
219246
*/

newscoop/src/Newscoop/NewscoopBundle/Resources/translations/articles.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Comments: Comments
189189
'This list is already in a different state than the one in which it was loaded.': 'This list is already in a different state than the one in which it was loaded.'
190190
'List name should not be longer than 40 chars': 'List name should not be longer than 40 chars'
191191
'Not valid number': 'Not valid number'
192+
'List limit': 'List limit'
192193
articles:
193194
playlists:
194195
alert: 'Are you sure you want to change the maximum number of articles for this featured article list? If you decrease the limit, all articles beyond this limit will be deleted. Example: If you change the limit from 50 to 30 articles all 20 articles starting from position number 31 till 50 will be deleted from the list. Maybe the example is too much'

newscoop/src/Newscoop/NewscoopBundle/Resources/views/Playlists/index.html.twig

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,20 @@
224224
</div>
225225
{% endif %}
226226
<div ng-controller="FeaturedController">
227-
<div ng-if="!$parent.isViewing" class="context-block context-list plugin-context-block" {% if editorView %}style="width: 620px;"{% endif %}>
227+
<div ng-if="!$parent.isViewing" class="context-block context-list plugin-context-block" {% if editorView %}style="width: 643px;"{% endif %}>
228228
<div class="row">
229229
<div class="col-xs-6"><h3 style="display:inline">{[{ playlist.selected.title}]}</h3></div>
230-
{% if editorView == false %}<div class="col-xs-6" ng-if="playlist.selected">
231-
<form name="limitForm" class="limit-input">
232-
<label id="playlist-id-label">{{ 'List limit'|trans}}:</label>
230+
<div class="col-xs-6" ng-if="playlist.selected">
231+
<form name="limitForm" class="limit-input">
232+
<label id="playlist-id-label">{{ 'List limit'|trans}}:</label>
233+
{% if editorView == false %}
233234
<input ng-change="updateParentLimit(this)" type="number" name="input" ng-model="playlist.selected.maxItems" min="0" max="99" class="form-control input-sm" id="playlistId">
234235
<span class="error-custom" ng-show="limitForm.input.$error.number">{{ 'Not valid number'|trans}}!</span>
235-
</form>
236-
</div>
236+
{% else %}
237+
<span style="line-height: 28px;">{[{ playlist.selected.maxItems }]}</span>
237238
{% endif %}
239+
</form>
240+
</div>
238241
</div>
239242
<div class="context-list-results" >
240243
<div style="display: block">
@@ -247,7 +250,7 @@
247250
</div>
248251
{% endif %}
249252
<li class="item" ng-repeat="article in $parent.featuredArticles">
250-
<div class="context-item" {% if editorView %}style="width: 580px"{% endif %} >
253+
<div class="context-item" {% if editorView %}style="width: 620px"{% endif %} >
251254
<div class="context-drag-topics"><a href="#" title="drag to sort"></a></div>
252255
<div class="context-item-header">
253256
<div class="context-item-date">{[{::article.created| date:"dd.MM.yyyy 'at' H:mm:ss"}]}

0 commit comments

Comments
 (0)