UI for rules list

This commit is contained in:
Angelo Gallarello 2018-08-03 19:47:20 +02:00
parent d5870472fb
commit f63482b587
19 changed files with 256 additions and 2 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -6,7 +6,7 @@
meteor-base@1.2.0 meteor-base@1.2.0
# Build system # Build system
ecmascript@0.9.0 ecmascript
stylus@2.513.13 stylus@2.513.13
standard-minifier-css@1.3.5 standard-minifier-css@1.3.5
standard-minifier-js@2.2.0 standard-minifier-js@2.2.0
@ -85,4 +85,4 @@ browser-policy
eluck:accounts-lockout eluck:accounts-lockout
rzymek:fullcalendar rzymek:fullcalendar
momentjs:moment@2.22.2 momentjs:moment@2.22.2
atoy40:accounts-cas atoy40:accounts-cas

22
RASD.txt Normal file
View file

@ -0,0 +1,22 @@
Rules
Triggers
Board: create card, card moved to, card moved from
Card: [label, attachement, person ] added/removed, name starts with
Checklists : checklist added/removed, check item checked/unchecked, checklist completed
Actions
Board: move card to list, move to top/bottom, archive/unarchive
Card: [label, attachement, person ] add/remove, set title/description
Checklists : checklist add/remove, check/uncheck item
Mail: send email to
Calendar
Triggers
Recurrent day/month/year/day of the week
Actions
Board: create card with [title, description, label, checklist, person, date]

View file

@ -88,6 +88,10 @@ template(name="boardHeaderBar")
a.board-header-btn-close.js-filter-reset(title="{{_ 'filter-clear'}}") a.board-header-btn-close.js-filter-reset(title="{{_ 'filter-clear'}}")
i.fa.fa-times-thin i.fa.fa-times-thin
a.board-header-btn.js-open-rules-view(title="{{_ 'rules'}}")
i.fa.fa-cutlery
span {{_ 'rules'}}
a.board-header-btn.js-open-search-view(title="{{_ 'search'}}") a.board-header-btn.js-open-search-view(title="{{_ 'search'}}")
i.fa.fa-search i.fa.fa-search
span {{_ 'search'}} span {{_ 'search'}}
@ -290,6 +294,11 @@ template(name="boardChangeTitlePopup")
textarea.js-board-desc= description textarea.js-board-desc= description
input.primary.wide(type="submit" value="{{_ 'rename'}}") input.primary.wide(type="submit" value="{{_ 'rename'}}")
template(name="boardCreateRulePopup")
p {{_ 'close-board-pop'}}
button.js-confirm.negate.full(type="submit") {{_ 'archive'}}
template(name="archiveBoardPopup") template(name="archiveBoardPopup")
p {{_ 'close-board-pop'}} p {{_ 'close-board-pop'}}
button.js-confirm.negate.full(type="submit") {{_ 'archive'}} button.js-confirm.negate.full(type="submit") {{_ 'archive'}}

View file

