summaryrefslogtreecommitdiffstats
path: root/client/components/cards
diff options
context:
space:
mode:
authorPouyan Savoli <papoola@hotmail.com>2017-09-18 00:46:17 +0200
committerPouyan Savoli <papoola@hotmail.com>2017-09-22 22:59:32 +0200
commit3753337d60e17e5e72ec071aa4a1b28e36297d15 (patch)
tree81363c3fb7d1af2c90e7a3e2b1233412569bd52d /client/components/cards
parentcaad952bc1b29bb925c1347a14daa5d1ec8ada81 (diff)
downloadwekan-3753337d60e17e5e72ec071aa4a1b28e36297d15.tar.gz
wekan-3753337d60e17e5e72ec071aa4a1b28e36297d15.tar.bz2
wekan-3753337d60e17e5e72ec071aa4a1b28e36297d15.zip
dropdown items
Diffstat (limited to 'client/components/cards')
-rw-r--r--client/components/cards/cardCustomFields.jade29
-rw-r--r--client/components/cards/cardCustomFields.js62
2 files changed, 71 insertions, 20 deletions
diff --git a/client/components/cards/cardCustomFields.jade b/client/components/cards/cardCustomFields.jade
index 6515aa79..9e9f7d84 100644
--- a/client/components/cards/cardCustomFields.jade
+++ b/client/components/cards/cardCustomFields.jade
@@ -8,11 +8,14 @@ template(name="cardCustomFieldsPopup")
if hasCustomField
i.fa.fa-check
hr
- a.quiet-button.full.js-configure-custom-fields
+ a.quiet-button.full.js-settings
i.fa.fa-cog
- span {{_ 'configure-custom-fields'}}
+ span {{_ 'settings'}}
-template(name="cardCustomFieldText")
+template(name="cardCustomField")
+ +Template.dynamic(template=getTemplate)
+
+template(name="cardCustomField-text")
if canModifyCard
+inlinedForm(classNames="js-card-customfield-text")
+editor(autofocus=true)
@@ -26,4 +29,24 @@ template(name="cardCustomFieldText")
+viewer
= value
else
+ | {{_ 'edit'}}
+
+template(name="cardCustomField-dropdown")
+ if canModifyCard
+ +inlinedForm(classNames="js-card-customfield-dropdown")
+ select.inline
+ each items
+ if($eq data.value this._id)
+ option(value=_id selected="selected") {{name}}
+ else
+ option(value=_id) {{name}}
+ .edit-controls.clearfix
+ button.primary(type="submit") {{_ 'save'}}
+ a.fa.fa-times-thin.js-close-inlined-form
+ else
+ a.js-open-inlined-form
+ if value
+ +viewer
+ = selectedItem
+ else
| {{_ 'edit'}} \ No newline at end of file
diff --git a/client/components/cards/cardCustomFields.js b/client/components/cards/cardCustomFields.js
index 7009dede..f9fa760c 100644
--- a/client/components/cards/cardCustomFields.js
+++ b/client/components/cards/cardCustomFields.js
@@ -13,7 +13,7 @@ Template.cardCustomFieldsPopup.events({
card.toggleCustomField(customFieldId);
evt.preventDefault();
},
- 'click .js-configure-custom-fields'(evt) {
+ 'click .js-settings'(evt) {
EscapeActions.executeUpTo('detailsPane');
Sidebar.setView('customFields');
evt.preventDefault();
@@ -21,23 +21,25 @@ Template.cardCustomFieldsPopup.events({
});
const CardCustomField = BlazeComponent.extendComponent({
- template() {
- return 'cardCustomFieldText';
+
+ getTemplate() {
+ return 'cardCustomField-' + this.data().definition.type;
},
onCreated() {
const self = this;
- self.date = ReactiveVar();
- self.now = ReactiveVar(moment());
},
- value() {
- return this.data().value;
+ canModifyCard() {
+ return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
},
+});
+CardCustomField.register('cardCustomField');
- showISODate() {
- return this.date.get().toISOString();
- },
+(class extends CardCustomField {
+
+ onCreated() {
+ }
events() {
return [{
@@ -48,13 +50,39 @@ const CardCustomField = BlazeComponent.extendComponent({
const value = this.currentComponent().getValue();
card.setCustomField(customFieldId,value);
},
- 'click .js-edit-date': Popup.open('editCardStartDate'),
}];
- },
+ }
- canModifyCard() {
- return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
- },
-});
+}).register('cardCustomField-text');
+
+(class extends CardCustomField {
+
+ onCreated() {
+ this._items = this.data().definition.settings.dropdownItems;
+ this.items = this._items.slice(0);
+ this.items.unshift({
+ _id: "",
+ name: TAPi18n.__('custom-field-dropdown-none')
+ });
+ }
+
+ selectedItem() {
+ const selected = this._items.find((item) => {
+ return item._id == this.data().value;
+ });
+ return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown');
+ }
+
+ events() {
+ return [{
+ 'submit .js-card-customfield-dropdown'(evt) {
+ evt.preventDefault();
+ const card = Cards.findOne(Session.get('currentCard'));
+ const customFieldId = this.data()._id;
+ const value = this.find('select').value;
+ card.setCustomField(customFieldId,value);
+ },
+ }];
+ }
-CardCustomField.register('cardCustomField'); \ No newline at end of file
+}).register('cardCustomField-dropdown'); \ No newline at end of file