Fixed: Add tag when text box loses focus

This commit is contained in:
Mark McDowall
2014-12-02 17:18:17 -08:00
parent be81bf322a
commit cd1d34a0f2
17 changed files with 373 additions and 49 deletions

View File

@@ -1,29 +1,47 @@
 <div class="col-sm-2">
{{TitleCase preferredProtocol}}
{{#if enableUsenet}}
{{#if enableTorrent}}
{{#if_eq preferredProtocol compare="usenet"}}
Prefer Usenet
{{else}}
Prefer Torrent
{{/if_eq}}
{{else}}
Only Usenet
{{/if}}
{{else}}
Only Torrent
{{/if}}
</div>
<div class="col-sm-2">
{{#if_eq usenetDelay compare="0"}}
No delay
{{else}}
{{#if_eq usenetDelay compare="1"}}
1 minute
{{#if enableUsenet}}
{{#if_eq usenetDelay compare="0"}}
No delay
{{else}}
{{usenetDelay}} minutes
{{#if_eq usenetDelay compare="1"}}
1 minute
{{else}}
{{usenetDelay}} minutes
{{/if_eq}}
{{/if_eq}}
{{/if_eq}}
{{else}}
-
{{/if}}
</div>
<div class="col-sm-2">
{{#if_eq torrentDelay compare="0"}}
No delay
{{else}}
{{#if_eq torrentDelay compare="1"}}
1 minute
{{#if enableTorrent}}
{{#if_eq torrentDelay compare="0"}}
No delay
{{else}}
{{torrentDelay}} minutes
{{#if_eq torrentDelay compare="1"}}
1 minute
{{else}}
{{torrentDelay}} minutes
{{/if_eq}}
{{/if_eq}}
{{/if_eq}}
{{else}}
-
{{/if}}
</div>
<div class="col-sm-5">
{{tagDisplay tags}}

View File

@@ -5,7 +5,7 @@
<div class="rule-setting-list">
<div class="rule-setting-header x-header hidden-xs">
<div class="row">
<span class="col-sm-2">Preferred Protocol</span>
<span class="col-sm-2">Protocol</span>
<span class="col-sm-2">Usenet Delay</span>
<span class="col-sm-2">Torrent Delay</span>
<span class="col-sm-5">Tags</span>

View File

@@ -18,7 +18,14 @@ define([
_deleteView: DeleteView,
ui: {
tags : '.x-tags'
tags : '.x-tags',
usenetDelay : '.x-usenet-delay',
torrentDelay : '.x-torrent-delay',
protocol : '.x-protocol'
},
events: {
'change .x-protocol' : '_updateModel'
},
initialize: function (options) {
@@ -32,11 +39,83 @@ define([
property : 'tags'
});
}
this._toggleControls();
},
_onAfterSave: function () {
this.targetCollection.add(this.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
},
_updateModel: function () {
var protocol = this.ui.protocol.val();
if (protocol === 'preferUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet'
});
}
if (protocol === 'preferTorrent') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
if (protocol === 'onlyUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : false,
preferredProtocol : 'usenet'
});
}
if (protocol === 'onlyTorrent') {
this.model.set({
enableUsenet : false,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
this._toggleControls();
},
_toggleControls: function () {
var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol');
if (preferred === 'usenet') {
this.ui.protocol.val('preferUsenet');
}
else {
this.ui.protocol.val('preferTorrent');
}
if (enableUsenet) {
this.ui.usenetDelay.show();
}
else {
this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide();
}
if (enableTorrent) {
this.ui.torrentDelay.show();
}
else {
this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide();
}
}
});

View File

@@ -10,21 +10,23 @@
<div class="modal-body indexer-modal">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">Preferred Protocol</label>
<label class="col-sm-3 control-label">Protocol</label>
<div class="col-sm-1 col-sm-push-5 help-inline">
<i class="icon-nd-form-info" title="Choose which protocol to use when choosing between otherwise equal releases" />
<i class="icon-nd-form-info" title="Choose which protocol(s) to use and which one is preferred when choosing between otherwise equal releases" />
</div>
<div class="col-sm-5 col-sm-pull-1">
<select class="form-control" name="preferredProtocol">
<option value="1">Usenet</option>
<option value="2">Torrents</option>
<select class="form-control x-protocol">
<option value="preferUsenet">Prefer Usenet</option>
<option value="preferTorrent">Prefer Torrent</option>
<option value="onlyUsenet">Only Usenet</option>
<option value="onlyTorrent">Only Torrent</option>
</select>
</div>
</div>
<div class="form-group">
<div class="form-group x-usenet-delay">
<label class="col-sm-3 control-label">Usenet Delay</label>
<div class="col-sm-1 col-sm-push-5 help-inline">
@@ -36,7 +38,7 @@
</div>
</div>
<div class="form-group">
<div class="form-group x-torrent-delay">
<label class="col-sm-3 control-label">Torrent Delay</label>
<div class="col-sm-1 col-sm-push-5 help-inline">
@@ -49,7 +51,7 @@
</div>
{{#if_eq id compare="1"}}
<div class="alert alert-info" role="alert">The default Delay Profile applies to all series unless overridden by a Delay Profile attached to a matching tag</div>
<div class="alert alert-info" role="alert">This is the default profile. It applies to all series that don't have an explicit profile.</div>
{{else}}
<div class="form-group">
<label class="col-sm-3 control-label">Tags</label>
@@ -67,7 +69,9 @@
</div>
<div class="modal-footer">
{{#if id}}
<button class="btn btn-danger pull-left x-delete">delete</button>
{{#if_gt id compare="1"}}
<button class="btn btn-danger pull-left x-delete">delete</button>
{{/if_gt}}
{{/if}}
<span class="indicator x-indicator"><i class="icon-spinner icon-spin"></i></span>
<button class="btn" data-dismiss="modal">cancel</button>