Selaa lähdekoodia

GC-1178: impl changing list policy form

Yuki Takei 7 vuotta sitten
vanhempi
sitoutus
97c98c716a

+ 2 - 2
src/server/form/admin/securityGeneral.js

@@ -11,6 +11,6 @@ module.exports = form(
   field('settingForm[security:restrictGuestMode]').required(),
   field('settingForm[security:registrationMode]').required(),
   field('settingForm[security:registrationWhiteList]').custom(normalizeCRLF).custom(stringToArray),
-  field('settingForm[security:list-policy:showRestrictedByOwner]').trim().toBooleanStrict(),
-  field('settingForm[security:list-policy:showRestrictedByGroup]').trim().toBooleanStrict(),
+  field('settingForm[security:list-policy:hideRestrictedByOwner]').trim().toBooleanStrict(),
+  field('settingForm[security:list-policy:hideRestrictedByGroup]').trim().toBooleanStrict(),
 );

+ 12 - 2
src/server/models/config.js

@@ -60,8 +60,8 @@ module.exports = function(crowi) {
       'security:registrationMode'      : 'Open',
       'security:registrationWhiteList' : [],
 
-      'security:list-policy:showRestrictedByOwner' : true,
-      'security:list-policy:showRestrictedByGroup' : true,
+      'security:list-policy:hideRestrictedByOwner' : false,
+      'security:list-policy:hideRestrictedByGroup' : false,
 
       'security:isEnabledPassport' : false,
       'security:passport-ldap:isEnabled' : false,
@@ -380,6 +380,16 @@ module.exports = function(crowi) {
     return SECURITY_RESTRICT_GUEST_MODE_READONLY === config.crowi['security:restrictGuestMode'];
   };
 
+  configSchema.statics.hidePagesRestrictedByOwnerInList = function(config) {
+    const key = 'security:list-policy:hideRestrictedByOwner';
+    return getValueForCrowiNS(config, key);
+  };
+
+  configSchema.statics.hidePagesRestrictedByGroupInList = function(config) {
+    const key = 'security:list-policy:hideRestrictedByGroup';
+    return getValueForCrowiNS(config, key);
+  };
+
   configSchema.statics.isEnabledPlugins = function(config) {
     const key = 'plugin:isEnabledPlugins';
     return getValueForCrowiNS(config, key);

+ 14 - 12
src/server/views/admin/security.html

@@ -95,16 +95,17 @@
           </div>
 
           <div class="form-group">
-            {% set configName = 'settingForm[security:list-policy:showRestrictedByOwner]' %}
-            {% set configValue = settingForm['security:list-policy:showRestrictedByOwner'] %}
+            {% set configName = 'settingForm[security:list-policy:hideRestrictedByOwner]' %}
+            {% set configValue = settingForm['security:list-policy:hideRestrictedByOwner'] %}
+            {% set isEnabled = !configValue %}
             <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_1") }}</label>
             <div class="col-xs-9">
               <div class="btn-group btn-toggle" data-toggle="buttons">
-                <label class="btn btn-default btn-rounded btn-outline {% if configValue %}active{% endif %}" data-active-class="primary">
-                  <input name="{{configName}}" value="true" type="radio" {% if true === configValue %}checked{% endif %}> ON
+                <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
+                  <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
                 </label>
-                <label class="btn btn-default btn-rounded btn-outline {% if !configValue %}active{% endif %}" data-active-class="default">
-                  <input name="{{configName}}" value="false" type="radio" {% if !configValue %}checked{% endif %}> OFF
+                <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
+                  <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
                 </label>
               </div>
 
@@ -115,16 +116,17 @@
           </div>
 
           <div class="form-group">
-              {% set configName = 'settingForm[security:list-policy:showRestrictedByGroup]' %}
-              {% set configValue = settingForm['security:list-policy:showRestrictedByGroup'] %}
+            {% set configName = 'settingForm[security:list-policy:hideRestrictedByGroup]' %}
+            {% set configValue = settingForm['security:list-policy:hideRestrictedByGroup'] %}
+            {% set isEnabled = !configValue %}
             <label for="{{configName}}" class="col-xs-3 control-label">{{ t("security_setting.page_listing_2") }}</label>
             <div class="col-xs-9">
               <div class="btn-group btn-toggle" data-toggle="buttons">
-                <label class="btn btn-default btn-rounded btn-outline {% if configValue %}active{% endif %}" data-active-class="primary">
-                  <input name="{{configName}}" value="true" type="radio" {% if true === configValue %}checked{% endif %}> ON
+                <label class="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
+                  <input name="{{configName}}" value="false" type="radio" {% if isEnabled %}checked{% endif %}> ON
                 </label>
-                <label class="btn btn-default btn-rounded btn-outline {% if !configValue %}active{% endif %}" data-active-class="default">
-                  <input name="{{configName}}" value="false" type="radio" {% if !configValue %}checked{% endif %}> OFF
+                <label class="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
+                  <input name="{{configName}}" value="true" type="radio" {% if !isEnabled %}checked{% endif %}> OFF
                 </label>
               </div>