Bug 32991: Don't display breadcrumb if pref is off
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / vue / components / ERM / Main.vue
1 <template>
2     <div v-if="ERMModule">
3         <Breadcrumb />
4         <div class="main container-fluid">
5             <div class="row">
6                 <div class="col-sm-10 col-sm-push-2">
7                     <main>
8                         <Dialog />
9                         <router-view />
10                     </main>
11                 </div>
12
13                 <div class="col-sm-2 col-sm-pull-10">
14                     <aside>
15                         <div id="navmenu">
16                             <div id="navmenulist">
17                                 <h5>{{ $__("E-resource management") }}</h5>
18                                 <ul>
19                                     <li>
20                                         <router-link
21                                             to="/cgi-bin/koha/erm/agreements"
22                                         >
23                                             <i class="fa fa-check-circle-o"></i>
24                                             {{ $__("Agreements") }}</router-link
25                                         >
26                                     </li>
27                                     <li>
28                                         <router-link
29                                             to="/cgi-bin/koha/erm/licenses"
30                                         >
31                                             <i class="fa fa-gavel"></i>
32                                             {{ $__("Licenses") }}</router-link
33                                         >
34                                     </li>
35                                     <li>
36                                         <router-link
37                                             to="/cgi-bin/koha/erm/eholdings"
38                                             class="disabled"
39                                         >
40                                             <i class="fa fa-crosshairs"></i>
41                                             {{ $__("eHoldings") }}
42                                         </router-link>
43                                     </li>
44
45                                     <li>
46                                         <ul>
47                                             <li
48                                                 v-for="provider in erm_providers"
49                                                 :key="provider"
50                                             >
51                                                 <router-link
52                                                     v-if="provider == 'local'"
53                                                     :to="`/cgi-bin/koha/erm/eholdings/local`"
54                                                     class="disabled"
55                                                 >
56                                                     <i
57                                                         class="fa fa-map-marker"
58                                                     ></i>
59                                                     {{
60                                                         $__("Local")
61                                                     }}</router-link
62                                                 >
63                                                 <router-link
64                                                     v-else-if="
65                                                         provider == 'ebsco'
66                                                     "
67                                                     :to="`/cgi-bin/koha/erm/eholdings/ebsco`"
68                                                     class="disabled"
69                                                 >
70                                                     <i class="fa fa-globe"></i>
71                                                     {{
72                                                         $__("EBSCO")
73                                                     }}</router-link
74                                                 >
75                                                 <ul>
76                                                     <li>
77                                                         <router-link
78                                                             :to="`/cgi-bin/koha/erm/eholdings/${provider}/packages`"
79                                                         >
80                                                             <i
81                                                                 class="fa fa-archive"
82                                                             ></i>
83                                                             {{
84                                                                 $__("Packages")
85                                                             }}</router-link
86                                                         >
87                                                     </li>
88                                                     <li>
89                                                         <router-link
90                                                             :to="`/cgi-bin/koha/erm/eholdings/${provider}/titles`"
91                                                         >
92                                                             <i
93                                                                 class="fa fa-sort-alpha-asc"
94                                                             ></i>
95                                                             {{
96                                                                 $__("Titles")
97                                                             }}</router-link
98                                                         >
99                                                     </li>
100                                                 </ul>
101                                             </li>
102                                         </ul>
103                                     </li>
104                                 </ul>
105                             </div>
106                         </div>
107                     </aside>
108                 </div>
109             </div>
110         </div>
111     </div>
112     <div class="main container-fluid" v-else>
113         <Dialog />
114     </div>
115 </template>
116
117 <script>
118 import { inject } from "vue"
119 import Breadcrumb from "../../components/Breadcrumb.vue"
120 import Dialog from "../../components/Dialog.vue"
121 import { APIClient } from "../../fetch/api-client.js"
122 import "vue-select/dist/vue-select.css"
123 import { storeToRefs } from "pinia"
124
125 export default {
126     setup() {
127         const vendorStore = inject("vendorStore")
128
129         const AVStore = inject("AVStore")
130
131         const mainStore = inject("mainStore")
132
133         const { loading, loaded, setError } = mainStore
134
135         return {
136             vendorStore,
137             AVStore,
138             setError,
139             erm_providers,
140             ERMModule,
141             loading,
142             loaded,
143         }
144     },
145     data() {
146         return {
147             component: "agreement",
148         }
149     },
150     beforeCreate() {
151         if (!this.ERMModule) {
152             return this.setError(
153                 this.$__(
154                     'The e-resource management module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule">ERMModule</a> to use it'
155                 ),
156                 false
157             )
158         }
159         this.loading()
160
161         const acq_client = APIClient.acquisition
162         acq_client.vendors.getAll().then(
163             vendors => {
164                 this.vendorStore.vendors = vendors
165                 this.initialized = true
166             },
167             error => {}
168         )
169
170         const av_client = APIClient.authorised_values
171         const authorised_values = {
172             av_agreement_statuses: "ERM_AGREEMENT_STATUS",
173             av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
174             av_agreement_renewal_priorities: "ERM_AGREEMENT_RENEWAL_PRIORITY",
175             av_user_roles: "ERM_USER_ROLES",
176             av_license_types: "ERM_LICENSE_TYPE",
177             av_license_statuses: "ERM_LICENSE_STATUS",
178             av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS",
179             av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION",
180             av_package_types: "ERM_PACKAGE_TYPE",
181             av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE",
182             av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE",
183         }
184
185         let av_cat_array = Object.keys(authorised_values).map(function (
186             av_cat
187         ) {
188             return '"' + authorised_values[av_cat] + '"'
189         })
190
191         av_client.values
192             .getCategoriesWithValues(av_cat_array)
193             .then(av_categories => {
194                 Object.entries(authorised_values).forEach(
195                     ([av_var, av_cat]) => {
196                         const av_match = av_categories.find(
197                             element => element.category_name == av_cat
198                         )
199                         this.AVStore[av_var] = av_match.authorised_values
200                     }
201                 )
202             })
203             .then(() => this.loaded())
204     },
205     components: {
206         Breadcrumb,
207         Dialog,
208     },
209 }
210 </script>
211
212 <style>
213 #navmenulist a.router-link-active {
214     font-weight: 700;
215 }
216 #menu ul ul,
217 #navmenulist ul ul {
218     padding-left: 2em;
219     font-size: 100%;
220 }
221
222 form .v-select {
223     display: inline-block;
224     background-color: white;
225     width: 30%;
226 }
227
228 .v-select,
229 input:not([type="submit"]):not([type="search"]):not([type="button"]):not([type="checkbox"]),
230 textarea {
231     border-color: rgba(60, 60, 60, 0.26);
232     border-width: 1px;
233     border-radius: 4px;
234     min-width: 30%;
235 }
236 .flatpickr-input {
237     width: 30%;
238 }
239
240 #navmenulist ul li a.disabled {
241     color: #666;
242     pointer-events: none;
243     font-weight: 700;
244 }
245 #navmenulist ul li a.disabled.router-link-active {
246     color: #000;
247 }
248 </style>