@controleonline/ui-default 1.0.270 → 1.0.273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/integration-source-gate.yml +68 -0
- package/.github/workflows/manager-worker.yml +19 -0
- package/.github/workflows/publish-npm.yml +91 -0
- package/AGENTS.md +46 -50
- package/docs/technical/Contrato-de-colunas.md +67 -0
- package/docs/technical/Default-Components.md +76 -0
- package/docs/technical/DefaultForm.md +80 -0
- package/docs/technical/DefaultInput-e-DefaultSelect.md +73 -0
- package/docs/technical/DefaultTable.md +272 -0
- package/docs/wiki.md +1 -0
- package/package.json +4 -3
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/address/DefaultAddress.js +446 -0
- package/src/react/components/address/DefaultAddress.styles.js +133 -0
- package/src/react/components/address/DefaultAddressCoordFields.js +59 -0
- package/src/react/components/address/DefaultAddressMapPane.js +55 -0
- package/src/react/components/address/LatLonReadonlyFields.js +51 -0
- package/src/react/components/address/defaultAddressHelpers.js +163 -0
- package/src/react/components/address/defaultAddressStyles.js +148 -0
- package/src/react/components/address/defaultAddressUtils.js +129 -0
- package/src/react/components/extra-data/DefaultExtraData.js +152 -0
- package/src/react/components/extra-data/DefaultExtraData.styles.js +61 -0
- package/src/react/components/files/DefaultFile.js +231 -46
- package/src/react/components/files/DefaultFileColumn.js +123 -0
- package/src/react/components/files/DefaultFileColumn.styles.js +52 -0
- package/src/react/components/files/DefaultFileColumn.utils.js +104 -0
- package/src/react/components/filters/CompactFilterSelector.js +51 -35
- package/src/react/components/filters/DefaultColumnFilter.js +60 -48
- package/src/react/components/filters/DefaultExternalFilters.js +324 -265
- package/src/react/components/filters/filterValue.js +65 -0
- package/src/react/components/form/DefaultForm.js +99 -79
- package/src/react/components/help/DefaultTooltip.js +48 -12
- package/src/react/components/help/DefaultTooltip.styles.js +20 -0
- package/src/react/components/inputs/DefaultColorInput.js +153 -0
- package/src/react/components/inputs/DefaultFeatherIconPicker.js +146 -0
- package/src/react/components/inputs/DefaultFeatherIconPicker.styles.js +113 -0
- package/src/react/components/inputs/DefaultInput.js +296 -141
- package/src/react/components/inputs/DefaultInput.styles.js +26 -0
- package/src/react/components/inputs/DefaultSelect.js +134 -123
- package/src/react/components/inputs/defaultInputUtils.js +262 -213
- package/src/react/components/map/DefaultMap.native.js +73 -73
- package/src/react/components/map/DefaultMap.shared.js +911 -762
- package/src/react/components/map/DefaultMap.web.js +124 -68
- package/src/react/components/table/DefaultColumnMenu.js +22 -3
- package/src/react/components/table/DefaultDebug.js +44 -37
- package/src/react/components/table/DefaultSearchModal.js +9 -1
- package/src/react/components/table/DefaultTable.grouping.js +98 -0
- package/src/react/components/table/DefaultTable.js +217 -111
- package/src/react/components/table/DefaultTable.styles.js +369 -310
- package/src/react/components/table/DefaultTable.utils.js +38 -4
- package/src/react/components/table/DefaultTableBody.js +13 -8
- package/src/react/components/table/DefaultTableCards.js +20 -1
- package/src/react/components/table/DefaultTableControls.js +180 -205
- package/src/react/components/table/DefaultTableImportModal.js +108 -0
- package/src/react/components/table/DefaultTableInput.js +1 -0
- package/src/react/components/table/DefaultTableRowActions.js +1 -1
- package/src/react/components/table/DefaultTableRows.js +357 -325
- package/src/react/components/table/DefaultTableSearch.js +28 -5
- package/src/react/components/table/DefaultTableToolbar.js +92 -3
- package/src/react/components/table/useDefaultTablePagination.js +56 -7
- package/src/react/components/table/useDefaultTableStoreSync.js +164 -0
- package/src/react/components/upload/DefaultUpload.js +406 -0
- package/src/react/components/upload/DefaultUpload.styles.js +153 -0
- package/src/react/components/upload/DefaultUploadAttachmentsList.js +146 -0
- package/src/react/components/upload/DefaultUploadManagerModal.js +247 -0
- package/src/react/components/upload/defaultUploadHelpers.js +108 -0
- package/src/react/components/upload/defaultUploadLibrary.js +248 -0
- package/src/react/components/upload/fileUpload.js +93 -0
- package/src/react/hooks/usePostalCodeLookup.js +159 -0
- package/src/react/index.js +6 -0
- package/src/react/services/addressFormUtils.js +262 -0
- package/src/react/services/addressGeo.js +230 -0
- package/src/react/utils/tableVisibleColumnsPreferences.js +113 -15
- package/src/tests/react/components/address/defaultAddressHelpers.test.js +104 -0
- package/src/tests/react/components/files/DefaultFile.test.js +22 -6
- package/src/tests/react/components/files/DefaultFileColumn.company.test.js +24 -0
- package/src/tests/react/components/form/DefaultForm.test.js +123 -0
- package/src/tests/react/components/help/DefaultTooltip.test.js +93 -0
- package/src/tests/react/components/inputs/DefaultSelect.test.js +108 -79
- package/src/tests/react/components/table/DefaultTable.grouping.test.js +49 -0
- package/src/tests/react/components/table/DefaultTable.test.js +53 -2
- package/src/tests/react/components/table/DefaultTable.utils.test.js +10 -0
- package/src/tests/react/components/table/DefaultTableControls.filters.test.mjs +21 -0
- package/src/tests/react/components/table/DefaultTableRowActions.test.js +23 -0
- package/src/tests/react/components/table/DefaultTableRows.rowActions.test.js +152 -0
- package/src/tests/react/components/table/resolveRowBackgroundColor.test.mjs +45 -0
- package/src/tests/react/components/table/useDefaultTableStoreSync.test.js +161 -0
- package/src/tests/react/components/upload/DefaultUpload.test.js +353 -0
- package/src/tests/react/components/upload/defaultUploadLibrary.test.js +104 -0
- package/src/tests/react/components/upload/peopleMediaLibraryPreview.test.mjs +57 -0
- package/src/tests/react/filters/filterValue.test.js +46 -0
- package/src/tests/react/hooks/usePostalCodeLookup.test.js +107 -0
- package/src/tests/react/inputs/defaultInputUtils.test.js +9 -1
- package/src/tests/react/services/SMOKE-637-cep-hydrate.md +45 -0
- package/src/tests/react/services/addressFormUtils.test.js +179 -0
- package/src/tests/react/services/addressGeoLookup.async.test.js +104 -0
- package/src/tests/react/services/addressGeoLookup.test.js +105 -0
- package/src/tests/react/services/smoke-637/form-cep-12941040.png +0 -0
- package/src/tests/react/services/smoke-637/index.html +132 -0
- package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +96 -49
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="pt-BR">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Smoke #637 — address-cep-hydrate</title>
|
|
6
|
+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
|
7
|
+
<style>
|
|
8
|
+
body { font-family: system-ui, sans-serif; margin: 16px; background: #f6f7f9; }
|
|
9
|
+
h1 { font-size: 18px; }
|
|
10
|
+
label { display: block; font-size: 12px; color: #555; margin-top: 8px; }
|
|
11
|
+
input { width: 100%; max-width: 420px; padding: 8px; font-size: 14px; }
|
|
12
|
+
#map { height: 320px; width: 100%; max-width: 720px; margin-top: 12px; border: 1px solid #ccc; }
|
|
13
|
+
.row { display: flex; gap: 12px; flex-wrap: wrap; }
|
|
14
|
+
.col { flex: 1; min-width: 200px; }
|
|
15
|
+
#status { margin-top: 8px; font-size: 13px; }
|
|
16
|
+
.ok { color: #0a7; }
|
|
17
|
+
.err { color: #c00; }
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<h1>DefaultAddress smoke — CEP hydrate (#637)</h1>
|
|
22
|
+
<p>fluxo: address-cep-hydrate · CEP 12941040 · pin ui-default lookupPostalCode</p>
|
|
23
|
+
<div class="row">
|
|
24
|
+
<div class="col">
|
|
25
|
+
<label>CEP</label>
|
|
26
|
+
<input id="address-cep-input" data-testid="address-cep-input" value="12941040" />
|
|
27
|
+
<label>Rua</label>
|
|
28
|
+
<input id="address-street-input" data-testid="address-street-input" />
|
|
29
|
+
<label>Bairro</label>
|
|
30
|
+
<input id="address-district-input" data-testid="address-district-input" />
|
|
31
|
+
<label>Cidade</label>
|
|
32
|
+
<input id="address-city-input" data-testid="address-city-input" />
|
|
33
|
+
<label>UF</label>
|
|
34
|
+
<input id="address-uf-input" data-testid="address-uf-input" />
|
|
35
|
+
</div>
|
|
36
|
+
<div class="col">
|
|
37
|
+
<label>Latitude</label>
|
|
38
|
+
<input id="address-latitude-input" data-testid="address-latitude-input" value="—" />
|
|
39
|
+
<label>Longitude</label>
|
|
40
|
+
<input id="address-longitude-input" data-testid="address-longitude-input" value="—" />
|
|
41
|
+
<label>Provider</label>
|
|
42
|
+
<input id="address-provider-input" />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div id="status">aguardando lookup…</div>
|
|
46
|
+
<div id="map"></div>
|
|
47
|
+
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
|
48
|
+
<script>
|
|
49
|
+
const TOKEN = '4a073f4bf39f4a2ed19818baf44c4b3d';
|
|
50
|
+
const API = 'https://api.controleonline.com';
|
|
51
|
+
const onlyDigits = v => String(v || '').replace(/\D+/g, '');
|
|
52
|
+
const hasText = v => String(v || '').trim().length > 0;
|
|
53
|
+
const isValidCoord = v => {
|
|
54
|
+
if (v === null || v === undefined || v === '' || v === '—') return false;
|
|
55
|
+
const n = Number(v);
|
|
56
|
+
return Number.isFinite(n) && Math.abs(n) > 0.000001;
|
|
57
|
+
};
|
|
58
|
+
function merge(base, extra, suffix) {
|
|
59
|
+
const next = { ...(base || {}) };
|
|
60
|
+
const fill = (k, val) => { if (!hasText(next[k]) && hasText(val)) next[k] = val; };
|
|
61
|
+
fill('street', extra.street);
|
|
62
|
+
fill('district', extra.district);
|
|
63
|
+
fill('city', extra.city);
|
|
64
|
+
fill('state', extra.state || extra.uf);
|
|
65
|
+
fill('uf', extra.uf || extra.state);
|
|
66
|
+
if (!isValidCoord(next.latitude) && isValidCoord(extra.latitude)) next.latitude = Number(extra.latitude);
|
|
67
|
+
if (!isValidCoord(next.longitude) && isValidCoord(extra.longitude)) next.longitude = Number(extra.longitude);
|
|
68
|
+
if (suffix) next.provider = next.provider ? next.provider + '+' + suffix : suffix;
|
|
69
|
+
return next;
|
|
70
|
+
}
|
|
71
|
+
async function lookupPostalCode(cep) {
|
|
72
|
+
const digits = onlyDigits(cep);
|
|
73
|
+
let payload = { cep: digits };
|
|
74
|
+
try {
|
|
75
|
+
const r = await fetch(API + '/postal-codes/' + digits, {
|
|
76
|
+
headers: {
|
|
77
|
+
accept: 'application/ld+json',
|
|
78
|
+
'api-token': TOKEN,
|
|
79
|
+
'app-domain': 'admin.controleonline.com',
|
|
80
|
+
device: 'web-7',
|
|
81
|
+
'device-type': 'ADMIN'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
if (r.ok) {
|
|
85
|
+
const apiData = await r.json();
|
|
86
|
+
payload = { ...payload, ...apiData, cep: digits };
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {}
|
|
89
|
+
if (!hasText(payload.street) || !hasText(payload.city)) {
|
|
90
|
+
const vr = await fetch('https://viacep.com.br/ws/' + digits + '/json/');
|
|
91
|
+
const json = await vr.json();
|
|
92
|
+
payload = merge(payload, {
|
|
93
|
+
street: json.logradouro, district: json.bairro, city: json.localidade, uf: json.uf, state: json.uf
|
|
94
|
+
}, 'viacep-client');
|
|
95
|
+
}
|
|
96
|
+
if (!isValidCoord(payload.latitude) || !isValidCoord(payload.longitude)) {
|
|
97
|
+
const q = encodeURIComponent([payload.street, payload.district, payload.city, payload.uf, 'Brasil'].filter(Boolean).join(', '));
|
|
98
|
+
const nr = await fetch('https://nominatim.openstreetmap.org/search?format=json&limit=1&q=' + q, {
|
|
99
|
+
headers: { 'Accept-Language': 'pt-BR' }
|
|
100
|
+
});
|
|
101
|
+
const arr = await nr.json();
|
|
102
|
+
if (arr[0]) payload = merge(payload, { latitude: arr[0].lat, longitude: arr[0].lon }, 'nominatim-client');
|
|
103
|
+
}
|
|
104
|
+
return payload;
|
|
105
|
+
}
|
|
106
|
+
const map = L.map('map').setView([0, 0], 2);
|
|
107
|
+
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OSM' }).addTo(map);
|
|
108
|
+
lookupPostalCode('12941040').then(p => {
|
|
109
|
+
document.getElementById('address-street-input').value = p.street || '';
|
|
110
|
+
document.getElementById('address-district-input').value = p.district || '';
|
|
111
|
+
document.getElementById('address-city-input').value = p.city || '';
|
|
112
|
+
document.getElementById('address-uf-input').value = p.uf || p.state || '';
|
|
113
|
+
document.getElementById('address-latitude-input').value = p.latitude;
|
|
114
|
+
document.getElementById('address-longitude-input').value = p.longitude;
|
|
115
|
+
document.getElementById('address-provider-input').value = p.provider || '';
|
|
116
|
+
const lat = Number(p.latitude), lon = Number(p.longitude);
|
|
117
|
+
map.setView([lat, lon], 16);
|
|
118
|
+
L.marker([lat, lon]).addTo(map);
|
|
119
|
+
const ok = p.city === 'Atibaia' && Math.abs(lat + 23.11) < 0.05;
|
|
120
|
+
const st = document.getElementById('status');
|
|
121
|
+
st.className = ok ? 'ok' : 'err';
|
|
122
|
+
st.textContent = ok
|
|
123
|
+
? 'OK: rua=' + p.street + ' cidade=' + p.city + ' UF=' + (p.uf||p.state) + ' lat/lon preenchidos mapa Atibaia'
|
|
124
|
+
: 'FAIL payload=' + JSON.stringify(p);
|
|
125
|
+
window.__SMOKE637__ = p;
|
|
126
|
+
}).catch(e => {
|
|
127
|
+
document.getElementById('status').className = 'err';
|
|
128
|
+
document.getElementById('status').textContent = String(e);
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
TABLE_VISIBLE_COLUMNS_PREFERENCES_KEY,
|
|
6
6
|
TABLE_VIEW_MODE_PREFERENCES_KEY,
|
|
7
7
|
buildDefaultVisibleColumns,
|
|
8
|
+
canHideVisibleColumn,
|
|
8
9
|
persistTableFiltersPreference,
|
|
9
10
|
persistTableSortPreference,
|
|
10
11
|
persistTableViewModePreference,
|
|
@@ -44,6 +45,7 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
44
45
|
{ name: 'price', visible: false },
|
|
45
46
|
];
|
|
46
47
|
const scope = {
|
|
48
|
+
companyKey: '42',
|
|
47
49
|
storeKey: 'financialEntries',
|
|
48
50
|
routeKey: 'receivables',
|
|
49
51
|
};
|
|
@@ -70,21 +72,33 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
70
72
|
},
|
|
71
73
|
}),
|
|
72
74
|
).toEqual({
|
|
73
|
-
id:
|
|
75
|
+
id: true,
|
|
74
76
|
status: true,
|
|
75
77
|
price: false,
|
|
76
78
|
});
|
|
77
79
|
});
|
|
78
80
|
|
|
79
|
-
it('
|
|
81
|
+
it('does not allow hiding the last remaining column', () => {
|
|
82
|
+
expect(
|
|
83
|
+
canHideVisibleColumn({
|
|
84
|
+
columns,
|
|
85
|
+
fieldName: 'status',
|
|
86
|
+
visibleColumns: {id: true, status: false, price: false},
|
|
87
|
+
}),
|
|
88
|
+
).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('builds the company, route and store preference scope', () => {
|
|
80
92
|
global.location = {pathname: '/order-history-page'};
|
|
81
93
|
|
|
82
94
|
expect(
|
|
83
95
|
resolveDefaultTablePreferenceScope({
|
|
96
|
+
companyId: 42,
|
|
84
97
|
route: {name: 'IgnoredRoute'},
|
|
85
98
|
storeName: 'orders',
|
|
86
99
|
}),
|
|
87
100
|
).toEqual({
|
|
101
|
+
companyKey: '42',
|
|
88
102
|
routeKey: 'order-history-page',
|
|
89
103
|
storeKey: 'orders',
|
|
90
104
|
});
|
|
@@ -97,11 +111,13 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
97
111
|
|
|
98
112
|
expect(
|
|
99
113
|
resolveDefaultTablePreferenceScope({
|
|
114
|
+
companyId: '99',
|
|
100
115
|
preferenceKey: 'product_showcase_items',
|
|
101
116
|
route: {name: 'ProductShowcasesPage'},
|
|
102
117
|
storeName: 'product_showcase_items',
|
|
103
118
|
}),
|
|
104
119
|
).toEqual({
|
|
120
|
+
companyKey: '99',
|
|
105
121
|
routeKey: 'product_showcase_items',
|
|
106
122
|
storeKey: 'product_showcase_items',
|
|
107
123
|
});
|
|
@@ -129,15 +145,17 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
129
145
|
});
|
|
130
146
|
});
|
|
131
147
|
|
|
132
|
-
it('reads and writes visible columns under default-table[store][route]', () => {
|
|
148
|
+
it('reads and writes visible columns under default-table[company][store][route]', () => {
|
|
133
149
|
global.localStorage.setItem(
|
|
134
150
|
DEFAULT_TABLE_PREFERENCES_STORAGE_KEY,
|
|
135
151
|
JSON.stringify({
|
|
136
152
|
theme: 'light',
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
'42': {
|
|
154
|
+
financialEntries: {
|
|
155
|
+
receivables: {
|
|
156
|
+
[TABLE_VISIBLE_COLUMNS_PREFERENCES_KEY]: {
|
|
157
|
+
id: false,
|
|
158
|
+
},
|
|
141
159
|
},
|
|
142
160
|
},
|
|
143
161
|
},
|
|
@@ -149,6 +167,7 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
149
167
|
});
|
|
150
168
|
|
|
151
169
|
persistVisibleColumnsPreference({
|
|
170
|
+
companyKey: '42',
|
|
152
171
|
storeKey: 'financialEntries',
|
|
153
172
|
routeKey: 'payables',
|
|
154
173
|
}, {
|
|
@@ -162,29 +181,33 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
162
181
|
),
|
|
163
182
|
).toEqual({
|
|
164
183
|
theme: 'light',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
'42': {
|
|
185
|
+
financialEntries: {
|
|
186
|
+
receivables: {
|
|
187
|
+
[TABLE_VISIBLE_COLUMNS_PREFERENCES_KEY]: {
|
|
188
|
+
id: false,
|
|
189
|
+
},
|
|
169
190
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
191
|
+
payables: {
|
|
192
|
+
[TABLE_VISIBLE_COLUMNS_PREFERENCES_KEY]: {
|
|
193
|
+
id: true,
|
|
194
|
+
status: false,
|
|
195
|
+
},
|
|
175
196
|
},
|
|
176
197
|
},
|
|
177
198
|
},
|
|
178
199
|
});
|
|
179
200
|
});
|
|
180
201
|
|
|
181
|
-
it('reads and writes view mode under default-table[store][route]', () => {
|
|
202
|
+
it('reads and writes view mode under default-table[company][store][route]', () => {
|
|
182
203
|
global.localStorage.setItem(
|
|
183
204
|
DEFAULT_TABLE_PREFERENCES_STORAGE_KEY,
|
|
184
205
|
JSON.stringify({
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
206
|
+
'42': {
|
|
207
|
+
financialEntries: {
|
|
208
|
+
payables: {
|
|
209
|
+
[TABLE_VIEW_MODE_PREFERENCES_KEY]: 'cards',
|
|
210
|
+
},
|
|
188
211
|
},
|
|
189
212
|
},
|
|
190
213
|
}),
|
|
@@ -192,7 +215,7 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
192
215
|
|
|
193
216
|
expect(
|
|
194
217
|
resolveStoredTableViewModePreference(
|
|
195
|
-
{storeKey: 'financialEntries', routeKey: 'payables'},
|
|
218
|
+
{companyKey: '42', storeKey: 'financialEntries', routeKey: 'payables'},
|
|
196
219
|
'table',
|
|
197
220
|
),
|
|
198
221
|
).toBe('cards');
|
|
@@ -208,26 +231,30 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
208
231
|
global.localStorage.getItem(DEFAULT_TABLE_PREFERENCES_STORAGE_KEY),
|
|
209
232
|
),
|
|
210
233
|
).toEqual({
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
234
|
+
'42': {
|
|
235
|
+
financialEntries: {
|
|
236
|
+
payables: {
|
|
237
|
+
[TABLE_VIEW_MODE_PREFERENCES_KEY]: 'cards',
|
|
238
|
+
},
|
|
239
|
+
receivables: {
|
|
240
|
+
[TABLE_VIEW_MODE_PREFERENCES_KEY]: 'table',
|
|
241
|
+
},
|
|
217
242
|
},
|
|
218
243
|
},
|
|
219
244
|
});
|
|
220
245
|
});
|
|
221
246
|
|
|
222
|
-
it('reads and writes sort under default-table[store][route]', () => {
|
|
247
|
+
it('reads and writes sort under default-table[company][store][route]', () => {
|
|
223
248
|
global.localStorage.setItem(
|
|
224
249
|
DEFAULT_TABLE_PREFERENCES_STORAGE_KEY,
|
|
225
250
|
JSON.stringify({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
251
|
+
'42': {
|
|
252
|
+
financialEntries: {
|
|
253
|
+
payables: {
|
|
254
|
+
[TABLE_SORT_PREFERENCES_KEY]: {
|
|
255
|
+
direction: 'asc',
|
|
256
|
+
field: 'price',
|
|
257
|
+
},
|
|
231
258
|
},
|
|
232
259
|
},
|
|
233
260
|
},
|
|
@@ -236,6 +263,7 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
236
263
|
|
|
237
264
|
expect(
|
|
238
265
|
resolveStoredTableSortPreference({
|
|
266
|
+
companyKey: '42',
|
|
239
267
|
storeKey: 'financialEntries',
|
|
240
268
|
routeKey: 'payables',
|
|
241
269
|
}),
|
|
@@ -256,24 +284,26 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
256
284
|
global.localStorage.getItem(DEFAULT_TABLE_PREFERENCES_STORAGE_KEY),
|
|
257
285
|
),
|
|
258
286
|
).toEqual({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
287
|
+
'42': {
|
|
288
|
+
financialEntries: {
|
|
289
|
+
payables: {
|
|
290
|
+
[TABLE_SORT_PREFERENCES_KEY]: {
|
|
291
|
+
direction: 'asc',
|
|
292
|
+
field: 'price',
|
|
293
|
+
},
|
|
264
294
|
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
295
|
+
receivables: {
|
|
296
|
+
[TABLE_SORT_PREFERENCES_KEY]: {
|
|
297
|
+
direction: 'desc',
|
|
298
|
+
field: 'dueDate',
|
|
299
|
+
},
|
|
270
300
|
},
|
|
271
301
|
},
|
|
272
302
|
},
|
|
273
303
|
});
|
|
274
304
|
});
|
|
275
305
|
|
|
276
|
-
it('reads and writes filters under default-table[store][route]', () => {
|
|
306
|
+
it('reads and writes filters under default-table[company][store][route]', () => {
|
|
277
307
|
persistTableFiltersPreference(scope, {
|
|
278
308
|
search: '72813',
|
|
279
309
|
status: 'paid',
|
|
@@ -289,14 +319,31 @@ describe('tableVisibleColumnsPreferences', () => {
|
|
|
289
319
|
global.localStorage.getItem(DEFAULT_TABLE_PREFERENCES_STORAGE_KEY),
|
|
290
320
|
),
|
|
291
321
|
).toEqual({
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
322
|
+
'42': {
|
|
323
|
+
financialEntries: {
|
|
324
|
+
receivables: {
|
|
325
|
+
[TABLE_FILTER_PREFERENCES_KEY]: {
|
|
326
|
+
search: '72813',
|
|
327
|
+
status: 'paid',
|
|
328
|
+
},
|
|
297
329
|
},
|
|
298
330
|
},
|
|
299
331
|
},
|
|
300
332
|
});
|
|
301
333
|
});
|
|
334
|
+
|
|
335
|
+
it('ignores scopes without a company key', () => {
|
|
336
|
+
persistTableFiltersPreference(
|
|
337
|
+
{storeKey: 'orders', routeKey: 'order-history-page'},
|
|
338
|
+
{app: 'POS'},
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
expect(global.localStorage.getItem(DEFAULT_TABLE_PREFERENCES_STORAGE_KEY)).toBeNull();
|
|
342
|
+
expect(
|
|
343
|
+
resolveStoredTableFiltersPreference({
|
|
344
|
+
storeKey: 'orders',
|
|
345
|
+
routeKey: 'order-history-page',
|
|
346
|
+
}),
|
|
347
|
+
).toBeNull();
|
|
348
|
+
});
|
|
302
349
|
});
|