Просмотр исходного кода

Merge branch 'imprv/duplicate-Page-with-child' of https://github.com/weseek/growi into imprv/duplicate-Page-with-child

白石誠 5 лет назад
Родитель
Сommit
a389992486

+ 1 - 0
resource/locales/en_US/translation.json

@@ -328,6 +328,7 @@
       "Fail to get subordinated pages": "Fail to get subordinated pages",
       "Current page name": "Current page name",
       "Duplicate with child": "Duplicate with child",
+      "Duplicate without exist path": "Duplicate without exist path",
       "Same page already exists": "Same page already exists"
     }
   },

+ 1 - 0
resource/locales/ja_JP/translation.json

@@ -330,6 +330,7 @@
       "Fail to get subordinated pages": "配下ページの取得に失敗しました",
       "Current page name": "現在のページ名",
       "Duplicate with child": "配下のページも一緒に複製する",
+      "Duplicate without exist path": "存在するパス以外を複製する",
       "Same page already exists": "同じページがすでに存在します"
     }
   },

+ 1 - 0
resource/locales/zh_CN/translation.json

@@ -303,6 +303,7 @@
       "Fail to get subordinated pages": "Fail to get subordinated pages",
 			"Current page name": "Current page name",
       "Duplicate with child": "Duplicate with child",
+      "Duplicate without exist path": "Duplicate without exist path",
       "Same page already exists": "Same page already exists"
 		}
 	},

+ 51 - 21
src/client/js/components/PageDuplicateModal.jsx

@@ -13,6 +13,7 @@ import PageContainer from '../services/PageContainer';
 import PagePathAutoComplete from './PagePathAutoComplete';
 import ApiErrorMessageList from './PageManagement/ApiErrorMessageList';
 
+
 const PageDuplicateModal = (props) => {
   const { t, appContainer, pageContainer } = props;
 
@@ -25,15 +26,35 @@ const PageDuplicateModal = (props) => {
 
   const [errs, setErrs] = useState(null);
 
-  const [subordinatedPaths, setSubordinatedPaths] = useState([]);
+  // ToDo: subordinatedPaths is not used yet so commented. Will use when all the child of { path } is needed.
+  // const [subordinatedPaths, setSubordinatedPaths] = useState([]);
+  // for now we use the code below.
+  const [setSubordinatedPaths] = useState([]);
   const [getSubordinatedError, setGetSuborinatedError] = useState(null);
   const [isDuplicateRecursively, setIsDuplicateRecursively] = useState(true);
+  const [isDuplicateRecursivelyWithoutExistPath, setIsDuplicateRecursivelyWithoutExistPath] = useState(true);
+  const [isDuplicateExistList, setIsDuplicateExistList] = useState([]);
+
+
+  function getSubordinatedDuplicateList(value) {
+
+    // ToDo: get the duplicated list from sever
+    // below is psuedo code
+    // let duplicatedList = get.apiv3......
+    // duplicatedList = duplicatedList.map((value) =>
+    // <li className="duplicate-exist" key={value}> {value}: { t('modal_duplicate.label.Same page already exists') } </li>; )
+    // setIsDuplicateExist(duplicatedList);
+
+    // ToDo: for now we use dummy path
+    setIsDuplicateExistList(['/test146/test147', value]);
+  }
 
   /**
    * change pageNameInput for PagePathAutoComplete
    * @param {string} value
    */
   function ppacInputChangeHandler(value) {
+    getSubordinatedDuplicateList(value);
     setPageNameInput(value);
   }
 
@@ -42,6 +63,7 @@ const PageDuplicateModal = (props) => {
    * @param {string} value
    */
   function inputChangeHandler(value) {
+    getSubordinatedDuplicateList(value);
     setPageNameInput(value);
   }
 
@@ -65,6 +87,10 @@ const PageDuplicateModal = (props) => {
     }
   }, [props.isOpen, getSubordinatedList]);
 
+  function changeIsDuplicateRecursivelyWithoutExistPathHandler() {
+    setIsDuplicateRecursivelyWithoutExistPath(!isDuplicateRecursivelyWithoutExistPath);
+  }
+
   async function duplicate() {
     setErrs(null);
 
@@ -129,27 +155,31 @@ const PageDuplicateModal = (props) => {
           <label className="custom-control-label" htmlFor="cbDuplicateRecursively">
             { t('modal_duplicate.label.Duplicate with child') }
           </label>
-          <div>
-            <ul className="duplicate-name">
-              {isDuplicateRecursively && subordinatedPaths.map((duplicatedNewPath) => {
-                  // ToDo: The "true" statement below will be modified by task GW3503
-                  if (true) {
-                    return (
-                      <li
-                        className="duplicate-exist"
-                        key={duplicatedNewPath}
-                      >
-                        {duplicatedNewPath}: { t('modal_duplicate.label.Same page already exists') }
-                      </li>
-                    );
-                  }
-                  return <li key={duplicatedNewPath}>{duplicatedNewPath}</li>;
-                })
-              }
-            </ul>
-          </div>
-          <div> {getSubordinatedError} </div>
         </div>
+
+        <div
+          className="custom-control custom-checkbox custom-checkbox-warning"
+          style={{ display: (isDuplicateExistList.length !== 0) && isDuplicateRecursively ? '' : 'none' }}
+        >
+          <input
+            className="custom-control-input"
+            name="withoutExistRecursively"
+            id="cbDuplicatewithoutExistRecursively"
+            type="checkbox"
+            checked={isDuplicateRecursivelyWithoutExistPath}
+            onChange={changeIsDuplicateRecursivelyWithoutExistPathHandler}
+          />
+          <label className="custom-control-label" htmlFor="cbDuplicatewithoutExistRecursively">
+            { t('modal_duplicate.label.Duplicate without exist path') }
+          </label>
+        </div>
+
+        <div>
+          <ul className="duplicate-name">
+            {isDuplicateRecursively && isDuplicateExistList.length !== 0 && isDuplicateExistList}
+          </ul>
+        </div>
+        <div> {getSubordinatedError} </div>
       </ModalBody>
       <ModalFooter>
         <ApiErrorMessageList errs={errs} targetPath={pageNameInput} />