From 3f0600fed70512f87dc20fe039695d1681a73d39 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Sat, 17 Aug 2019 19:17:57 -0400 Subject: Add Feature: enable two-way webhooks - stage one --- client/components/sidebar/sidebar.jade | 36 ++++++++------ client/components/sidebar/sidebar.js | 86 ++++++++++++++++++++++------------ 2 files changed, 78 insertions(+), 44 deletions(-) (limited to 'client/components/sidebar') diff --git a/client/components/sidebar/sidebar.jade b/client/components/sidebar/sidebar.jade index 2dfe41b3..ccfadc0c 100644 --- a/client/components/sidebar/sidebar.jade +++ b/client/components/sidebar/sidebar.jade @@ -135,22 +135,30 @@ template(name="archiveBoardPopup") template(name="outgoingWebhooksPopup") each integrations form.integration-form - if title - h4 {{title}} - else - h4 {{_ 'no-name'}} - label - | URL - input.js-outgoing-webhooks-url(type="text" name="url" value=url) - input(type="hidden" value=_id name="id") + a.flex + span {{_ 'disable-webhook'}} + b   + .materialCheckBox(class="{{#unless enabled}}is-checked{{/unless}}") + input.js-outgoing-webhooks-title(placeholder="{{_ 'webhook-title'}}" type="text" name="title" value=title) + input.js-outgoing-webhooks-url(type="text" name="url" value=url autofocus) + input.js-outgoing-webhooks-token(placeholder="{{_ 'webhook-token' }}" type="text" value=token name="token") + select.js-outgoing-webhooks-type(name="type") + each _type in types + if($eq _type this.type) + option(value=_type selected="selected") {{_ _type}} + else + option(value=_type) {{_ _type}} + input(type="hidden" value=this.type name="_type") + input(type="hidden" value=_id name="id") input.primary.wide(type="submit" value="{{_ 'save'}}") form.integration-form - h4 - | {{_ 'new-outgoing-webhook'}} - label - | URL - input.js-outgoing-webhooks-url(type="text" name="url" autofocus) - input.primary.wide(type="submit" value="{{_ 'save'}}") + input.js-outgoing-webhooks-title(placeholder="{{_ 'webhook-title'}}" type="text" name="title" autofocus) + input.js-outgoing-webhooks-url(placeholder="{{_ 'URL' }}" type="text" name="url") + input.js-outgoing-webhooks-token(placeholder="{{_ 'webhook-token' }}" type="text" name="token") + select.js-outgoing-webhooks-type(name="type") + each _type in types + option(value=_type) {{_ _type}} + input.primary.wide(type="submit" value="{{_ 'create'}}") template(name="boardMenuPopup") ul.pop-over-list diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index f7efb1e8..f1ccfb1e 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -1,6 +1,8 @@ Sidebar = null; const defaultView = 'home'; +const MCB = '.materialCheckBox'; +const CKCLS = 'is-checked'; const viewTitles = { filter: 'filter-cards', @@ -280,44 +282,71 @@ Template.membersWidget.events({ }); BlazeComponent.extendComponent({ + boardId() { + return Session.get('currentBoard') || Integrations.Const.GLOBAL_WEBHOOK_ID; + }, integrations() { - const boardId = Session.get('currentBoard'); + const boardId = this.boardId(); return Integrations.find({ boardId: `${boardId}` }).fetch(); }, - - integration(id) { - const boardId = Session.get('currentBoard'); - return Integrations.findOne({ _id: id, boardId: `${boardId}` }); + types() { + return Integrations.Const.WEBHOOK_TYPES; + }, + integration(cond) { + const boardId = this.boardId(); + const condition = { boardId, ...cond }; + for (const k in condition) { + if (!condition[k]) delete condition[k]; + } + return Integrations.findOne(condition); + }, + onCreated() { + this.disabled = new ReactiveVar(false); }, - events() { return [ { + 'click a.flex'(evt) { + this.disabled.set(!this.disabled.get()); + $(evt.target).toggleClass(CKCLS, this.disabled.get()); + }, submit(evt) { evt.preventDefault(); const url = evt.target.url.value; - const boardId = Session.get('currentBoard'); + const boardId = this.boardId(); let id = null; let integration = null; + const title = evt.target.title.value; + const token = evt.target.token.value; + const type = evt.target.type.value; + const enabled = !this.disabled.get(); + let remove = false; + const values = { + url, + type, + token, + title, + enabled, + }; if (evt.target.id) { id = evt.target.id.value; - integration = this.integration(id); - if (url) { - Integrations.update(integration._id, { - $set: { - url: `${url}`, - }, - }); - } else { - Integrations.remove(integration._id); - } + integration = this.integration({ _id: id }); + remove = !url; + } else if (url) { + integration = this.integration({ url, token }); + } + if (remove) { + Integrations.remove(integration._id); + } else if (integration && integration._id) { + Integrations.update(integration._id, { + $set: values, + }); } else if (url) { Integrations.insert({ + ...values, userId: Meteor.userId(), enabled: true, - type: 'outgoing-webhooks', - url: `${url}`, - boardId: `${boardId}`, + boardId, activities: ['all'], }); } @@ -474,12 +503,12 @@ BlazeComponent.extendComponent({ evt.preventDefault(); this.currentBoard.allowsSubtasks = !this.currentBoard.allowsSubtasks; this.currentBoard.setAllowsSubtasks(this.currentBoard.allowsSubtasks); - $('.js-field-has-subtasks .materialCheckBox').toggleClass( - 'is-checked', + $(`.js-field-has-subtasks ${MCB}`).toggleClass( + CKCLS, this.currentBoard.allowsSubtasks, ); $('.js-field-has-subtasks').toggleClass( - 'is-checked', + CKCLS, this.currentBoard.allowsSubtasks, ); $('.js-field-deposit-board').prop( @@ -515,15 +544,12 @@ BlazeComponent.extendComponent({ ]; options.forEach(function(element) { if (element !== value) { - $(`#${element} .materialCheckBox`).toggleClass( - 'is-checked', - false, - ); - $(`#${element}`).toggleClass('is-checked', false); + $(`#${element} ${MCB}`).toggleClass(CKCLS, false); + $(`#${element}`).toggleClass(CKCLS, false); } }); - $(`#${value} .materialCheckBox`).toggleClass('is-checked', true); - $(`#${value}`).toggleClass('is-checked', true); + $(`#${value} ${MCB}`).toggleClass(CKCLS, true); + $(`#${value}`).toggleClass(CKCLS, true); this.currentBoard.setPresentParentTask(value); evt.preventDefault(); }, -- cgit v1.2.3-1-g7c22 From 7d6d3af54a2fc1fb68634725eb754b22f02fd430 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 29 Oct 2019 19:05:44 +0200 Subject: Add Features: allowing lists to be sorted by modifiedAt when not in draggable mode. Bug Fix #2093: the broken should be prior to file attachment feature introduced, and tested export board is working. Thanks to whowillcare ! ( xet7 merged this pull request manually from https://github.com/wekan/wekan/pull/2756 ) Closes #2093 --- client/components/sidebar/sidebarFilters.jade | 4 ++++ client/components/sidebar/sidebarFilters.js | 4 ++++ client/components/sidebar/sidebarSearches.jade | 4 ++++ client/components/sidebar/sidebarSearches.js | 5 +++++ 4 files changed, 17 insertions(+) (limited to 'client/components/sidebar') diff --git a/client/components/sidebar/sidebarFilters.jade b/client/components/sidebar/sidebarFilters.jade index 55ab213a..5f929cb9 100644 --- a/client/components/sidebar/sidebarFilters.jade +++ b/client/components/sidebar/sidebarFilters.jade @@ -4,6 +4,10 @@ and #each x in y constructors to fix this. template(name="filterSidebar") + ul.sidebar-list + span {{_ 'list-filter-label'}} + form.js-list-filter + input(type="text") ul.sidebar-list li(class="{{#if Filter.labelIds.isSelected undefined}}active{{/if}}") a.name.js-toggle-label-filter diff --git a/client/components/sidebar/sidebarFilters.js b/client/components/sidebar/sidebarFilters.js index 3483d00c..ee0176b9 100644 --- a/client/components/sidebar/sidebarFilters.js +++ b/client/components/sidebar/sidebarFilters.js @@ -4,6 +4,10 @@ BlazeComponent.extendComponent({ events() { return [ { + 'submit .js-list-filter'(evt) { + evt.preventDefault(); + Filter.lists.set(this.find('.js-list-filter input').value.trim()); + }, 'click .js-toggle-label-filter'(evt) { evt.preventDefault(); Filter.labelIds.toggle(this.currentData()._id); diff --git a/client/components/sidebar/sidebarSearches.jade b/client/components/sidebar/sidebarSearches.jade index 96877c50..4ee7fc9c 100644 --- a/client/components/sidebar/sidebarSearches.jade +++ b/client/components/sidebar/sidebarSearches.jade @@ -2,6 +2,10 @@ template(name="searchSidebar") form.js-search-term-form input(type="text" name="searchTerm" placeholder="{{_ 'search-example'}}" autofocus dir="auto") .list-body.js-perfect-scrollbar + .minilists.clearfix.js-minilists + each (lists) + a.minilist-wrapper.js-minilist(href=absoluteUrl) + +minilist(this) .minicards.clearfix.js-minicards each (results) a.minicard-wrapper.js-minicard(href=absoluteUrl) diff --git a/client/components/sidebar/sidebarSearches.js b/client/components/sidebar/sidebarSearches.js index 8944c04e..02677260 100644 --- a/client/components/sidebar/sidebarSearches.js +++ b/client/components/sidebar/sidebarSearches.js @@ -8,6 +8,11 @@ BlazeComponent.extendComponent({ return currentBoard.searchCards(this.term.get()); }, + lists() { + const currentBoard = Boards.findOne(Session.get('currentBoard')); + return currentBoard.searchLists(this.term.get()); + }, + events() { return [ { -- cgit v1.2.3-1-g7c22 From 96abe3c6914ce37d9fb44da8fda375e40ad65c9e Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 18 Nov 2019 22:23:49 +0200 Subject: New feature: Now there is popup selection of Lists/Swimlanes/Calendar/Roles. New feature, not set visible yet, because switching to it does not work properly yet: Collapsible Swimlanes #2804 Fix: Public board now loads correctly. When you select one of Lists/Swimlanes/Calendar view and reload webbrowser page, it can change view. Closes #2311 Fix: List sorting commented out. Closes #2800 Fix: Errors hasHiddenMinicardText, hasShowDragHandles, showSort, hasSortBy, profile, FirefoxAndroid/IE11/Vivaldi/Chromium browsers not working by using cookies instead of database. More details at https://github.com/wekan/wekan/issues/2643#issuecomment-554907955 Note: Cookie changes are not always immediate, if there is no effect, you may need to reload webbrowser page. Closes #2643 . Thanks to xet7 ! --- client/components/sidebar/sidebar.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'client/components/sidebar') diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index f1ccfb1e..4b918d54 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -107,7 +107,13 @@ BlazeComponent.extendComponent({ 'click .js-toggle-sidebar': this.toggle, 'click .js-back-home': this.setView, 'click .js-toggle-minicard-label-text'() { - Meteor.call('toggleMinicardLabelText'); + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + if (cookies.has('hiddenMinicardLabelText')) { + cookies.remove('hiddenMinicardLabelText'); //true + } else { + cookies.set('hiddenMinicardLabelText', 'true'); //true + } }, 'click .js-shortcuts'() { FlowRouter.go('shortcuts'); @@ -121,7 +127,13 @@ Blaze.registerHelper('Sidebar', () => Sidebar); Template.homeSidebar.helpers({ hiddenMinicardLabelText() { - return Meteor.user().hasHiddenMinicardLabelText(); + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + if (cookies.has('hiddenMinicardLabelText')) { + return true; + } else { + return false; + } }, }); -- cgit v1.2.3-1-g7c22 From 351d4767d7e93c90ac798769d6071da8730d834f Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Tue, 19 Nov 2019 14:09:36 +0200 Subject: When logged in, use database for setting, so that changes are immediate. Only on public board use cookies. Comment out Collapse CSS that is not in use. Thanks to xet7 ! --- client/components/sidebar/sidebar.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'client/components/sidebar') diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 4b918d54..6bb22f39 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -107,12 +107,17 @@ BlazeComponent.extendComponent({ 'click .js-toggle-sidebar': this.toggle, 'click .js-back-home': this.setView, 'click .js-toggle-minicard-label-text'() { - import { Cookies } from 'meteor/ostrio:cookies'; - const cookies = new Cookies(); - if (cookies.has('hiddenMinicardLabelText')) { - cookies.remove('hiddenMinicardLabelText'); //true + currentUser = Meteor.user(); + if (currentUser) { + Meteor.call('toggleMinicardLabelText'); } else { - cookies.set('hiddenMinicardLabelText', 'true'); //true + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + if (cookies.has('hiddenMinicardLabelText')) { + cookies.remove('hiddenMinicardLabelText'); + } else { + cookies.set('hiddenMinicardLabelText', 'true'); + } } }, 'click .js-shortcuts'() { @@ -127,12 +132,17 @@ Blaze.registerHelper('Sidebar', () => Sidebar); Template.homeSidebar.helpers({ hiddenMinicardLabelText() { - import { Cookies } from 'meteor/ostrio:cookies'; - const cookies = new Cookies(); - if (cookies.has('hiddenMinicardLabelText')) { - return true; + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).hiddenMinicardLabelText; } else { - return false; + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + if (cookies.has('hiddenMinicardLabelText')) { + return true; + } else { + return false; + } } }, }); -- cgit v1.2.3-1-g7c22