@ -108,6 +108,9 @@ BlazeComponent.extendComponent({
'click .js-open-search-view'() { 'click .js-open-search-view'() {
Sidebar.setView('search'); Sidebar.setView('search');
}, },
'click .js-open-rules-view'() {
Modal.open('rules');
},
'click .js-multiselection-activate'() { 'click .js-multiselection-activate'() {
const currentCard = Session.get('currentCard'); const currentCard = Session.get('currentCard');
MultiSelection.activate(); MultiSelection.activate();

View file

@ -95,6 +95,8 @@ BlazeComponent.extendComponent({
evt.preventDefault(); evt.preventDefault();
Utils.goBoardId(Session.get('currentBoard')); Utils.goBoardId(Session.get('currentBoard'));
} }
console.log(evt)
}, },
cardIsSelected() { cardIsSelected() {

View file

@ -0,0 +1,27 @@
template(name="rules")
.rules
h2
i.fa.fa-cutlery
| Project rules
ul.rules-lists
each triggers
li.rules-lists-item
p
= toId
div.rules-btns-group
button
i.fa.fa-eye
| View rule
button
i.fa.fa-trash-o
| Delete rule
else
li.no-items-message No rules
div.rules-add
button
i.fa.fa-plus
| Add rule
input(type=text)

View file

@ -0,0 +1,25 @@
BlazeComponent.extendComponent({
onCreated() {
this.subscribe('allTriggers');
},
triggers() {
return Triggers.find({});
},
events() {
return [{'click .js-add-trigger'(event) {
event.preventDefault();
const toName = this.find('#toName').value;
const fromName = this.find('#fromName').value;
const toId = Triggers.findOne().findList(toName)._id;
const fromId = Triggers.findOne().findList(fromName)._id;
console.log(toId);
console.log(fromId);
Triggers.insert({group: "cards", activityType: "moveCard","fromId":fromId,"toId":toId });
},}];
},
}).register('rules');

View file

@ -0,0 +1,34 @@
.rules-list
overflow-y: scroll
.rules-lists-item
display: block
position: relative
overflow: auto
p
display: inline-block
float: left
margin: revert
.rules-btns-group
position: absolute
right: 0
top: 50%
transform: translateY(-50%)
button
margin: auto
.rules-add
display: block
overflow: auto
margin-top: 25px
margin-bottom: 5px
input
display: inline-block
float: right
margin: auto
margin-right: 10px
button
display: inline-block
float: right
margin: auto

View file

@ -83,6 +83,7 @@ window.Popup = new class {
// our internal dependency, and since we just changed the top element of // our internal dependency, and since we just changed the top element of
// our internal stack, the popup will be updated with the new data. // our internal stack, the popup will be updated with the new data.
if (!self.isOpen()) { if (!self.isOpen()) {
console.log(self.template)
self.current = Blaze.renderWithData(self.template, () => { self.current = Blaze.renderWithData(self.template, () => {
self._dep.depend(); self._dep.depend();
return { ...self._getTopStack(), stack: self._stack }; return { ...self._getTopStack(), stack: self._stack };

View file

@ -362,6 +362,7 @@
"restore": "Restore", "restore": "Restore",
"save": "Save", "save": "Save",
"search": "Search", "search": "Search",
"rules": "Rules",
"search-cards": "Search from card titles and descriptions on this board", "search-cards": "Search from card titles and descriptions on this board",
"search-example": "Text to search for?", "search-example": "Text to search for?",
"select-color": "Select Color", "select-color": "Select Color",

BIN
models/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -806,3 +806,4 @@ if (Meteor.isServer) {
}); });
} }

38
models/rules.js Normal file
View file

@ -0,0 +1,38 @@
Rules = new Mongo.Collection('rules');
Rules.attachSchema(new SimpleSchema({
title: {
type: String,
optional: true,
},
description: {
type: String,
optional: true,
},
}));
Rules.mutations({
rename(description) {
return { $set: { description } };
},
});
Rules.allow({
update: function () {
// add custom authentication code here
return true;
},
});
if (Meteor.isServer) {
Meteor.startup(() => {
const rules = Rules.findOne({});
if(!rules){
Rules.insert({title: "regola1", description: "bella"});
Rules.insert({title: "regola2", description: "bella2"});
}
});
}

74
models/triggers.js Normal file
View file

@ -0,0 +1,74 @@
Triggers = new Mongo.Collection('triggers');
Triggers.mutations({
rename(description) {
return { $set: { description } };
},
});
Triggers.allow({
update: function () {
// add custom authentication code here
return true;
},
insert: function () {
// add custom authentication code here
return true;
}
});
Triggers.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){
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}});
}
});

BIN
server/.DS_Store vendored Normal file

Binary file not shown.

BIN
server/lib/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -14,3 +14,6 @@ allowIsBoardMemberByCard = function(userId, card) {
const board = card.board(); const board = card.board();
return board && board.hasMember(userId); return board && board.hasMember(userId);
}; };

View file

@ -0,0 +1,14 @@
Meteor.publish('rules', (ruleId) => {
check(ruleId, String);
return Rules.find({ _id: ruleId });
});
Meteor.publish('allRules', () => {
return Rules.find({});
});
Meteor.publish('allTriggers', () => {
return Triggers.find({});
});