diff options
24 files changed, 492 insertions, 165 deletions
diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index bf36da7d..c4fc303f 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -109,7 +109,7 @@ BlazeComponent.extendComponent({ Sidebar.setView('search'); }, 'click .js-open-rules-view'() { - Modal.open('rules'); + Modal.open('rulesMain'); }, 'click .js-multiselection-activate'() { const currentCard = Session.get('currentCard'); diff --git a/client/components/forms/forms.styl b/client/components/forms/forms.styl index 0a905943..4fff1e02 100644 --- a/client/components/forms/forms.styl +++ b/client/components/forms/forms.styl @@ -1,5 +1,6 @@ @import 'nib' +select, textarea, input:not([type=file]), button diff --git a/client/components/rules/.DS_Store b/client/components/rules/.DS_Store Binary files differnew file mode 100644 index 00000000..5008ddfc --- /dev/null +++ b/client/components/rules/.DS_Store diff --git a/client/components/rules/actions/boardActions.jade b/client/components/rules/actions/boardActions.jade new file mode 100644 index 00000000..fe56c3ee --- /dev/null +++ b/client/components/rules/actions/boardActions.jade @@ -0,0 +1,22 @@ +template(name="boardActions") + div.trigger-item + div.trigger-content + div.trigger-text + | Move card to + div.trigger-dropdown + select(id="action") + option(value="top") Top of + option(value="bottom") Bottom of + div.trigger-text + | list + div.trigger-dropdown + input(type=text,placeholder="List Name") + div.trigger-button.js-add-move-action.js-goto-rules + i.fa.fa-plus + + + + + + + diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js new file mode 100644 index 00000000..53325ca0 --- /dev/null +++ b/client/components/rules/actions/boardActions.js @@ -0,0 +1,32 @@ +BlazeComponent.extendComponent({ + onCreated() { + + }, + + + + events() { + return [ + {'click .js-add-move-action'(event) { + + console.log(this.data()); + console.log(this.data().triggerIdVar.get()); + const ruleName = this.data().ruleName.get(); + const triggerId = this.data().triggerIdVar.get(); + const actionSelected = this.find('#action').value; + + if(actionSelected == "top"){ + Actions.insert({actionType: "moveCardToTop"},function(err,id){ + Rules.insert({title: ruleName, triggerId: triggerId, actionId: id}); + }); + } + if(actionSelected == "bottom"){ + Actions.insert({actionType: "moveCardToBottom"},function(err,id){ + Rules.insert({title: ruleName, triggerId: triggerId, actionId: id}); + }); + } + }, + }]; +}, + +}).register('boardActions');
\ No newline at end of file diff --git a/client/components/rules/rules.jade b/client/components/rules/rules.jade deleted file mode 100644 index 46c69a8d..00000000 --- a/client/components/rules/rules.jade +++ /dev/null @@ -1,65 +0,0 @@ -template(name="rules") - if rulesListVar.get - +rulesList - else if rulesTriggerVar.get - +rulesTrigger - -template(name="rulesList") - .rules - h2 - i.fa.fa-cutlery - | Project rules - - ul.rules-list - each rules - li.rules-lists-item - p - = title - div.rules-btns-group - button - i.fa.fa-eye - | View rule - button.js-delete-rule - i.fa.fa-trash-o - | Delete rule - else - li.no-items-message No rules - div.rules-add - button.js-add-rule - i.fa.fa-plus - | Add rule - input(type=text,placeholder="New rule name",id="ruleTitle") - -template(name="rulesTrigger") - h2 - i.fa.fa-cutlery - | Rule "#{ruleName.get}"" - Add triggers - .triggers-content - .triggers-body - .triggers-side-menu - ul - li.active - i.fa.fa-columns - li - i.fa.fa-sticky-note - li - i.fa.fa-check - .triggers-main-body - +boardTriggers - -template(name="boardTriggers") - div.trigger-item - div.trigger-content - div.trigger-text - | When a card is - div.trigger-dropdown - select - div.trigger-button - i.fa.fa-plus - - - - - - - diff --git a/client/components/rules/rules.js b/client/components/rules/rules.js deleted file mode 100644 index 9bca3460..00000000 --- a/client/components/rules/rules.js +++ /dev/null @@ -1,47 +0,0 @@ -BlazeComponent.extendComponent({ - onCreated() { - this.rulesListVar = new ReactiveVar(true); - this.rulesTriggerVar = new ReactiveVar(false); - this.ruleName = new ReactiveVar(""); - }, - - setTrigger() { - this.rulesListVar.set(false); - this.rulesTriggerVar.set(true); - }, - - events() { - return [{'click .js-delete-rule'(event) { - const rule = this.currentData(); - Rules.remove(rule._id); - - }, - 'click .js-add-rule'(event) { - - event.preventDefault(); - const ruleTitle = this.find('#ruleTitle').value; - Rules.insert({title: ruleTitle}); - this.find('#ruleTitle').value = ""; - this.ruleName.set(ruleTitle) - this.setTrigger(); - - }}]; - }, - -}).register('rules'); - - -BlazeComponent.extendComponent({ - onCreated() { - this.subscribe('allRules'); - }, - - rules() { - return Rules.find({}); - }, - events() { - return [{}]; - }, -}).register('rulesList'); - - diff --git a/client/components/rules/rules.styl b/client/components/rules/rules.styl index 48a175a5..35fbabb2 100644 --- a/client/components/rules/rules.styl +++ b/client/components/rules/rules.styl @@ -49,10 +49,11 @@ height 100% .triggers-side-menu - background-color: #f7f7f7; - border: 1px solid #f0f0f0; - border-radius: 4px; - box-shadow: inset -1px -1px 3px rgba(0,0,0,.05); + background-color: #f7f7f7 + border: 1px solid #f0f0f0 + border-radius: 4px + height: intrinsic + box-shadow: inset -1px -1px 3px rgba(0,0,0,.05) ul @@ -93,7 +94,8 @@ .trigger-item overflow:auto padding:10px - height:30px + height:40px + margin-bottom:5px border-radius: 3px position: relative background-color: white @@ -111,24 +113,31 @@ width:100px height:30px margin:0px + margin-left:5px + input + display: inline-block + width: 80px; + margin: 0; .trigger-button position:absolute top:50% transform: translateY(-50%) width:30px height:30px - border: 1px solid #eee; - border-radius: 4px; - box-shadow: inset -1px -1px 3px rgba(0,0,0,.05); + border: 1px solid #eee + border-radius: 4px + box-shadow: inset -1px -1px 3px rgba(0,0,0,.05) text-align:center font-size: 20px right:10px i - position: absolute; - top: 50%; - left: 50%; + position: absolute + top: 50% + left: 50% box-shadow: none - transform: translate(-50%,-50%); + transform: translate(-50%,-50%) + &:hover, &.is-active + box-shadow: 0 0 0 2px darken(white, 60%) inset diff --git a/client/components/rules/rulesActions.jade b/client/components/rules/rulesActions.jade new file mode 100644 index 00000000..0e207495 --- /dev/null +++ b/client/components/rules/rulesActions.jade @@ -0,0 +1,17 @@ +template(name="rulesActions") + h2 + i.fa.fa-cutlery + | Rule "#{data.ruleName}" - Add action + .triggers-content + .triggers-body + .triggers-side-menu + ul + li.active.js-set-board-triggers + i.fa.fa-columns + li.js-set-card-triggers + i.fa.fa-sticky-note + li.js-set-checklist-triggers + i.fa.fa-check + .triggers-main-body + if showBoardActions.get + +boardActions(ruleName=data.ruleName triggerIdVar=data.triggerIdVar)
\ No newline at end of file diff --git a/client/components/rules/rulesActions.js b/client/components/rules/rulesActions.js new file mode 100644 index 00000000..297fc806 --- /dev/null +++ b/client/components/rules/rulesActions.js @@ -0,0 +1,52 @@ +BlazeComponent.extendComponent({ + onCreated() { + this.showBoardActions = new ReactiveVar(true); + this.showCardActions = new ReactiveVar(false); + this.showChecklistAction = new ReactiveVar(false); + }, + + + setBoardTriggers(){ + this.showBoardActions.set(true); + this.showCardActions.set(false); + this.showChecklistActionsr.set(false); + $('.js-set-card-triggers').removeClass('active'); + $('.js-set-board-triggers').addClass('active'); + $('.js-set-checklist-triggers').removeClass('active'); + }, + setCardTriggers(){ + this.showBoardActions.set(false); + this.showCardActions.set(true); + this.showChecklistActions.set(false); + $('.js-set-card-triggers').addClass('active'); + $('.js-set-board-triggers').removeClass('active'); + $('.js-set-checklist-triggers').removeClass('active'); + }, + setChecklistTriggers(){ + this.showBoardActions.set(false); + this.showCardActions.set(false); + this.showChecklistActions.set(true); + $('.js-set-card-triggers').removeClass('active'); + $('.js-set-board-triggers').removeClass('active'); + $('.js-set-checklist-triggers').addClass('active'); + }, + + rules() { + return Rules.find({}); + }, + + name(){ + console.log(this.data()); + }, + events() { + return [{'click .js-set-board-triggers'(event) { + this.setBoardTriggers(); + }, + 'click .js-set-card-triggers'(event) { + this.setCardTriggers(); + }, + 'click .js-set-checklist-triggers'(event) { + this.setChecklistTriggers(); + },}]; + }, +}).register('rulesActions');
\ No newline at end of file diff --git a/client/components/rules/rulesList.jade b/client/components/rules/rulesList.jade new file mode 100644 index 00000000..a0d8143c --- /dev/null +++ b/client/components/rules/rulesList.jade @@ -0,0 +1,25 @@ +template(name="rulesList") + .rules + h2 + i.fa.fa-cutlery + | Project rules + + ul.rules-list + each rules + li.rules-lists-item + p + = title + div.rules-btns-group + button + i.fa.fa-eye + | View rule + button.js-delete-rule + i.fa.fa-trash-o + | Delete rule + else + li.no-items-message No rules + div.rules-add + button.js-goto-trigger + i.fa.fa-plus + | Add rule + input(type=text,placeholder="New rule name",id="ruleTitle")
\ No newline at end of file diff --git a/client/components/rules/rulesList.js b/client/components/rules/rulesList.js new file mode 100644 index 00000000..caafe29f --- /dev/null +++ b/client/components/rules/rulesList.js @@ -0,0 +1,12 @@ +BlazeComponent.extendComponent({ + onCreated() { + this.subscribe('allRules'); + }, + + rules() { + return Rules.find({}); + }, + events() { + return [{}]; + }, +}).register('rulesList');
\ No newline at end of file diff --git a/client/components/rules/rulesMain.jade b/client/components/rules/rulesMain.jade new file mode 100644 index 00000000..8e0efd63 --- /dev/null +++ b/client/components/rules/rulesMain.jade @@ -0,0 +1,7 @@ +template(name="rulesMain") + if rulesListVar.get + +rulesList + else if rulesTriggerVar.get + +rulesTriggers(ruleName=ruleName triggerIdVar=triggerIdVar) + else if rulesActionVar.get + +rulesActions(ruleName=ruleName triggerIdVar=triggerIdVar)
\ No newline at end of file diff --git a/client/components/rules/rulesMain.js b/client/components/rules/rulesMain.js new file mode 100644 index 00000000..c7e10512 --- /dev/null +++ b/client/components/rules/rulesMain.js @@ -0,0 +1,62 @@ +BlazeComponent.extendComponent({ + onCreated() { + this.rulesListVar = new ReactiveVar(true); + this.rulesTriggerVar = new ReactiveVar(false); + this.rulesActionVar = new ReactiveVar(false); + this.ruleName = new ReactiveVar(""); + this.triggerIdVar = new ReactiveVar(""); + }, + + setTrigger() { + this.rulesListVar.set(false); + this.rulesTriggerVar.set(true); + this.rulesActionVar.set(false); + }, + + setRulesList() { + this.rulesListVar.set(true); + this.rulesTriggerVar.set(false); + this.rulesActionVar.set(false); + }, + + setAction() { + this.rulesListVar.set(false); + this.rulesTriggerVar.set(false); + this.rulesActionVar.set(true); + }, + + events() { + return [{'click .js-delete-rule'(event) { + const rule = this.currentData(); + Rules.remove(rule._id); + + }, + 'click .js-goto-trigger'(event) { + event.preventDefault(); + const ruleTitle = this.find('#ruleTitle').value; + this.find('#ruleTitle').value = ""; + this.ruleName.set(ruleTitle) + this.setTrigger(); + }, + 'click .js-goto-action'(event) { + event.preventDefault(); + this.setAction(); + }, + 'click .js-goto-rules'(event) { + event.preventDefault(); + this.setRulesList(); + }, + + + }]; + }, + +}).register('rulesMain'); + + + + + + + + diff --git a/client/components/rules/rulesTriggers.jade b/client/components/rules/rulesTriggers.jade new file mode 100644 index 00000000..5ee563e0 --- /dev/null +++ b/client/components/rules/rulesTriggers.jade @@ -0,0 +1,21 @@ +template(name="rulesTriggers") + h2 + i.fa.fa-cutlery + | Rule "#{data.ruleName}" - Add trigger + .triggers-content + .triggers-body + .triggers-side-menu + ul + li.active.js-set-board-triggers + i.fa.fa-columns + li.js-set-card-triggers + i.fa.fa-sticky-note + li.js-set-checklist-triggers + i.fa.fa-check + .triggers-main-body + if showBoardTrigger.get + +boardTriggers + else if showCardTrigger.get + +cardTriggers + else if showChecklistTrigger.get + +checklistTriggers
\ No newline at end of file diff --git a/client/components/rules/rulesTriggers.js b/client/components/rules/rulesTriggers.js new file mode 100644 index 00000000..0a4abd66 --- /dev/null +++ b/client/components/rules/rulesTriggers.js @@ -0,0 +1,52 @@ +BlazeComponent.extendComponent({ + onCreated() { + this.showBoardTrigger = new ReactiveVar(true); + this.showCardTrigger = new ReactiveVar(false); + this.showChecklistTrigger = new ReactiveVar(false); + }, + + + setBoardTriggers(){ + this.showBoardTrigger.set(true); + this.showCardTrigger.set(false); + this.showChecklistTrigger.set(false); + $('.js-set-card-triggers').removeClass('active'); + $('.js-set-board-triggers').addClass('active'); + $('.js-set-checklist-triggers').removeClass('active'); + }, + setCardTriggers(){ + this.showBoardTrigger.set(false); + this.showCardTrigger.set(true); + this.showChecklistTrigger.set(false); + $('.js-set-card-triggers').addClass('active'); + $('.js-set-board-triggers').removeClass('active'); + $('.js-set-checklist-triggers').removeClass('active'); + }, + setChecklistTriggers(){ + this.showBoardTrigger.set(false); + this.showCardTrigger.set(false); + this.showChecklistTrigger.set(true); + $('.js-set-card-triggers').removeClass('active'); + $('.js-set-board-triggers').removeClass('active'); + $('.js-set-checklist-triggers').addClass('active'); + }, + + rules() { + return Rules.find({}); + }, + + name(){ + console.log(this.data()); + }, + events() { + return [{'click .js-set-board-triggers'(event) { + this.setBoardTriggers(); + }, + 'click .js-set-card-triggers'(event) { + this.setCardTriggers(); + }, + 'click .js-set-checklist-triggers'(event) { + this.setChecklistTriggers(); + },}]; + }, +}).register('rulesTriggers');
\ No newline at end of file diff --git a/client/components/rules/triggers/boardTriggers.jade b/client/components/rules/triggers/boardTriggers.jade new file mode 100644 index 00000000..8b0b9489 --- /dev/null +++ b/client/components/rules/triggers/boardTriggers.jade @@ -0,0 +1,45 @@ +template(name="boardTriggers") + div.trigger-item + div.trigger-content + div.trigger-text + | When a card is + div.trigger-dropdown + select(id="action") + option(value="created") Added to + option(value="removed") Removed from + div.trigger-text + | the board + div.trigger-button.js-add-gen-trigger.js-goto-action + i.fa.fa-plus + + div.trigger-item + div.trigger-content + div.trigger-text + | When a card is + div.trigger-dropdown + select + option Moved to + div.trigger-text + | to list + div.trigger-dropdown + input(type=text,placeholder="List Name") + div.trigger-button.js-add-spec-trigger.js-goto-action + i.fa.fa-plus + + div.trigger-item + div.trigger-content + div.trigger-text + | When a card is + div.trigger-dropdown + select + option Archived + option Unarchived + div.trigger-button.js-add-arc-trigger.js-goto-action + i.fa.fa-plus + + + + + + + diff --git a/client/components/rules/triggers/boardTriggers.js b/client/components/rules/triggers/boardTriggers.js new file mode 100644 index 00000000..4c8594d3 --- /dev/null +++ b/client/components/rules/triggers/boardTriggers.js @@ -0,0 +1,28 @@ +BlazeComponent.extendComponent({ + onCreated() { + + }, + + events() { + return [ + {'click .js-add-gen-trigger'(event) { + + let datas = this.data(); + const actionSelected = this.find('#action').value; + const boardId = Session.get('currentBoard') + if(actionSelected == "created"){ + Triggers.insert({activityType: "createCard","boardId":boardId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + if(actionSelected == "removed"){ + Triggers.insert({activityType: "removeCard","boardId":boardId},function(error,id){ + datas.triggerIdVar.set(id); + }); + } + + }, + }]; + }, + +}).register('boardTriggers');
\ No newline at end of file diff --git a/client/components/rules/triggers/cardTriggers.jade b/client/components/rules/triggers/cardTriggers.jade new file mode 100644 index 00000000..c1a42ab5 --- /dev/null +++ b/client/components/rules/triggers/cardTriggers.jade @@ -0,0 +1,10 @@ +template(name="cardTriggers") + div.trigger-item + div.trigger-content + div.trigger-text + | When a label is + div.trigger-dropdown + select + option Moved to + div.trigger-button + i.fa.fa-plus
\ No newline at end of file diff --git a/client/components/rules/triggers/checklistTriggers.jade b/client/components/rules/triggers/checklistTriggers.jade new file mode 100644 index 00000000..7364bfa7 --- /dev/null +++ b/client/components/rules/triggers/checklistTriggers.jade @@ -0,0 +1,10 @@ +template(name="checklistTriggers") + div.trigger-item + div.trigger-content + div.trigger-text + | When a check is + div.trigger-dropdown + select + option Checked + div.trigger-button + i.fa.fa-plus
\ No newline at end of file diff --git a/models/actions.js b/models/actions.js new file mode 100644 index 00000000..0961abbb --- /dev/null +++ b/models/actions.js @@ -0,0 +1,62 @@ +Actions = new Mongo.Collection('actions'); + + + +Actions.mutations({ + rename(description) { + return { $set: { description } }; + }, +}); + +Actions.allow({ + update: function () { + // add custom authentication code here + return true; + }, + insert: function () { + // add custom authentication code here + return true; + } +}); + + +Actions.helpers({ + fromList() { + return Lists.findOne(this.fromId); + }, + + toList() { + return Lists.findOne(this.toId); + }, + + findList(title) { + return Lists.findOne({title:title}); + }, + + labels() { + const boardLabels = this.board().labels; + const cardLabels = _.filter(boardLabels, (label) => { + return _.contains(this.labelIds, label._id); + }); + return cardLabels; + }}); + + + +if (Meteor.isServer) { + Meteor.startup(() => { + const rules = Triggers.findOne({}); + if(!rules){ + Actions.insert({actionType: "moveCardToTop"}); + } + }); +} + + + + + + + + + diff --git a/models/activities.js b/models/activities.js index 5b54759c..beb741bc 100644 --- a/models/activities.js +++ b/models/activities.js @@ -56,6 +56,17 @@ Activities.before.insert((userId, doc) => { doc.createdAt = new Date(); }); + + +Activities.after.insert((userId, doc) => { + const activity = Activities._transform(doc); + const matchedTriggers = Triggers.find(activity); + if(matchedTriggers.count() > 0){ + const card = activity.card(); + Cards.direct.update({_id: card._id},{$set: {title: "ciaooo"}}); + } +}); + if (Meteor.isServer) { // For efficiency create indexes on the date of creation, and on the date of // creation in conjunction with the card or board id, as corresponding views diff --git a/models/rules.js b/models/rules.js index df0cccea..778622c4 100644 --- a/models/rules.js +++ b/models/rules.js @@ -39,15 +39,3 @@ Rules.allow({ }, }); - - - -if (Meteor.isServer) { - Meteor.startup(() => { - const rules = Rules.findOne({}); - if(!rules){ - Rules.insert({title: "regola1", description: "bella"}); - Rules.insert({title: "regola2", description: "bella2"}); - } - }); -} diff --git a/models/triggers.js b/models/triggers.js index f8dbb50d..660d8b94 100644 --- a/models/triggers.js +++ b/models/triggers.js @@ -39,34 +39,7 @@ Triggers.helpers({ return _.contains(this.labelIds, label._id); }); return cardLabels; - }}); - - - -if (Meteor.isServer) { - Meteor.startup(() => { - const rules = Triggers.findOne({}); - if(!rules){ - Triggers.insert({group: "cards", activityType: "moveCard","fromId":-1,"toId":-1 }); - } - }); -} - - - - Activities.after.insert((userId, doc) => { - const activity = Activities._transform(doc); - const matchedTriggers = Triggers.find({activityType: activity.activityType,fromId:activity.oldListId,toId:activity.listId}) - if(matchedTriggers.count() > 0){ - const card = activity.card(); - const oldTitle = card.title; - const fromListTitle = activity.oldList().title; - Cards.direct.update({_id: card._id, listId: card.listId, boardId: card.boardId, archived: false}, - {$set: {title: "[From "+fromListTitle +"] "+ oldTitle}}); - } - }); - - +}}); |