浏览代码

Toggle opened card Custom Fields layout between Grid and one per row.

Thanks to xet7 !
Lauri Ojansivu 3 年之前
父节点
当前提交
fc2fb9a081
共有 3 个文件被更改,包括 42 次插入1 次删除
  1. 10 1
      client/components/cards/cardDetails.jade
  2. 8 0
      client/components/cards/cardDetails.js
  3. 24 0
      models/users.js

+ 10 - 1
client/components/cards/cardDetails.jade

@@ -227,8 +227,17 @@ template(name="cardDetails")
 
         //.card-details-items
         if customFieldsWD
-          each customFieldsWD
+          .material-toggle-switch(title="{{_ 'change'}} {{_ 'custom-fields'}} {{_ 'layout'}}")
+            if customFieldsGrid
+              input.toggle-switch(type="checkbox" id="toggleCustomFieldsGridButton" checked="checked")
+            else
+              input.toggle-switch(type="checkbox" id="toggleCustomFieldsGridButton")
+            label.toggle-label(for="toggleCustomFieldsGridButton")
+          unless customFieldsGrid
             hr
+          each customFieldsWD
+            if customFieldsGrid
+              hr
             .card-details-item.card-details-item-customfield
               h3.card-details-item-title
                 i.fa.fa-list-alt

+ 8 - 0
client/components/cards/cardDetails.js

@@ -61,6 +61,11 @@ BlazeComponent.extendComponent({
     return Meteor.user().hasHiddenSystemMessages();
   },
 
+  customFieldsGrid() {
+    return Meteor.user().hasCustomFieldsGrid();
+  },
+
+
   cardMaximized() {
     return Meteor.user().hasCardMaximized();
   },
@@ -419,6 +424,9 @@ BlazeComponent.extendComponent({
         'click #toggleButton'() {
           Meteor.call('toggleSystemMessages');
         },
+        'click #toggleCustomFieldsGridButton'() {
+          Meteor.call('toggleCustomFieldsGrid');
+        },
         'click .js-maximize-card-details'() {
           Meteor.call('toggleCardMaximized');
           autosize($('.card-details'));

+ 24 - 0
models/users.js

@@ -184,6 +184,13 @@ Users.attachSchema(
       type: Boolean,
       optional: true,
     },
+    'profile.customFieldsGrid': {
+      /**
+       * has user at card Custom Fields have Grid (false) or one per row (true) layout?
+       */
+      type: Boolean,
+      optional: true,
+    },
     'profile.hiddenSystemMessages': {
       /**
        * does the user want to hide system messages?
@@ -652,6 +659,11 @@ Users.helpers({
     return profile.hiddenSystemMessages || false;
   },
 
+  hasCustomFieldsGrid() {
+    const profile = this.profile || {};
+    return profile.customFieldsGrid || false;
+  },
+
   hasCardMaximized() {
     const profile = this.profile || {};
     return profile.cardMaximized || false;
@@ -809,6 +821,14 @@ Users.mutations({
     };
   },
 
+  toggleFieldsGrid(value = false) {
+    return {
+      $set: {
+        'profile.customFieldsGrid': !value,
+      },
+    };
+  },
+
   toggleCardMaximized(value = false) {
     return {
       $set: {
@@ -911,6 +931,10 @@ Meteor.methods({
     const user = Meteor.user();
     user.toggleSystem(user.hasHiddenSystemMessages());
   },
+  toggleCustomFieldsGrid() {
+    const user = Meteor.user();
+    user.toggleFieldsGrid(user.hasCustomFieldsGrid());
+  },
   toggleCardMaximized() {
     const user = Meteor.user();
     user.toggleCardMaximized(user.hasCardMaximized());