summaryrefslogtreecommitdiffstats
path: root/client/components/sidebar
diff options
context:
space:
mode:
authorIgnatzHome <ignatz@maschath.de>2018-05-17 20:21:07 +0200
committerIgnatzHome <ignatz@maschath.de>2018-05-17 20:21:07 +0200
commit9518a5c11ee5bc8556ad7af2d0bef1aa8ae47874 (patch)
tree47ffe9a487aa6d66bbb4cd327ca248c4b30fda4a /client/components/sidebar
parentc0c7b269a794fb28ddf5ffc17744f6724041de96 (diff)
parent8b16955cc27b29ae507be084adccc4fad61b05ef (diff)
downloadwekan-9518a5c11ee5bc8556ad7af2d0bef1aa8ae47874.tar.gz
wekan-9518a5c11ee5bc8556ad7af2d0bef1aa8ae47874.tar.bz2
wekan-9518a5c11ee5bc8556ad7af2d0bef1aa8ae47874.zip
resolving merge conflicts
Diffstat (limited to 'client/components/sidebar')
-rw-r--r--client/components/sidebar/sidebar.js1
-rw-r--r--client/components/sidebar/sidebar.styl61
-rw-r--r--client/components/sidebar/sidebarCustomFields.jade52
-rw-r--r--client/components/sidebar/sidebarCustomFields.js130
4 files changed, 222 insertions, 22 deletions
diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js
index bff96dcb..5a9de74b 100644
--- a/client/components/sidebar/sidebar.js
+++ b/client/components/sidebar/sidebar.js
@@ -6,6 +6,7 @@ const viewTitles = {
filter: 'filter-cards',
search: 'search-cards',
multiselection: 'multi-selection',
+ customFields: 'custom-fields',
archives: 'archives',
};
diff --git a/client/components/sidebar/sidebar.styl b/client/components/sidebar/sidebar.styl
index 8f2f493e..740186b5 100644
--- a/client/components/sidebar/sidebar.styl
+++ b/client/components/sidebar/sidebar.styl
@@ -45,28 +45,45 @@
display: flex
flex-direction: column
- li > a
- display: flex
- height: 30px
- margin: 0
- padding: 4px
- border-radius: 3px
- align-items: center
-
- &:hover
- &, i, .quiet
- color white
-
- .member, .card-label
- margin-right: 7px
- margin-top: 5px
-
- .sidebar-list-item-description
- flex: 1
- overflow: ellipsis
-
- .fa.fa-check
- margin: 0 4px
+ li
+ & > a
+ display: flex
+ height: 30px
+ margin: 0
+ padding: 4px
+ border-radius: 3px
+ align-items: center
+
+ &:hover
+ &, i, .quiet
+ color white
+
+ .member, .card-label
+ margin-right: 7px
+ margin-top: 5px
+
+ .minicard-edit-button
+ float: right
+ padding: 8px
+ border-radius: 3px
+
+ .sidebar-list-item-description
+ flex: 1
+ overflow: ellipsis
+
+ .fa.fa-check
+ margin: 0 4px
+
+ .minicard
+ padding: 6px 8px 4px
+
+ .minicard-edit-button
+ float: right
+ padding: 4px
+ border-radius: 3px
+
+ &:hover
+ background: #dbdbdb
.sidebar-btn
display: block
diff --git a/client/components/sidebar/sidebarCustomFields.jade b/client/components/sidebar/sidebarCustomFields.jade
new file mode 100644
index 00000000..def083e9
--- /dev/null
+++ b/client/components/sidebar/sidebarCustomFields.jade
@@ -0,0 +1,52 @@
+template(name="customFieldsSidebar")
+ ul.sidebar-list
+ each customFields
+ li
+ div.minicard-wrapper.js-minicard
+ div.minicard
+ a.fa.fa-pencil.js-edit-custom-field.minicard-edit-button
+ div.minicard-title
+ | {{ name }} ({{ type }})
+
+ if currentUser.isBoardMember
+ hr
+ a.sidebar-btn.js-open-create-custom-field
+ i.fa.fa-plus
+ span {{_ 'createCustomField'}}
+
+template(name="createCustomFieldPopup")
+ form
+ label
+ | {{_ 'name'}}
+ unless _id
+ input.js-field-name(type="text" autofocus)
+ else
+ input.js-field-name(type="text" value=name)
+
+ label
+ | {{_ 'type'}}
+ select.js-field-type(disabled="{{#if _id}}disabled{{/if}}")
+ each types
+ if selected
+ option(value=value selected="selected") {{name}}
+ else
+ option(value=value) {{name}}
+ div.js-field-settings.js-field-settings-dropdown(class="{{#if isTypeNotSelected 'dropdown'}}hide{{/if}}")
+ label
+ | {{_ 'custom-field-dropdown-options'}}
+ each dropdownItems.get
+ input.js-dropdown-item(type="text" value=name placeholder="")
+ input.js-dropdown-item.last(type="text" value="" placeholder="{{_ 'custom-field-dropdown-options-placeholder'}}")
+ a.flex.js-field-show-on-card
+ .materialCheckBox(class="{{#if showOnCard}}is-checked{{/if}}")
+
+ span {{_ 'show-field-on-card'}}
+ button.primary.wide.left(type="button")
+ | {{_ 'save'}}
+ if _id
+ button.negate.wide.right.js-delete-custom-field(type="button")
+ | {{_ 'delete'}}
+
+template(name="deleteCustomFieldPopup")
+ p {{_ "custom-field-delete-pop"}}
+ button.js-confirm.negate.full(type="submit") {{_ 'delete'}} \ No newline at end of file
diff --git a/client/components/sidebar/sidebarCustomFields.js b/client/components/sidebar/sidebarCustomFields.js
new file mode 100644
index 00000000..139b8a42
--- /dev/null
+++ b/client/components/sidebar/sidebarCustomFields.js
@@ -0,0 +1,130 @@
+BlazeComponent.extendComponent({
+
+ customFields() {
+ return CustomFields.find({
+ boardId: Session.get('currentBoard'),
+ });
+ },
+
+ events() {
+ return [{
+ 'click .js-open-create-custom-field': Popup.open('createCustomField'),
+ 'click .js-edit-custom-field': Popup.open('editCustomField'),
+ }];
+ },
+
+}).register('customFieldsSidebar');
+
+const CreateCustomFieldPopup = BlazeComponent.extendComponent({
+
+ _types: ['text', 'number', 'checkbox', 'date', 'dropdown'],
+
+ onCreated() {
+ this.type = new ReactiveVar((this.data().type) ? this.data().type : this._types[0]);
+ this.dropdownItems = new ReactiveVar((this.data().settings && this.data().settings.dropdownItems) ? this.data().settings.dropdownItems : []);
+ },
+
+ types() {
+ const currentType = this.data().type;
+ return this._types.
+ map(type => {return {
+ value: type,
+ name: TAPi18n.__('custom-field-' + type),
+ selected: type == currentType,
+ }});
+ },
+
+ isTypeNotSelected(type) {
+ return this.type.get() !== type;
+ },
+
+ getDropdownItems() {
+ var items = this.dropdownItems.get();
+ Array.from(this.findAll('.js-field-settings-dropdown input')).forEach((el, index) => {
+ //console.log('each item!', index, el.value);
+ if (!items[index]) items[index] = {
+ _id: Random.id(6),
+ };
+ items[index].name = el.value.trim();
+ });
+ return items;
+ },
+
+ getSettings() {
+ let settings = {};
+ switch (this.type.get()) {
+ case 'dropdown':
+ let dropdownItems = this.getDropdownItems().filter(item => !!item.name.trim());
+ settings.dropdownItems = dropdownItems;
+ break;
+ }
+ return settings;
+ },
+
+ events() {
+ return [{
+ 'change .js-field-type'(evt) {
+ const value = evt.target.value;
+ this.type.set(value);
+ },
+ 'keydown .js-dropdown-item.last'(evt) {
+ if (evt.target.value.trim() && evt.keyCode === 13) {
+ let items = this.getDropdownItems();
+ this.dropdownItems.set(items);
+ evt.target.value = '';
+ }
+ },
+ 'click .js-field-show-on-card'(evt) {
+ let $target = $(evt.target);
+ if(!$target.hasClass('js-field-show-on-card')){
+ $target = $target.parent();
+ }
+ $target.find('.materialCheckBox').toggleClass('is-checked');
+ $target.toggleClass('is-checked');
+ },
+ 'click .primary'(evt) {
+ evt.preventDefault();
+
+ const data = {
+ boardId: Session.get('currentBoard'),
+ name: this.find('.js-field-name').value.trim(),
+ type: this.type.get(),
+ settings: this.getSettings(),
+ showOnCard: this.find('.js-field-show-on-card.is-checked') != null
+ }
+
+ // insert or update
+ if (!this.data()._id) {
+ CustomFields.insert(data);
+ } else {
+ CustomFields.update(this.data()._id, {$set: data});
+ }
+
+ Popup.back();
+ },
+ 'click .js-delete-custom-field': Popup.afterConfirm('deleteCustomField', function() {
+ const customFieldId = this._id;
+ CustomFields.remove(customFieldId);
+ Popup.close();
+ }),
+ }];
+ },
+
+});
+CreateCustomFieldPopup.register('createCustomFieldPopup');
+
+(class extends CreateCustomFieldPopup {
+
+ template() {
+ return 'createCustomFieldPopup';
+ }
+
+}).register('editCustomFieldPopup');
+
+/*Template.deleteCustomFieldPopup.events({
+ 'submit'(evt) {
+ const customFieldId = this._id;
+ CustomFields.remove(customFieldId);
+ Popup.close();
+ }
+});*/ \ No newline at end of file