Commit 29645f06 authored by Phil Hughes's avatar Phil Hughes

Hides/shows the boards sidebar

Rather than constructing & then deconstructing, we know just hide & show
the sidebar. This is done so we dont' have a memory leak on the frontend
with objects getting created.
parent 344154e9
...@@ -29,22 +29,8 @@ ...@@ -29,22 +29,8 @@
issue () { issue () {
if (this.showSidebar) { if (this.showSidebar) {
this.$nextTick(() => { this.$nextTick(() => {
this.issuableContext = new IssuableContext(this.currentUser); $(".right-sidebar").getNiceScroll(0).doScrollTop(0, 0);
this.milestoneSelect = new MilestoneSelect();
this.dueDateSelect = new gl.DueDateSelectors();
this.labelsSelect = new LabelsSelect();
this.sidebar = new Sidebar();
this.subscription = new Subscription('.subscription');
}); });
} else {
$('.right-sidebar').getNiceScroll().remove();
delete this.issuableContext;
delete this.milestoneSelect;
delete this.dueDateSelect;
delete this.labelsSelect;
delete this.sidebar;
delete this.subscription;
} }
} }
}, },
...@@ -52,6 +38,14 @@ ...@@ -52,6 +38,14 @@
closeSidebar () { closeSidebar () {
this.detail.issue = {}; this.detail.issue = {};
} }
},
ready () {
new IssuableContext(this.currentUser);
new MilestoneSelect();
new gl.DueDateSelectors();
new LabelsSelect();
new Sidebar();
new Subscription('.subscription');
} }
}); });
})(); })();
...@@ -41,7 +41,12 @@ ...@@ -41,7 +41,12 @@
defaultDate: $("input[name='" + this.fieldName + "']").val(), defaultDate: $("input[name='" + this.fieldName + "']").val(),
altField: "input[name='" + this.fieldName + "']", altField: "input[name='" + this.fieldName + "']",
onSelect: () => { onSelect: () => {
return this.saveDueDate(true); if (this.$dropdown.hasClass('js-issue-boards-due-date')) {
gl.issueBoards.BoardsStore.detail.issue.dueDate = $("input[name='" + this.fieldName + "']").val();
this.updateIssueBoardIssue();
} else {
return this.saveDueDate(true);
}
} }
}); });
} }
...@@ -49,8 +54,14 @@ ...@@ -49,8 +54,14 @@
initRemoveDueDate() { initRemoveDueDate() {
this.$block.on('click', '.js-remove-due-date', (e) => { this.$block.on('click', '.js-remove-due-date', (e) => {
e.preventDefault(); e.preventDefault();
$("input[name='" + this.fieldName + "']").val('');
return this.saveDueDate(false); if (this.$dropdown.hasClass('js-issue-boards-due-date')) {
gl.issueBoards.BoardsStore.detail.issue.dueDate = '';
this.updateIssueBoardIssue();
} else {
$("input[name='" + this.fieldName + "']").val('');
return this.saveDueDate(false);
}
}); });
} }
...@@ -83,6 +94,18 @@ ...@@ -83,6 +94,18 @@
this.datePayload = datePayload; this.datePayload = datePayload;
} }
updateIssueBoardIssue () {
this.$loading.fadeIn();
this.$dropdown.trigger('loading.gl.dropdown');
this.$selectbox.hide();
this.$value.css('display', '');
gl.issueBoards.BoardsStore.detail.issue.update(this.$dropdown.attr('data-issue-update'))
.then(() => {
this.$loading.fadeOut();
});
}
submitSelectedDate(isDropdown) { submitSelectedDate(isDropdown) {
return $.ajax({ return $.ajax({
type: 'PUT', type: 'PUT',
......
...@@ -382,7 +382,7 @@ ...@@ -382,7 +382,7 @@
$loading.fadeIn(); $loading.fadeIn();
gl.issueBoards.BoardsStore.detail.issue.update(issueUpdateURL) gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update'))
.then(function () { .then(function () {
$loading.fadeOut(); $loading.fadeOut();
}); });
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
$dropdown.trigger('loading.gl.dropdown'); $dropdown.trigger('loading.gl.dropdown');
$loading.fadeIn(); $loading.fadeIn();
gl.issueBoards.BoardsStore.detail.issue.update(issueUpdateURL) gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update'))
.then(function () { .then(function () {
$dropdown.trigger('loaded.gl.dropdown'); $dropdown.trigger('loaded.gl.dropdown');
$loading.fadeOut(); $loading.fadeOut();
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
function Subscription(container) { function Subscription(container) {
this.toggleSubscription = bind(this.toggleSubscription, this); this.toggleSubscription = bind(this.toggleSubscription, this);
var $container; var $container;
$container = $(container); this.$container = $(container);
this.url = $container.attr('data-url'); this.url = this.$container.attr('data-url');
this.subscribe_button = $container.find('.js-subscribe-button'); this.subscribe_button = this.$container.find('.js-subscribe-button');
this.subscription_status = $container.find('.subscription-status'); this.subscription_status = this.$container.find('.subscription-status');
this.subscribe_button.unbind('click').click(this.toggleSubscription); this.subscribe_button.unbind('click').click(this.toggleSubscription);
} }
...@@ -18,12 +18,17 @@ ...@@ -18,12 +18,17 @@
action = btn.find('span').text(); action = btn.find('span').text();
current_status = this.subscription_status.attr('data-status'); current_status = this.subscription_status.attr('data-status');
btn.addClass('disabled'); btn.addClass('disabled');
if ($('html').hasClass('issue-boards-page')) {
this.url = this.$container.attr('data-url');
}
return $.post(this.url, (function(_this) { return $.post(this.url, (function(_this) {
return function() { return function() {
var status; var status;
btn.removeClass('disabled'); btn.removeClass('disabled');
if ($('body').data('page') === 'projects:boards:show') { if ($('html').hasClass('issue-boards-page')) {
Vue.set(gl.issueBoards.BoardsStore.detail.issue, 'subscribed', !gl.issueBoards.BoardsStore.detail.issue.subscribed); Vue.set(gl.issueBoards.BoardsStore.detail.issue, 'subscribed', !gl.issueBoards.BoardsStore.detail.issue.subscribed);
} else { } else {
status = current_status === 'subscribed' ? 'unsubscribed' : 'subscribed'; status = current_status === 'subscribed' ? 'unsubscribed' : 'subscribed';
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
var updateIssueBoardsIssue = function () { var updateIssueBoardsIssue = function () {
$loading.fadeIn(); $loading.fadeIn();
gl.issueBoards.BoardsStore.detail.issue.update(issueURL) gl.issueBoards.BoardsStore.detail.issue.update($dropdown.attr('data-issue-update'))
.then(function () { .then(function () {
$loading.fadeOut(); $loading.fadeOut();
}); });
......
%board-sidebar{ "inline-template" => true, %board-sidebar{ "inline-template" => true,
":current-user" => "#{current_user.to_json(only: [:username, :id, :name], methods: [:avatar_url]) if current_user}" } ":current-user" => "#{current_user.to_json(only: [:username, :id, :name], methods: [:avatar_url]) if current_user}" }
%aside.right-sidebar.right-sidebar-expanded.issue-boards-sidebar{ "v-if" => "showSidebar" } %aside.right-sidebar.right-sidebar-expanded.issue-boards-sidebar{ "v-show" => "showSidebar" }
.issuable-sidebar .issuable-sidebar
.block.issuable-sidebar-header .block.issuable-sidebar-header
%span.issuable-header-text.hide-collapsed.pull-left %span.issuable-header-text.hide-collapsed.pull-left
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
No due date No due date
%span.bold{ "v-if" => "issue.dueDate" } %span.bold{ "v-if" => "issue.dueDate" }
{{ issue.dueDate | due-date }} {{ issue.dueDate | due-date }}
%span.no-value.js-remove-due-date-holder{ "v-if" => "issue.dueDate" } - if can?(current_user, :admin_issue, @project)
\- %span.no-value.js-remove-due-date-holder{ "v-if" => "issue.dueDate" }
%a.js-remove-due-date{ href: "#", role: "button" } \-
remove due date %a.js-remove-due-date{ href: "#", role: "button" }
remove due date
- if can?(current_user, :admin_issue, @project) - if can?(current_user, :admin_issue, @project)
.selectbox .selectbox
%input{ type: "hidden", %input{ type: "hidden",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- if can?(current_user, :admin_issue, @project) - if can?(current_user, :admin_issue, @project)
= link_to "Edit", "#", class: "edit-link pull-right" = link_to "Edit", "#", class: "edit-link pull-right"
.value.issuable-show-labels .value.issuable-show-labels
%span.no-value{ "v-if" => "issue.labels.length === 0" } %span.no-value{ "v-if" => "issue.labels && issue.labels.length === 0" }
None None
%a{ href: "#", %a{ href: "#",
"v-for" => "label in issue.labels" } "v-for" => "label in issue.labels" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment