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

Fix: Link of Create template page button in New Page modal is broken

Yuki Takei 6 лет назад
Родитель
Сommit
728b827719

+ 4 - 3
src/server/views/modal/create_page.html

@@ -44,9 +44,10 @@
           </fieldset>
         </form>
 
+        {% set templateParentPath = parentPath(path | preventXss | escape) %}
         <div id="template-form" class="row form-horizontal m-t-15">
           <fieldset class="col-xs-12">
-            <legend>{{ t('template.modal_label.Create template under', parentPath(path | preventXss | escape)) }}</legend>
+            <legend>{{ t('template.modal_label.Create template under', templateParentPath) }}</legend>
             <div class="d-flex create-page-input-container">
               <div class="create-page-input-row d-flex align-items-center">
                 <select id="template-type" class="form-control selectpicker" title="{{ t('template.option_label.select') }}">
@@ -72,8 +73,8 @@
             // modify href
             const value = $(this).val();
             const pageName = (value === 'children') ? '_template' : '__template';
-            const truePath = "{% if page.path || path %}{{ page.path || path | addTrailingSlash }}{% else %}{{ page.path || path }}{% endif %}"
-            const link = truePath + pageName + '#edit-form';
+            const parentPath = '{{templateParentPath}}';
+            const link = parentPath + pageName + '#edit-form';
             $('#link-to-template').attr('href', link);
           });
         </script>

+ 5 - 3
src/server/views/modal/create_template.html

@@ -1,3 +1,5 @@
+{% set templateParentPath = parentPath(page.path | preventXss | escape) %}
+
 <div class="modal create-template" id="create-template">
   <div class="modal-dialog">
     <div class="modal-content">
@@ -8,7 +10,7 @@
       </div>
       <div class="modal-body">
         <div class="form-group">
-          <label class="mb-4">{{ t('template.modal_label.Create template under', page.path ) }}</label>
+          <label class="mb-4">{{ t('template.modal_label.Create template under', templateParentPath ) }}</label>
           <div class="row">
             <div class="col-sm-6">
               <div class="panel panel-default panel-select-template">
@@ -18,7 +20,7 @@
                   <p class="help-block text-center"><small>{{ t('template.children.desc') }}</small></p>
                 </div>
                 <div class="panel-footer text-center">
-                  <a href="{% if page.path.endsWith('/') %}{{ page.path }}{% else %}{{ page.path}}/{% endif %}_template#edit"
+                  <a href="{{templateParentPath}}_template#edit"
                       class="btn btn-sm btn-primary" id="template-button-children">
                       {{ t("Edit") }}
                   </a>
@@ -33,7 +35,7 @@
                   <p class="help-block text-center"><small>{{ t('template.decendants.desc') }}</small></p>
                 </div>
                 <div class="panel-footer text-center">
-                  <a href="{% if page.path.endsWith('/') %}{{ page.path }}{% else %}{{ page.path }}/{% endif %}__template#edit"
+                  <a href="{{templateParentPath}}__template#edit"
                       class="btn btn-sm btn-primary" id="template-button-decendants">
                       {{ t("Edit") }}
                   </a>