Browse Source

Select category for search, suggest & edit

pull/1980/merge
Ruud 12 years ago
parent
commit
f12d878c0b
  1. 2
      couchpotato/core/plugins/category/static/category.css
  2. 26
      couchpotato/core/plugins/category/static/category.js
  3. 6
      couchpotato/core/plugins/movie/main.py
  4. 38
      couchpotato/core/plugins/movie/static/movie.actions.js
  5. 2
      couchpotato/core/plugins/movie/static/movie.js
  6. 36
      couchpotato/core/plugins/movie/static/search.css
  7. 44
      couchpotato/core/plugins/movie/static/search.js
  8. 3
      couchpotato/core/plugins/quality/static/quality.js
  9. 12
      couchpotato/core/plugins/suggestion/static/suggest.css

2
couchpotato/core/plugins/category/static/category.css

@ -29,9 +29,7 @@
.category .formHint {
width: 250px !important;
vertical-align: top !important;
margin: 0 !important;
padding-left: 3px !important;
opacity: 0.1;
}
.category:hover .formHint {

26
couchpotato/core/plugins/category/static/category.js

@ -42,7 +42,7 @@ var CategoryListBase = new Class({
self.settings.createGroup({
'label': 'Categories',
'description': 'Create your own categories.'
'description': 'Create categories, each one extending global filters. (Needs refresh \'' +(App.isMac() ? 'CMD+R' : 'F5')+ '\' after editing)'
}).inject(self.content).adopt(
self.category_container = new Element('div.container'),
new Element('a.add_new_category', {
@ -63,6 +63,16 @@ var CategoryListBase = new Class({
},
getCategory: function(id){
return this.categories.filter(function(category){
return category.data.id == id
}).pick()
},
getAll: function(){
return this.categories;
},
createCategory: function(data){
var self = this;
@ -78,7 +88,7 @@ var CategoryListBase = new Class({
var category_list;
var group = self.settings.createGroup({
'label': 'Category order'
'label': 'Category ordering'
}).adopt(
new Element('.ctrlHolder#category_ordering').adopt(
new Element('label[text=Order]'),
@ -138,7 +148,6 @@ var Category = new Class({
var self = this;
self.data = data;
self.types = [];
self.create();
@ -165,15 +174,16 @@ var Category = new Class({
new Element('input.inlay', {
'type':'text',
'value': data.label,
'placeholder': 'Label'
})
'placeholder': 'Example: Kids, Horror or His'
}),
new Element('p.formHint', {'text': 'See global filters for explanation.'})
),
new Element('.category_preferred.ctrlHolder').adopt(
new Element('label', {'text':'Preferred'}),
new Element('input.inlay', {
'type':'text',
'value': data.preferred,
'placeholder': 'Ignored'
'placeholder': 'Blu-ray, DTS'
})
),
new Element('.category_required.ctrlHolder').adopt(
@ -181,7 +191,7 @@ var Category = new Class({
new Element('input.inlay', {
'type':'text',
'value': data.required,
'placeholder': 'Required'
'placeholder': 'Example: DTS, AC3 & English'
})
),
new Element('.category_ignored.ctrlHolder').adopt(
@ -189,7 +199,7 @@ var Category = new Class({
new Element('input.inlay', {
'type':'text',
'value': data.ignored,
'placeholder': 'Ignored'
'placeholder': 'Example: dubbed, swesub, french'
})
)
);

6
couchpotato/core/plugins/movie/main.py

@ -2,7 +2,7 @@ from couchpotato import get_session
from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
from couchpotato.core.helpers.variable import getImdb, splitString
from couchpotato.core.helpers.variable import getImdb, splitString, tryInt
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.core.settings.model import Library, LibraryTitle, Movie, \
@ -452,6 +452,10 @@ class MoviePlugin(Plugin):
m.profile_id = kwargs.get('profile_id')
cat_id = kwargs.get('category_id', None)
if cat_id is not None:
m.category_id = tryInt(cat_id) if tryInt(cat_id) > 0 else None
# Remove releases
for rel in m.releases:
if rel.status_id is available_status.get('id'):

38
couchpotato/core/plugins/movie/static/movie.actions.js

@ -521,6 +521,11 @@ MA.Edit = new Class({
self.profile_select = new Element('select', {
'name': 'profile'
}),
self.category_select = new Element('select', {
'name': 'category'
}).grab(
new Element('option', {'value': -1, 'text': 'None'})
),
new Element('a.button.edit', {
'text': 'Save & Search',
'events': {
@ -540,7 +545,34 @@ MA.Edit = new Class({
});
Quality.getActiveProfiles().each(function(profile){
// Fill categories
var categories = CategoryList.getAll();
if(categories.length == 0)
self.category_select.hide();
else {
self.category_select.show();
categories.each(function(category){
var category_id = category.data.id;
new Element('option', {
'value': category_id,
'text': category.data.label
}).inject(self.category_select);
if(self.movie.category && self.movie.category.data && self.movie.category.data.id == category_id)
self.category_select.set('value', category_id);
});
}
// Fill profiles
var profiles = Quality.getActiveProfiles();
if(profiles.length == 1)
self.profile_select.hide();
profiles.each(function(profile){
var profile_id = profile.id ? profile.id : profile.data.id;
@ -551,6 +583,7 @@ MA.Edit = new Class({
if(self.movie.profile && self.movie.profile.data && self.movie.profile.data.id == profile_id)
self.profile_select.set('value', profile_id);
});
}
@ -566,7 +599,8 @@ MA.Edit = new Class({
'data': {
'id': self.movie.get('id'),
'default_title': self.title_select.get('value'),
'profile_id': self.profile_select.get('value')
'profile_id': self.profile_select.get('value'),
'category_id': self.category_select.get('value')
},
'useSpinner': true,
'spinnerTarget': $(self.movie),

2
couchpotato/core/plugins/movie/static/movie.js

@ -14,6 +14,7 @@ var Movie = new Class({
self.el = new Element('div.movie');
self.profile = Quality.getProfile(data.profile_id) || {};
self.category = CategoryList.getCategory(data.category_id) || {};
self.parent(self, options);
self.addEvents();
@ -111,6 +112,7 @@ var Movie = new Class({
self.removeView();
self.profile = Quality.getProfile(self.data.profile_id) || {};
self.category = CategoryList.getCategory(self.data.category_id) || {};
self.create();
self.busy(false);

36
couchpotato/core/plugins/movie/static/search.css

@ -165,7 +165,8 @@
@media all and (max-width: 480px) {
.movie_result .options select[name=title] { width: 90px; }
.movie_result .options select[name=profile] { width: 60px; }
.movie_result .options select[name=profile] { width: 50px; }
.movie_result .options select[name=category] { width: 50px; }
}
@ -217,25 +218,50 @@
position: absolute;
top: 20%;
left: 15px;
right: 60px;
right: 7px;
vertical-align: middle;
}
.movie_result .info h2 {
margin: 0;
font-weight: normal;
font-size: 20px;
padding: 0;
}
.search_form .info h2 {
position: absolute;
width: 100%;
}
.movie_result .info h2 .title {
display: block;
margin: 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 100%;
}
.movie_result .info h2 span {
.search_form .info h2 .title {
position: absolute;
width: 88%;
}
.movie_result .info h2 .year {
padding: 0 5px;
text-align: center;
position: absolute;
right: -60px;
width: 12%;
right: 0;
}
@media all and (max-width: 480px) {
.search_form .info h2 .year {
font-size: 12px;
margin-top: 7px;
}
}
.search_form .mask,

44
couchpotato/core/plugins/movie/static/search.js

@ -216,9 +216,10 @@ Block.Search.Item = new Class({
}
}).adopt(
self.info_container = new Element('div.info').adopt(
self.title = new Element('h2', {
new Element('h2').adopt(
self.title = new Element('span.title', {
'text': info.titles && info.titles.length > 0 ? info.titles[0] : 'Unknown'
}).adopt(
}),
self.year = info.year ? new Element('span.year', {
'text': info.year
}) : null
@ -274,6 +275,8 @@ Block.Search.Item = new Class({
add: function(e){
var self = this;
if(e)
(e).preventDefault();
self.loadingMask();
@ -282,7 +285,8 @@ Block.Search.Item = new Class({
'data': {
'identifier': self.info.imdb,
'title': self.title_select.get('value'),
'profile_id': self.profile_select.get('value')
'profile_id': self.profile_select.get('value'),
'category_id': self.category_select.get('value')
},
'onComplete': function(json){
self.options_el.empty();
@ -335,7 +339,12 @@ Block.Search.Item = new Class({
self.profile_select = new Element('select', {
'name': 'profile'
}),
new Element('a.button', {
self.category_select = new Element('select', {
'name': 'category'
}).grab(
new Element('option', {'value': -1, 'text': 'None'})
),
self.add_button = new Element('a.button', {
'text': 'Add',
'events': {
'click': self.add.bind(self)
@ -350,7 +359,28 @@ Block.Search.Item = new Class({
}).inject(self.title_select)
})
Quality.getActiveProfiles().each(function(profile){
// Fill categories
var categories = CategoryList.getAll();
if(categories.length == 0)
self.category_select.hide();
else {
self.category_select.show();
categories.each(function(category){
new Element('option', {
'value': category.data.id,
'text': category.data.label
}).inject(self.category_select);
});
}
// Fill profiles
var profiles = Quality.getActiveProfiles();
if(profiles.length == 1)
self.profile_select.hide();
profiles.each(function(profile){
new Element('option', {
'value': profile.id ? profile.id : profile.data.id,
'text': profile.label ? profile.label : profile.data.label
@ -358,6 +388,10 @@ Block.Search.Item = new Class({
});
self.options_el.addClass('set');
if(categories.length == 0 && self.title_select.getElements('option').length == 1 && profiles.length == 1)
self.add();
}
},

3
couchpotato/core/plugins/quality/static/quality.js

@ -103,7 +103,8 @@ var QualityBase = new Class({
var profile_list;
var group = self.settings.createGroup({
'label': 'Profile Defaults'
'label': 'Profile Defaults',
'description': '(Needs refresh \'' +(App.isMac() ? 'CMD+R' : 'F5')+ '\' after editing)'
}).adopt(
new Element('.ctrlHolder#profile_ordering').adopt(
new Element('label[text=Order]'),

12
couchpotato/core/plugins/suggestion/static/suggest.css

@ -34,6 +34,7 @@
left: 15px;
right: 15px;
bottom: 15px;
overflow: hidden;
}
.suggestions .movie_result .data .info h2 {
@ -83,6 +84,17 @@
.suggestions .movie_result .options {
left: 100px;
}
.suggestions .movie_result .options select[name=title] { width: 100%; }
.suggestions .movie_result .options select[name=profile] { width: 100%; }
.suggestions .movie_result .options select[name=category] { width: 100%; }
.suggestions .movie_result .button {
position: absolute;
margin: 2px 0 0 0;
right: 15px;
bottom: 15px;
}
.suggestions .movie_result .thumbnail {
width: 100px;

Loading…
Cancel
Save