Explorar o código

add edit link for admin

axolotle %!s(int64=2) %!d(string=hai) anos
pai
achega
bdfb80e092
Modificáronse 2 ficheiros con 16 adicións e 1 borrados
  1. 14 1
      src/components/nodes/NodeViewFooter.vue
  2. 2 0
      src/store/nodes.js

+ 14 - 1
src/components/nodes/NodeViewFooter.vue

@@ -13,6 +13,14 @@
           </b-badge>
         </div>
 
+        <b-button
+          v-if="debug"
+          variant="kit" class="btn-edit"
+          :href="`/api/node/${node.id}/edit?destination=/api/node/${node.id}`" target="_blank"
+        >
+          Éditer
+        </b-button>
+
         <div v-if="mode === 'view' && node.siblings && node.siblings.length">
           <b-button :id="'siblings-' + node.id" variant="depart" class="btn-shadow siblings">
             {{ $t('siblings') }}
@@ -63,6 +71,8 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
+
 import { toCommaList } from '@/helpers/common'
 import { getRelation } from '@/store/utils'
 import { NodeViewTitle, NodeViewBody } from '@/components/nodes'
@@ -85,6 +95,8 @@ export default {
   },
 
   computed: {
+    ...mapGetters(['debug']),
+
     authors () {
       const authors = this.node.authors
       if (!authors) return 'Pas d\'auteur⋅rices'
@@ -136,7 +148,8 @@ export default {
     }
   }
 
-  .btn-read {
+  .btn-read,
+  .btn-edit {
     pointer-events: auto;
   }
 

+ 2 - 0
src/store/nodes.js

@@ -17,6 +17,7 @@ import {
 
 export default {
   state: {
+    debug: localStorage.getItem('debug') === 'true',
     nodes: {},
     history: [],
     optionsVisible: true,
@@ -170,6 +171,7 @@ export default {
   },
 
   getters: {
+    debug: state => state.debug,
     allNodes: state => state.nodes,
     // Args getters
     nodes: state => ids => ids.map(id => state.nodes[id]),