| 
      
            Line 0
          
      
      
        Link Here
      
     | 
  
            
               | 
               | 
              1 | 
              <template>  | 
            
            
              | 2 | 
                  <div v-if="!initialized">{{ $__("Loading") }}</div> | 
            
            
              | 3 | 
                  <div v-else id="record_sources_list">  | 
            
            
              | 4 | 
                      <Toolbar>  | 
            
            
              | 5 | 
                          <ToolbarButton  | 
            
            
              | 6 | 
                              :to="{ name: 'Add' }" | 
            
            
              | 7 | 
                              icon="plus"  | 
            
            
              | 8 | 
                              :title="$__('New record source')" | 
            
            
              | 9 | 
                          />  | 
            
            
              | 10 | 
                      </Toolbar>  | 
            
            
              | 11 | 
                      <h1>{{ title }}</h1> | 
            
            
              | 12 | 
                      <div v-if="record_sources_count > 0" class="page-section">  | 
            
            
              | 13 | 
                          <KohaTable  | 
            
            
              | 14 | 
                              ref="table"  | 
            
            
              | 15 | 
                              v-bind="tableOptions"  | 
            
            
              | 16 | 
                              @edit="doEdit"  | 
            
            
              | 17 | 
                              @delete="doDelete"  | 
            
            
              | 18 | 
                          ></KohaTable>  | 
            
            
              | 19 | 
                      </div>  | 
            
            
              | 20 | 
                      <div v-else class="dialog message">  | 
            
            
              | 21 | 
                          {{ $__("There are no record sources defined") }} | 
            
            
              | 22 | 
                      </div>  | 
            
            
              | 23 | 
                  </div>  | 
            
            
              | 24 | 
              </template>  | 
            
            
              | 25 | 
               | 
            
            
              | 26 | 
              <script>  | 
            
            
              | 27 | 
              import Toolbar from "../../Toolbar.vue"  | 
            
            
              | 28 | 
              import ToolbarButton from "../../ToolbarButton.vue"  | 
            
            
              | 29 | 
              import { inject } from "vue" | 
            
            
              | 30 | 
              import { RecordSourcesClient } from "../../../fetch/record-sources" | 
            
            
              | 31 | 
              import KohaTable from "../../KohaTable.vue"  | 
            
            
              | 32 | 
              export default { | 
            
            
              | 33 | 
                  name: "List",  | 
            
            
              | 34 | 
                  data() { | 
            
            
              | 35 | 
                      return { | 
            
            
              | 36 | 
                          title: this.$__("Record sources"), | 
            
            
              | 37 | 
                          tableOptions: { | 
            
            
              | 38 | 
                              columns: [  | 
            
            
              | 39 | 
                                  { | 
            
            
              | 40 | 
                                      title: this.$__("ID"), | 
            
            
              | 41 | 
                                      data: "record_source_id",  | 
            
            
              | 42 | 
                                      searchable: true,  | 
            
            
              | 43 | 
                                  },  | 
            
            
              | 44 | 
                                  { | 
            
            
              | 45 | 
                                      title: this.$__("Name"), | 
            
            
              | 46 | 
                                      data: "name",  | 
            
            
              | 47 | 
                                      searchable: true,  | 
            
            
              | 48 | 
                                  },  | 
            
            
              | 49 | 
                                  { | 
            
            
              | 50 | 
                                      title: __("Can be edited"), | 
            
            
              | 51 | 
                                      data: "can_be_edited",  | 
            
            
              | 52 | 
                                      searchable: true,  | 
            
            
              | 53 | 
                                      orderable: true,  | 
            
            
              | 54 | 
                                      render: function (data, type, row, meta) { | 
            
            
              | 55 | 
                                          return escape_str(  | 
            
            
              | 56 | 
                                              row.can_be_edited ? __("Yes") : __("No") | 
            
            
              | 57 | 
                                          )  | 
            
            
              | 58 | 
                                      },  | 
            
            
              | 59 | 
                                  },  | 
            
            
              | 60 | 
                              ],  | 
            
            
              | 61 | 
                              actions: { | 
            
            
              | 62 | 
                                  "-1": ["edit", "delete"],  | 
            
            
              | 63 | 
                              },  | 
            
            
              | 64 | 
                              url: "/api/v1/record_sources",  | 
            
            
              | 65 | 
                          },  | 
            
            
              | 66 | 
                          initialized: false,  | 
            
            
              | 67 | 
                          record_sources_count: 0,  | 
            
            
              | 68 | 
                      }  | 
            
            
              | 69 | 
                  },  | 
            
            
              | 70 | 
                  setup() { | 
            
            
              | 71 | 
                      const { setWarning, setMessage, setError, setConfirmationDialog } = | 
            
            
              | 72 | 
                          inject("mainStore") | 
            
            
              | 73 | 
                      const { record_source } = new RecordSourcesClient() | 
            
            
              | 74 | 
                      return { | 
            
            
              | 75 | 
                          setWarning,  | 
            
            
              | 76 | 
                          setMessage,  | 
            
            
              | 77 | 
                          setError,  | 
            
            
              | 78 | 
                          setConfirmationDialog,  | 
            
            
              | 79 | 
                          api: record_source,  | 
            
            
              | 80 | 
                      }  | 
            
            
              | 81 | 
                  },  | 
            
            
              | 82 | 
                  beforeRouteEnter(to, from, next) { | 
            
            
              | 83 | 
                      next(vm => { | 
            
            
              | 84 | 
                          vm.getRecordSourcesCount().then(() => (vm.initialized = true))  | 
            
            
              | 85 | 
                      })  | 
            
            
              | 86 | 
                  },  | 
            
            
              | 87 | 
                  methods: { | 
            
            
              | 88 | 
                      async getRecordSourcesCount() { | 
            
            
              | 89 | 
                          const count = await this.api.count()  | 
            
            
              | 90 | 
                          this.record_sources_count = count  | 
            
            
              | 91 | 
                      },  | 
            
            
              | 92 | 
                      newRecordSource() { | 
            
            
              | 93 | 
                          this.$router.push({ path: "record-sources/add" }) | 
            
            
              | 94 | 
                      },  | 
            
            
              | 95 | 
                      doEdit(data) { | 
            
            
              | 96 | 
                          this.$router.push({ | 
            
            
              | 97 | 
                              path: `record-sources/${data.record_source_id}`, | 
            
            
              | 98 | 
                              props: { | 
            
            
              | 99 | 
                                  data,  | 
            
            
              | 100 | 
                              },  | 
            
            
              | 101 | 
                          })  | 
            
            
              | 102 | 
                      },  | 
            
            
              | 103 | 
                      doDelete(data, dt) { | 
            
            
              | 104 | 
                          this.setConfirmationDialog(  | 
            
            
              | 105 | 
                              { | 
            
            
              | 106 | 
                                  title: this.$__(  | 
            
            
              | 107 | 
                                      "Are you sure you want to remove this record source?"  | 
            
            
              | 108 | 
                                  ),  | 
            
            
              | 109 | 
                                  message: data.name,  | 
            
            
              | 110 | 
                                  accept_label: this.$__("Yes, remove"), | 
            
            
              | 111 | 
                                  cancel_label: this.$__("No, do not remove"), | 
            
            
              | 112 | 
                              },  | 
            
            
              | 113 | 
                              () => { | 
            
            
              | 114 | 
                                  this.api  | 
            
            
              | 115 | 
                                      .delete({ | 
            
            
              | 116 | 
                                          id: data.record_source_id,  | 
            
            
              | 117 | 
                                      })  | 
            
            
              | 118 | 
                                      .then(response => { | 
            
            
              | 119 | 
                                          if (response) { | 
            
            
              | 120 | 
                                              this.setMessage(  | 
            
            
              | 121 | 
                                                  this.$__(  | 
            
            
              | 122 | 
                                                      "Record source '%s' removed"  | 
            
            
              | 123 | 
                                                  ).format(data.name),  | 
            
            
              | 124 | 
                                                  true  | 
            
            
              | 125 | 
                                              )  | 
            
            
              | 126 | 
                                              dt.draw()  | 
            
            
              | 127 | 
                                          }  | 
            
            
              | 128 | 
                                      })  | 
            
            
              | 129 | 
                              }  | 
            
            
              | 130 | 
                          )  | 
            
            
              | 131 | 
                      },  | 
            
            
              | 132 | 
                  },  | 
            
            
              | 133 | 
                  components: { | 
            
            
              | 134 | 
                      KohaTable,  | 
            
            
              | 135 | 
                      Toolbar,  | 
            
            
              | 136 | 
                      ToolbarButton,  | 
            
            
              | 137 | 
                  },  | 
            
            
              | 138 | 
              }  | 
            
            
              | 139 | 
              </script>  |