PageSourceSearch

https://cadeaubonnen.sheetz.nl/assets/controllers/admin/store-change_controller-8bFQZpE.js

js sheetz.nl collected 2026-10-04 01:39:22 UTC 4,200 bytes, 130 lines download raw bytes

1import { Controller } from '@hotwired/stimulus';
2
3export default class extends Controller {
4
5
6    changeStore()
7    {
8
9        const storeSelect = document.querySelector('select[data-action*="change->admin--store-change#changeStore"]');
10        if (! storeSelect.querySelector('option:checked')) return;
11
12        const form = storeSelect.closest('form');
13        
14        const storeId = storeSelect.querySelector('option:checked').value;
15        const storeData = this.getStore(storeId);
16
17        this.updateDefaults(form, storeData);
18        this.updateCurrency(form, storeData);
19        this.updateStoreIDLinks(form, storeData);
20    
21    }
22
23
24    getStore(id)
25    {
26        return glu.stores[id];
27    }
28
29
30    updateCurrency(form, storeData) {
31
32        const currencySymbol = storeData.currencySymbol;
33        const currencyIcons = form.querySelectorAll('.input_wrapper .icon--currency');
34        
35        if (currencySymbol) {
36            currencyIcons.forEach((icon) => {
37                icon.innerHTML = currencySymbol;
38            });
39        }
40
41    }
42
43
44    updateStoreIDLinks(form, storeData)
45    {
46        const storeId = storeData.id;
47        const storeIdLinks = form.querySelectorAll('a[data-store-change-update-id]');
48
49        storeIdLinks.forEach((link) => {
50            let newLink = link.dataset.storeChangeUpdateId.replace('%23', storeId);
51            link.href = newLink;
52        });
53    }
54
55
56    updateDefaults(form, storeData)
57    {
58        if (form.name == "product") {
59            this.updateValidityFormFields(form, storeData);
60            this.updateTermsFormFields(form, storeData);
61        }
62
63    }
64
65
66    updateValidityFormFields(form, data)
67    {
68
69        // Get USING DEFAULT checkbox checked state
70        const usingStoreValidity = form.querySelector('[name="product[voucher][usingStoreValidity]"]').checked;
71
72        if(usingStoreValidity) {
73
74            const validityPeriod = form.querySelector('[name="product[voucher][validityPeriod]"]');
75            const validityLength = form.querySelector('[name="product[voucher][validityLength]"]');
76            const validityFixedDate = form.querySelector('[name="product[voucher][validityFixedDate]"]');
77            const hasValidFrom = form.querySelector('[name="product[voucher][hasValidFrom]"]');
78            const validFromPeriod = form.querySelector('[name="product[voucher][validFromPeriod]"]');
79            const validFromLength = form.querySelector('[name="product[voucher][validFromLength]"]');
80            const validFromFixedDate = form.querySelector('[name="product[voucher][validFromFixedDate]"]');
81
82            if(usingStoreValidity == '1') {
83                
84                validityLength.value = data.validityLength;
85                validityFixedDate.value = data.validityFixedDate;
86
87                if(data.validFromPeriod != '' && form.querySelector('[name="product[voucher][validFromPeriod]"] option[value="'+data.validFromPeriod+'"]')) {
88
89                    validityPeriod.value = data.validityPeriod;
90                    validityPeriod.dispatchEvent(new Event('change', { bubbles: true }));
91
92                }
93
94                if(data.hasValidFrom) {
95                    hasValidFrom.checked = true;
96                } else {
97                    hasValidFrom.checked = false;
98                }
99
100                if(data.validFromPeriod != '' && form.querySelector('[name="product[voucher][validFromPeriod]"] option[value="'+data.validFromPeriod+'"]')) {
101
102                    validFromPeriod.value = data.validFromPeriod;
103                    validFromPeriod.dispatchEvent(new Event('change', { bubbles: true }));
104
105                }
106
107                validFromLength.value = data.validFromLength;
108                validFromFixedDate.value = data.validFromFixedDate;
109
110            }
111
112        }
113
114    }
115
116
117    updateTermsFormFields(form, data) 
118    {
119
120        // Get USING DEFAULT checkbox checked state
121        const usingStoreTerms = form.querySelector('[name="product[voucher][usingStoreTerms]"]').checked;
122
123        if(usingStoreTerms == '1') {    
124            const termsInput = form.querySelector('[name="product[voucher][terms]"]');
125            termsInput.value = data.defaultVoucherTerms;
126        }
127
128    }
129
130}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.