import CommentFormView from './views/comment-form-view';
import PlanFormView from './views/plan-form-view';
import SetSeverityFormView from './views/set-severity-form-view';
+import MoreActionsView from './views/more-actions-view';
import TagsFormView from './views/tags-form-view';
import Workspace from 'components/workspace/main';
import './templates';
'click .js-issue-assign-to-me': 'assignToMe',
'click .js-issue-plan': 'plan',
'click .js-issue-show-changelog': 'showChangeLog',
+ 'click .js-issue-more': 'showMoreActions',
'click .js-issue-rule': 'showRule',
'click .js-issue-edit-tags': 'editTags',
'click .js-issue-locations': 'showLocations'
RealWorkspace.openRule({ key: ruleKey });
},
+ showMoreActions: function (e) {
+ e.stopPropagation();
+ $('body').click();
+ this.popup = new MoreActionsView({
+ triggerEl: $(e.currentTarget),
+ bottomRight: true,
+ model: this.model,
+ detailView: this
+ });
+ this.popup.render();
+ },
+
+ action: function (action) {
+ var that = this;
+ this.disableControls();
+ return this.model.customAction(action)
+ .done(function () {
+ that.updateAfterAction(true);
+ })
+ .fail(function () {
+ that.enableControls();
+ });
+ },
+
editTags: function (e) {
e.stopPropagation();
$('body').click();
});
},
+
+ /**
+ * Do a custom (plugin) action
+ * @param {String} actionKey Action Key
+ * @param {Object|null} options Options for jQuery ajax
+ * @returns {jqXHR}
+ */
+ customAction: function (actionKey, options) {
+ var opts = _.extend({
+ url: this.urlRoot() + '/do_action',
+ data: { issue: this.id, actionKey: actionKey }
+ }, options);
+ return this._action(opts);
+ },
+
getLinearLocations: function () {
var textRange = this.get('textRange');
if (!textRange) {
--- /dev/null
+<ul class="menu">
+ {{#pluginActions actions}}
+ <li>
+ <a class="issue-action js-issue-action" href="#" data-action="{{this}}">{{t "issue.action" this "formlink"}}</a>
+ </li>
+ {{/pluginActions}}
+</ul>
+
+<div class="bubble-popup-arrow"></div>
class="issue-meta-label">{{t 'issue.comment.formlink' }}</span></button>
</li>
{{/inArray}}
+
+ {{#ifHasExtraActions actions}}
+ <li class="issue-meta">
+ <button class="button-link issue-action issue-action-with-options js-issue-more">
+ <span class="issue-meta-label">{{t 'more'}}</span> <i class="icon-dropdown"></i>
+ </button>
+ </li>
+ {{/ifHasExtraActions}}
</ul>
{{#inArray actions "assign_to_me"}}
import $ from 'jquery';
-import PopupView from 'components/common/popup';
+import ActionOptionsView from 'components/common/action-options-view';
import '../templates';
-export default PopupView.extend({
+export default ActionOptionsView.extend({
template: Templates['issue-more-actions'],
- events: function () {
- return {
- 'click .js-issue-action': 'action'
- };
+ selectOption: function (e) {
+ var action = $(e.currentTarget).data('action');
+ this.submit(action);
+ return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- action: function (e) {
- var actionKey = $(e.currentTarget).data('action');
+ submit: function (actionKey) {
return this.options.detailView.action(actionKey);
}
});
(function () {
+ var defaultActions = ['comment', 'assign', 'assign_to_me', 'plan', 'set_severity', 'set_tags'];
+
Handlebars.registerHelper('log', function () {
/* eslint no-console: 0 */
var args = Array.prototype.slice.call(arguments, 0, -1);
return numeral(number).format(format);
});
+ Handlebars.registerHelper('pluginActions', function (actions, options) {
+ var pluginActions = _.difference(actions, defaultActions);
+ return pluginActions.reduce(function (prev, current) {
+ return prev + options.fn(current);
+ }, '');
+ });
+
+ Handlebars.registerHelper('ifHasExtraActions', function (actions, options) {
+ var actionsLeft = _.difference(actions, defaultActions);
+ if (actionsLeft.length > 0) {
+ return options.fn(this);
+ } else {
+ return options.inverse(this);
+ }
+ });
+
Handlebars.registerHelper('withFirst', function (list, options) {
if (list && list.length > 0) {
return options.fn(list[0]);