Răsfoiți Sursa

WIP: reconstruct layouts

* duplicate modal
Yuki Takei 8 ani în urmă
părinte
comite
f3a3b086d0

+ 1 - 0
lib/locales/en-US/translation.json

@@ -143,6 +143,7 @@
       "notice": {
           "version": "This is not the current version.",
           "moved": "This page was moved from <code>%s</code>",
+          "duplicated": "This page was duplicated from <code>%s</code>",
           "unlinked": "Redirect pages to this page have been deleted.",
           "restricted": "Access to this page is restricted"
       }

+ 1 - 0
lib/locales/ja/translation.json

@@ -156,6 +156,7 @@
       "notice": {
           "version": "これは現在の版ではありません。",
           "moved": "このページは <code>%s</code> から移動しました。",
+          "duplicated": "このページは <code>%s</code> から複製されました。",
           "unlinked": "このページへのリダイレクトは削除されました。",
           "restricted": "このページの閲覧は制限されています"
       }

+ 15 - 6
lib/views/modal/duplicate.html

@@ -22,12 +22,21 @@
             </div>
         </div>
         <div class="modal-footer">
-          <p><small class="pull-left" id="duplicatePageNameCheck"></small></p>
-          <input type="hidden" name="_csrf" value="{{ csrf() }}">
-          <input type="hidden" name="path" value="{{ page.path }}">
-          <input type="hidden" name="page_id" value="{{ page._id.toString() }}">
-          <input type="hidden" name="revision_id" value="{{ page.revision._id.toString() }}">
-          <button type="submit" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b">Duplicate page</button>
+          <div class="d-flex justify-content-between">
+            <p>
+              <span class="text-danger msg-already-exists">
+                <strong><i class="icon-fw icon-ban"></i>{{ t('Page is already exists.') }}</strong>
+              </span>
+              <small id="linkToNewPage" class="msg-already-exists"></small>
+            </p>
+            <div>
+              <input type="hidden" name="_csrf" value="{{ csrf() }}">
+              <input type="hidden" name="path" value="{{ page.path }}">
+              <input type="hidden" name="page_id" value="{{ page._id.toString() }}">
+              <input type="hidden" name="revision_id" value="{{ page.revision._id.toString() }}">
+              <button type="submit" class="btn btn-primary">Duplicate page</button>
+            </div>
+          </div>
         </div>
 
       </form>

+ 8 - 0
lib/views/widget/page_alerts.html

@@ -47,6 +47,14 @@
     </div>
     {% endif %}
 
+    {% if req.query.duplicated and not page.isDeleted() %}
+    <div class="alert alert-success alert-moved">
+      <span>
+        <strong>{{ t('Duplicated') }}: </strong> {{ t('page_page.notice.duplicated', req.query.duplicated) }}
+      </span>
+    </div>
+    {% endif %}
+
     {% if req.query.unlinked %}
     <div class="alert alert-info alert-unlinked">
       <strong>{{ t('Unlinked') }}: </strong> {{ t('page_page.notice.unlinked') }}

+ 15 - 19
resource/js/legacy/crowi.js

@@ -236,8 +236,8 @@ $(function() {
 
   // rename
   $('#renamePage').on('shown.bs.modal', function (e) {
-    $('#newPageName').focus();
-    $('.msg-already-exists').hide();
+    $('#renamePage #newPageName').focus();
+    $('#renamePage .msg-already-exists').hide();
   });
   $('#renamePageForm, #unportalize-form').submit(function(e) {
     // create name-value map
@@ -254,11 +254,12 @@ $(function() {
     }).done(function(res) {
       if (!res.ok) {
         // if already exists
-        $('.msg-already-exists').show();
-        $('#linkToNewPage').html(`
+        $('#renamePage .msg-already-exists').show();
+        $('#renamePage #linkToNewPage').html(`
           <a href="${nameValueMap.new_path}">${nameValueMap.new_path} <i class="icon-login"></i></a>
         `);
-      } else {
+      }
+      else {
         var page = res.page;
         top.location.href = page.path + '?renamed=' + pagePath;
       }
@@ -269,7 +270,8 @@ $(function() {
 
   // duplicate
   $('#duplicatePage').on('shown.bs.modal', function (e) {
-    $('#duplicatePageName').focus();
+    $('#duplicatePage #duplicatePageName').focus();
+    $('#duplicatePage .msg-already-exists').hide();
   });
   $('#duplicatePageForm, #unportalize-form').submit(function (e) {
     // create name-value map
@@ -283,23 +285,17 @@ $(function() {
       url: '/_api/pages.duplicate',
       data: $(this).serialize(),
       dataType: 'json'
-    }).done(function (res) {
+    }).done(function(res) {
       if (!res.ok) {
         // if already exists
-        $('#duplicatePageNameCheck').html('<i class="fa fa-times-circle"></i> ' + res.error);
-        $('#duplicatePageNameCheck').addClass('alert-danger');
-        $('#linkToNewPage').html(`
-          <i class="fa fa-fw fa-arrow-right"></i><a href="${nameValueMap.new_path}">${nameValueMap.new_path}</a>
+        $('#duplicatePage .msg-already-exists').show();
+        $('#duplicatePage #linkToNewPage').html(`
+          <a href="${nameValueMap.new_path}">${nameValueMap.new_path} <i class="icon-login"></i></a>
         `);
-      } else {
+      }
+      else {
         var page = res.page;
-
-        $('#duplicatePageNameCheck').removeClass('alert-danger');
-        $('#duplicatePageNameCheck').html('<img src="/images/loading_s.gif"> Page duplicated! Redirecting to new page location.');
-
-        setTimeout(function () {
-          top.location.href = page.path + '?duplicated=' + pagePath;
-        }, 1000);
+        top.location.href = page.path + '?duplicated=' + pagePath;
       }
     });