diff options
| -rw-r--r-- | client/html/compact_metric_list_item.tpl | 8 | ||||
| -rw-r--r-- | client/js/controls/post_edit_sidebar_control.js | 13 | ||||
| -rw-r--r-- | client/js/controls/post_metric_input_control.js | 11 | ||||
| -rw-r--r-- | client/js/controls/post_readonly_sidebar_control.js | 9 | ||||
| -rw-r--r-- | client/js/views/post_main_view.js | 4 |
5 files changed, 29 insertions, 16 deletions
diff --git a/client/html/compact_metric_list_item.tpl b/client/html/compact_metric_list_item.tpl index ebca9af..5f2ae36 100644 --- a/client/html/compact_metric_list_item.tpl +++ b/client/html/compact_metric_list_item.tpl @@ -15,8 +15,12 @@ --><span class='metric-bounds' data-pseudo-content= '<%- ctx.tag.metric.min %> — <%- ctx.tag.metric.max %>'></span><!-- --><span class='metric-controls'>Set<!-- - --> <a href class='create-exact'>exact</a><!-- - --> <a href class='create-range'>range</a><!-- + --><a href class='create-exact'> exact</a><!-- + --><a href class='create-range'> range</a><!-- + --><a href='<%= ctx.getMetricSorterUrl(ctx.post.id, { + metrics: ctx.tag.names[0], + query: ctx.query}) %>' + class='sort'> sort</a><!-- --></span><!-- --><% } %><!-- --></li> diff --git a/client/js/controls/post_edit_sidebar_control.js b/client/js/controls/post_edit_sidebar_control.js index 4088d8a..fb06406 100644 --- a/client/js/controls/post_edit_sidebar_control.js +++ b/client/js/controls/post_edit_sidebar_control.js @@ -15,10 +15,11 @@ const FileDropperControl = require('../controls/file_dropper_control.js'); const template = views.getTemplate('post-edit-sidebar'); class PostEditSidebarControl extends events.EventTarget { - constructor(hostNode, post, postContentControl, postNotesOverlayControl) { + constructor(hostNode, ctx, postContentControl, postNotesOverlayControl) { super(); this._hostNode = hostNode; - this._post = post; + this._ctx = ctx; + this._post = ctx.post; this._postContentControl = postContentControl; this._postNotesOverlayControl = postNotesOverlayControl; this._newPostContent = null; @@ -35,8 +36,8 @@ class PostEditSidebarControl extends events.EventTarget { canEditPostMetrics: api.hasPrivilege('metrics:edit:posts'), canEditPostRelations: api.hasPrivilege('posts:edit:relations'), canEditPostNotes: api.hasPrivilege('posts:edit:notes') && - post.type !== 'video' && - post.type !== 'flash', + this._post.type !== 'video' && + this._post.type !== 'flash', canEditPostFlags: api.hasPrivilege('posts:edit:flags'), canEditPostContent: api.hasPrivilege('posts:edit:content'), canEditPostThumbnail: api.hasPrivilege('posts:edit:thumbnail'), @@ -79,12 +80,12 @@ class PostEditSidebarControl extends events.EventTarget { if (this._tagInputNode) { this._tagControl = new TagInputControl( - this._tagInputNode, post.tags); + this._tagInputNode, this._post.tags); } if (this._metricInputNode) { this._metricControl = new PostMetricInputControl( - this._metricInputNode, post); + this._metricInputNode, this._ctx); } if (this._contentInputNode) { diff --git a/client/js/controls/post_metric_input_control.js b/client/js/controls/post_metric_input_control.js index 42b78d6..45b6b24 100644 --- a/client/js/controls/post_metric_input_control.js +++ b/client/js/controls/post_metric_input_control.js @@ -12,9 +12,10 @@ const postMetricNodeTemplate = views.getTemplate('compact-post-metric-list-item' const postMetricRangeNodeTemplate = views.getTemplate('compact-post-metric-range-list-item'); class PostMetricInputControl extends events.EventTarget { - constructor(hostNode, post) { + constructor(hostNode, ctx) { super(); - this._post = post; + this._ctx = ctx; + this._post = ctx.post; this._hostNode = hostNode; // dom @@ -59,6 +60,8 @@ class PostMetricInputControl extends events.EventTarget { const node = metricNodeTemplate({ editMode: true, tag: tag, + post: this._post, + query: this._ctx.parameters.query, }); const createExactNode = node.querySelector('a.create-exact'); if (this._post.metrics.hasTagName(tag.names[0])) { @@ -78,6 +81,10 @@ class PostMetricInputControl extends events.EventTarget { this.createPostMetricRange(tag); }); } + const sortNode = node.querySelector('a.sort'); + if (this._post.metrics.hasTagName(tag.names[0])) { + sortNode.style.display = 'none'; + } return node; } diff --git a/client/js/controls/post_readonly_sidebar_control.js b/client/js/controls/post_readonly_sidebar_control.js index 4b7e3bf..62bfd79 100644 --- a/client/js/controls/post_readonly_sidebar_control.js +++ b/client/js/controls/post_readonly_sidebar_control.js @@ -11,14 +11,15 @@ const scoreTemplate = views.getTemplate('score'); const favTemplate = views.getTemplate('fav'); class PostReadonlySidebarControl extends events.EventTarget { - constructor(hostNode, post, postContentControl) { + constructor(hostNode, ctx, postContentControl) { super(); this._hostNode = hostNode; - this._post = post; + this._ctx = ctx; + this._post = ctx.post; this._postContentControl = postContentControl; - post.addEventListener('changeFavorite', e => this._evtChangeFav(e)); - post.addEventListener('changeScore', e => this._evtChangeScore(e)); + this._post.addEventListener('changeFavorite', e => this._evtChangeFav(e)); + this._post.addEventListener('changeScore', e => this._evtChangeScore(e)); views.replaceContent(this._hostNode, template({ post: this._post, diff --git a/client/js/views/post_main_view.js b/client/js/views/post_main_view.js index 71a7900..fbaabd2 100644 --- a/client/js/views/post_main_view.js +++ b/client/js/views/post_main_view.js @@ -116,12 +116,12 @@ class PostMainView { if (ctx.editMode) { this.sidebarControl = new PostEditSidebarControl( sidebarContainerNode, - ctx.post, + ctx, this._postContentControl, this._postNotesOverlayControl); } else { this.sidebarControl = new PostReadonlySidebarControl( - sidebarContainerNode, ctx.post, this._postContentControl); + sidebarContainerNode, ctx, this._postContentControl); } } |