@gandalan/weblibs 0.0.1

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.
@@ -0,0 +1,8 @@
1
+ import { get, writable } from "svelte/store";
2
+
3
+ export const APP_TOKEN = "66B70E0B-F7C4-4829-B12A-18AD309E3970";
4
+ export const AuthToken = writable(localStorage.getItem("AuthToken"));
5
+ export const MandantGuid = writable(localStorage.getItem("MandantGuid"));
6
+ export const ApiBaseUrl = writable(localStorage.getItem("ApiBaseUrl") || "https://api.dev.idas-cloudservices.net/api");
7
+ export const SiteBaseUrl = writable(window.location.protocol + "//" + window.location.host);
8
+ export const SSOAuthUrl = writable(get(ApiBaseUrl).replace("/api", "") + "/SSO?a=" + APP_TOKEN + "&r=%target%?t=%token%%26m=%mandant%");
package/api/api.js ADDED
@@ -0,0 +1,121 @@
1
+ import axios from 'axios';
2
+ import { AuthToken, ApiBaseUrl } from "./AuthStore";
3
+ import { get } from 'svelte/store';
4
+
5
+ export class API
6
+ {
7
+ lastError = '';
8
+ token = "";
9
+ baseurl = "";
10
+
11
+ constructor()
12
+ {
13
+ this.lastError = "";
14
+ this.baseurl = get(ApiBaseUrl);
15
+ this.token = get(AuthToken);
16
+ console.log("Base: " + this.baseurl + " Token: " + this.token);
17
+
18
+ if (this.token) {
19
+ axios.defaults.headers.common['X-Gdl-AuthToken'] = this.token;
20
+ }
21
+ }
22
+
23
+ async get(uri)
24
+ {
25
+ try {
26
+ console.log("GET " + this.baseurl + uri);
27
+ const response = await axios.get(this.baseurl + uri);
28
+ this.lastError = '';
29
+ return response.data;
30
+ }
31
+ catch (error) {
32
+ this.checkError(error);
33
+ }
34
+ }
35
+
36
+ async getFile(uri)
37
+ {
38
+ try {
39
+ const response = await axios.get(this.baseurl + uri, { responseType: 'blob' });
40
+ console.log(response);
41
+
42
+ let fileName = "1000.pdf";
43
+ if (response.headers["content-disposition"]) {
44
+ fileName = response.headers["content-disposition"].split(';')[1];
45
+ fileName = fileName.replace("filename=", "").trim();
46
+ }
47
+
48
+ this.lastError = '';
49
+ return { data: response.data, filename: fileName, contentType: "application/pdf" };
50
+ }
51
+ catch (error) {
52
+ this.checkError(error);
53
+ }
54
+ }
55
+
56
+ async getRaw(uri)
57
+ {
58
+ let response = {};
59
+ try {
60
+ response = await axios.get(this.baseurl + uri, { withCredentials: true })
61
+ console.log(response);
62
+ this.lastError = '';
63
+ }
64
+ catch (error) {
65
+ this.checkError(error);
66
+ }
67
+ return response;
68
+ }
69
+
70
+ async post(uri, formData)
71
+ {
72
+ try {
73
+ const response = await axios.post(this.baseurl + uri, formData, { withCredentials: true });
74
+ //console.log(JSON.stringify(response));
75
+ this.lastError = '';
76
+ return response;
77
+ }
78
+ catch (error) {
79
+ this.checkError(error);
80
+ }
81
+ }
82
+
83
+ async put(uri, formData)
84
+ {
85
+ try {
86
+ console.log(`PUT to ${this.baseurl}${uri}`);
87
+ const response = await axios.put(this.baseurl + uri, formData, { withCredentials: true });
88
+ this.lastError = '';
89
+ return response;
90
+ }
91
+ catch (error) {
92
+ this.checkError(error);
93
+ }
94
+ }
95
+
96
+ async delete(uri)
97
+ {
98
+ try
99
+ {
100
+ console.log(`DELETE to ${this.baseurl}${uri}`);
101
+ const response = await axios.delete(this.baseurl + uri, { withCredentials: true });
102
+ this.lastError = '';
103
+ return response;
104
+ }
105
+ catch (error) {
106
+ this.checkError(error);
107
+ }
108
+ }
109
+
110
+ checkError(error)
111
+ {
112
+ let status = error && error.response ? error.response.status : -1;
113
+ let message = error ? error.message : "?";
114
+ console.log("API Error " + status + ": " + message);
115
+ this.lastError = message;
116
+ if (status === 401 || status === 403) {
117
+ AuthToken.set(null);
118
+ localStorage.setItem("AuthToken", null);
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,12 @@
1
+ import { API } from './api';
2
+ import { AuthToken } from "./AuthStore";
3
+ //import mandanten from '../data/mandanten.json';
4
+
5
+ export function getAll()
6
+ {
7
+ //return mandanten;
8
+ if (AuthToken)
9
+ return new API().get('/Mandanten');
10
+ else
11
+ return [];
12
+ }
@@ -0,0 +1,46 @@
1
+ import { API } from './api';
2
+ import { get } from 'svelte/store'
3
+ import { MandantGuid } from "./AuthStore";
4
+
5
+ const niceContextNames = new Map();
6
+ niceContextNames.set("position", "Positionserfassung");
7
+ niceContextNames.set("start", "Programmstart");
8
+
9
+ export async function getAll()
10
+ {
11
+ let api = getNewAPI();
12
+ let result = await api.get('/NachrichtenKonfig?besitzerMandantGuid=' + get(MandantGuid));
13
+ result = result || [];
14
+ result.forEach(n => {
15
+ n.anzeigeText = n.nachricht && n.nachricht.length > 30 ? n.nachricht.substr(0,30) + "..." : n.nachricht;
16
+ if (n.context && niceContextNames.has(n.context))
17
+ {
18
+ n.anzeigeText += " (Anzeige bei " + niceContextNames.get(n.context) + ")";
19
+ }
20
+ });
21
+ return result;
22
+ }
23
+
24
+ export async function addNachricht(nachricht)
25
+ {
26
+ nachricht.besitzerMandantGuid = get(MandantGuid);
27
+ if (!nachricht.gueltigAb) nachricht.gueltigAb = null;
28
+ if (!nachricht.gueltigBis) nachricht.gueltigBis = null;
29
+
30
+ let api = getNewAPI();
31
+ console.log(nachricht);
32
+ return await api.post('/NachrichtenKonfig', nachricht);
33
+ }
34
+
35
+ export async function removeNachricht(nachricht)
36
+ {
37
+ let api = getNewAPI();
38
+ return await api.delete('/NachrichtenKonfig?nachrichtGuid=' + nachricht.nachrichtGuid);
39
+ }
40
+
41
+ function getNewAPI()
42
+ {
43
+ let api = new API();
44
+ api.baseurl = "";
45
+ return api;
46
+ }
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import { Button } from 'svelte-chota';
3
+ import { mdiMessageAlert } from '@mdi/js'
4
+
5
+ export let Handler;
6
+ export let disabled;
7
+ export let title;
8
+ </script>
9
+
10
+ <Button primary outline title={title} on:click={Handler} icon={mdiMessageAlert} {disabled}>
11
+ {title}
12
+ </Button>
@@ -0,0 +1,72 @@
1
+ <script>
2
+ import { createEventDispatcher } from 'svelte';
3
+ const dispatch = createEventDispatcher();
4
+ import { Icon } from 'svelte-chota';
5
+
6
+ export let items = [];
7
+ export let selectedItem = {};
8
+ export let standardItem;
9
+ export let displayProperty = "";
10
+ export let header = "Überschrift";
11
+ export let key = "Guid";
12
+ export let marker = null;
13
+ export let markerField = "";
14
+
15
+ function setCurrent(item)
16
+ {
17
+ selectedItem = item;
18
+ console.log(item);
19
+ dispatch("selectedItemChanged", item);
20
+ }
21
+ </script>
22
+
23
+ <div class="datagrid">
24
+ <div class="dgheader">
25
+ {header}
26
+ </div>
27
+ <div>
28
+ {#if standardItem}
29
+ <div class="dgrow" on:click={setCurrent(standardItem)} class:selected="{selectedItem[key] === standardItem[key]}">{standardItem[displayProperty]}</div>
30
+ {/if}
31
+ {#each items as d}
32
+ <div class="dgrow" on:click={setCurrent(d)} class:selected="{selectedItem[key] === d[key]}">
33
+ {d[displayProperty]}
34
+ {#if marker && markerField && d[markerField] === true}
35
+ <Icon src={marker} />
36
+ {/if}
37
+ </div>
38
+ {/each}
39
+ </div>
40
+ </div>
41
+
42
+ <style>
43
+ .datagrid {
44
+ border: 1px solid var(--color-darkGrey);
45
+ background-color: var(--color-grey);
46
+ display: flex;
47
+ flex-direction: column;
48
+ justify-content: flex-start;
49
+ align-content: flex-start;
50
+ cursor: pointer;
51
+ }
52
+
53
+ .dgheader {
54
+ background-color: var(--color-grey);
55
+ padding: 4px 4px 4px 8px;
56
+ flex: 1;
57
+ }
58
+
59
+ .dgrow {
60
+ margin-left: 8px;
61
+ border-bottom: 1px solid var(--color-darkGrey);
62
+ background-color: #fff;
63
+ padding: 4px;
64
+ flex: 1;
65
+ }
66
+
67
+ .selected {
68
+ background-color: var(--color-selected);
69
+ color: var(--color-selected-text);
70
+ }
71
+
72
+ </style>
@@ -0,0 +1,301 @@
1
+ <script>
2
+ export let Height = 30;
3
+ export let Placeholder = "";
4
+ export let Value = "";
5
+ export let Width = 120;
6
+
7
+ const backgroundNormal = "#FFFFFF";
8
+ const backgroundFalschesDatum = "#FF0000";
9
+
10
+ let monate = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];
11
+ let montateKurz = ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Nov", "Dez"];
12
+ let tage = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sontag"];
13
+ let tageKurz = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
14
+
15
+ let inputField, buttonStyle, divStyle, inputStyle;
16
+ let background = backgroundNormal;
17
+ let buttonHeight = Height - 6;
18
+ let buttonImageHeight = Height - 10;
19
+ let datePickerHidden = true;
20
+ let errorHidden = true;
21
+ let inputHeight = Height - 2;
22
+ let inputWidth = Width - Height - 10;
23
+
24
+ let allowedNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
25
+ let allowedTage = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
26
+ let allowedTageSchaltjahr = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
27
+ let allowedSonderzeichen = ".";
28
+ let allowedFunctionalKeys = ["ArrowLeft", "ArrowRight", "Backspace", "Delete"];
29
+ let currentJahr = new Date().getFullYear();
30
+ let currentMonat = monate[new Date().getMonth()];
31
+ let wochenImMonat = [];
32
+ let monatIndex = 0;
33
+
34
+ function alertFalschesDatum()
35
+ {
36
+ background = backgroundFalschesDatum;
37
+ errorHidden = false;
38
+ setFieldStyle();
39
+ }
40
+ function backToNormal()
41
+ {
42
+ background = backgroundNormal;
43
+ errorHidden = true;
44
+ setFieldStyle();
45
+ }
46
+ function checkGueltigesDatum()
47
+ {
48
+ let error = false;
49
+ let inhalt = Value.split(allowedSonderzeichen);
50
+ let localTag = inhalt[0];
51
+ let localMonat = inhalt[1];
52
+ let localJahr = inhalt[2];
53
+
54
+ if(inhalt.length == 1 && Value.length == 2)
55
+ {
56
+ Value = Value + allowedSonderzeichen;
57
+ }
58
+ if(inhalt.length == 2 && localMonat.toLocaleString().length >= 2)
59
+ {
60
+ Value = Value + allowedSonderzeichen;
61
+ }
62
+
63
+ // Prüfung, ob der Monat korrekt eingegeben wurde
64
+ if(localMonat != "undefined" && (localMonat < 1 || localMonat > 12))
65
+ {
66
+ error = true;
67
+ }
68
+ else
69
+ {
70
+ error = false;
71
+ }
72
+
73
+ // Prüfung, ob der Tag korrekt eingegeben wurde
74
+ if(localTag < 1 || localTag > 31)
75
+ {
76
+ error = true;
77
+ }
78
+
79
+ if(localMonat != "undefined")
80
+ {
81
+ let localAllowedTage = allowedTage[inhalt[1]];
82
+ if(localAllowedTage == "undefined")
83
+ {
84
+ error = true;
85
+ }
86
+ if(localTag > localAllowedTage)
87
+ {
88
+ error = true;
89
+ }
90
+ }
91
+
92
+ if(error)
93
+ {
94
+ alertFalschesDatum();
95
+ }
96
+ else
97
+ {
98
+ backToNormal();
99
+ }
100
+ }
101
+ function daysInMonth()
102
+ {
103
+ wochenImMonat = [];
104
+ monatIndex = monate.findIndex(item => item == currentMonat) + 1;
105
+ let tageImMonat = new Date(currentJahr, monatIndex, 0).getDate();
106
+ let localTagIndex = 0;
107
+ let woche = [];
108
+ let tagesWochenCounter = 0;
109
+
110
+ for(let counter = 0; counter < tageImMonat; counter++)
111
+ {
112
+ localTagIndex = new Date(currentJahr, monatIndex-1, counter).getDay();
113
+ if(counter == 0)
114
+ {
115
+ // Am Anfang müssen erstmal x Leertage in die Woche eingefügt werden, damit der Monat
116
+ // am passenden Wochentag startet => das macht es in der Anzeigeschleife leichter
117
+ for(let bufferCounter = 0; bufferCounter < localTagIndex; bufferCounter++)
118
+ {
119
+ woche = [...woche, ''];
120
+ }
121
+ }
122
+ woche = [...woche, counter+1];
123
+
124
+ tagesWochenCounter++;
125
+ if(woche.length >= 7)
126
+ {
127
+ wochenImMonat = [...wochenImMonat, woche]
128
+ woche = [];
129
+ tagesWochenCounter = 0;
130
+ }
131
+ if(counter == tageImMonat-1)
132
+ {
133
+ wochenImMonat = [...wochenImMonat, woche]
134
+ woche = [];
135
+ tagesWochenCounter = 0;
136
+ }
137
+ }
138
+ }
139
+ function ignoreInput(e)
140
+ {
141
+ e.preventDefault();
142
+ e.returnValue = false;
143
+ }
144
+ function setFieldStyle()
145
+ {
146
+ buttonStyle = "background: transparent; border: 0px; height: " + buttonHeight + "px; margin-left: 10px; margin-right: 8px; margin-top: 0px; width: " + buttonHeight + "px;";
147
+ divStyle = "background: white; border: 0.5px solid lightgray; border-radius: 5px; display: flex; height: " + Height + "px; width: " + Width + "px;";
148
+ inputStyle = "background: " + background + "; border: 0px; height: " + inputHeight + "px; width: " + inputWidth + "px;";
149
+ }
150
+ function setJahr(selectedJahr)
151
+ {
152
+ currentJahr = selectedJahr.currentJahr;
153
+ daysInMonth();
154
+ }
155
+ function setMonat(selectedMonat)
156
+ {
157
+ currentMonat = selectedMonat.currentMonat;
158
+ daysInMonth();
159
+ }
160
+ function setPlaceholder(tag)
161
+ {
162
+ if(tag != "")
163
+ {
164
+ //Placeholder = getFormattedDate(tag);
165
+ }
166
+ }
167
+ function setValue(tag)
168
+ {
169
+ Value = new Date(currentJahr+"-"+currentMonat+"-"+tag);
170
+ datePickerHidden = true;
171
+ backToNormal();
172
+ }
173
+ function thisKeyDown(e)
174
+ {
175
+ if(allowedNumbers.includes(e.key) == true)
176
+ {
177
+ let inhalt = Value.split(allowedSonderzeichen);
178
+ if(Value.length >= 10)
179
+ {
180
+ ignoreInput(e);
181
+ }
182
+ checkGueltigesDatum();
183
+ }
184
+ else if (e.key == allowedSonderzeichen)
185
+ {
186
+ // Kann nicht mit einer && Verknüpfung in die else if-Bedingung gepackt werden, da sonst gar kein Sonderzeichen mehr erlaubt ist... warum auch immer.
187
+ if(Value.split(allowedSonderzeichen).length >= 3)
188
+ {
189
+ ignoreInput(e);
190
+ }
191
+ }
192
+ else if (allowedFunctionalKeys.includes(e.key) == true) { }
193
+ else
194
+ {
195
+ ignoreInput(e);
196
+ }
197
+ }
198
+ function getValueFormatted(oldValue)
199
+ {
200
+ let localTag = (new Date(oldValue).getUTCDate()).toString();
201
+ let localMonat = (new Date(oldValue).getMonth()+1).toString();
202
+ let localJahr = new Date(oldValue).getUTCFullYear().toString();
203
+
204
+ if(localMonat.length < 2)
205
+ {
206
+ localMonat = "0" + localMonat;
207
+ }
208
+ if(localTag.length < 2)
209
+ {
210
+ localTag = "0" + localTag;
211
+ }
212
+ return localTag + "." + localMonat + "." + localJahr;
213
+ }
214
+
215
+ $:if(true)
216
+ {
217
+ setFieldStyle();
218
+ daysInMonth(currentMonat, currentJahr);
219
+ }
220
+ $:if(Value)
221
+ {
222
+ Value = getValueFormatted(Value);
223
+ }
224
+ </script>
225
+
226
+ <div style={divStyle}>
227
+ <input bind:this={inputField} type="text" style={inputStyle} placeholder={Placeholder} bind:value={Value} on:keydown={thisKeyDown}>
228
+ <button style={buttonStyle} on:click={() => datePickerHidden = !datePickerHidden}>
229
+ <img src="calendar.png" alt="" height={buttonImageHeight}>
230
+ <!-- [...] -->
231
+ </button>
232
+
233
+ <div class="card" hidden={errorHidden} style="margin-top: 40px; position:absolute;">
234
+ Ungültiges Datum
235
+ </div>
236
+ </div>
237
+ <div class="card" hidden={datePickerHidden} style="background: white; border: 1px solid black; border-radius: 10px; margin-top: 5px; position:absolute;">
238
+ <div style="margin: 10px;">
239
+ <div style="display: flex;">
240
+ <select class="buttonMonthSelected" bind:value={currentMonat} on:click={() => setMonat({currentMonat})}>
241
+ {#each monate as monatAuswahl}
242
+ <option class="buttonMonthSelector">{monatAuswahl}</option>
243
+ {/each}
244
+ </select>
245
+ <input type="number" style="height: 40px; margin-left: 10px; width: 85px;" bind:value={currentJahr} on:click={() => setJahr({currentJahr})}>
246
+ </div>
247
+ <br>
248
+ <table>
249
+ <tr>
250
+ {#each tageKurz as tag}
251
+ <td><b>{tag}</b></td>
252
+ {/each}
253
+ </tr>
254
+ {#each wochenImMonat as woche}
255
+ <tr>
256
+ {#each woche as tageInWoche}
257
+ <td>
258
+ <button class="buttonTag" on:mouseover={() => setPlaceholder(tageInWoche)} on:click={() => setValue(tageInWoche)}>
259
+ {tageInWoche}
260
+ </button>
261
+ </td>
262
+ {/each}
263
+ </tr>
264
+ {/each}
265
+ </table>
266
+ </div>
267
+ </div>
268
+
269
+ <style>
270
+ td, tr{
271
+ margin: 0px;
272
+ padding: 0px;
273
+ }
274
+ .buttonTag{
275
+ background-color: transparent;
276
+ border: 0px;
277
+ height: 35px;
278
+ text-align: center;
279
+ width: 35px;
280
+ }
281
+ .buttonTag:hover{
282
+ background-color:cornflowerblue;
283
+ color: white;
284
+ }
285
+ .buttonMonthSelected{
286
+ background-color: transparent;
287
+ border-radius: 5px;
288
+ text-align: left;
289
+ width: 115px;
290
+ }
291
+ .buttonMonthSelector{
292
+ background-color: transparent;
293
+ border: 0px;
294
+ text-align: left;
295
+ width: 115px;
296
+ }
297
+ .buttonMonthSelector:hover{
298
+ background-color:cornflowerblue;
299
+ color: white;
300
+ }
301
+ </style>
@@ -0,0 +1,273 @@
1
+ <script>
2
+ export let AllowedDecimals = 2;
3
+ export let DecimalTrenner = ",";
4
+ export let KeyDownFunctionOnEnter, KeyDownFunctionOnTab;
5
+ export let Height = 30;
6
+ export let IsPflichtfeld = false;
7
+ export let IsVorzeichenErlaubt = true;
8
+ export let MinValue = 0;
9
+ export let MaxValue = 0;
10
+ export let Multiline = false;
11
+ export let Type = "text";
12
+ export let Value = "";
13
+ export let Width = 120;
14
+
15
+ let errorHidden = true;
16
+ let errorMessage = "";
17
+ let style = "height: " + Height + "px; width: " + Width + "px;";
18
+ let styleError = "width: " + Width + "px;";
19
+ let tausenderTrenner = ".";
20
+
21
+ let allowedNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8,", "9"];
22
+ let allowedDecimalTrenner = [",", "."];
23
+ let allowedFunctionalKeys = ["ArrowLeft", "ArrowRight", "Backspace", "Delete"];
24
+ let allowedVorzeichen = "-";
25
+
26
+ function checkInput(e)
27
+ {
28
+ switch(Type)
29
+ {
30
+ case "currency":
31
+ case "number":
32
+ checkInputNumber(e);
33
+ break;
34
+
35
+ case "email":
36
+ checkInputEMail(e)
37
+ break;
38
+ }
39
+
40
+ executeAdditionalFunctions(e);
41
+ }
42
+ function checkInputNumber(e)
43
+ {
44
+ let localValueString = Value.toLocaleString();
45
+
46
+ // Prüfung auf Ziffern
47
+ if(allowedNumbers.includes(e.key) == true)
48
+ {
49
+ if(isBetweenMinMax(e))
50
+ {
51
+ let positionDezimalTrenner = localValueString.indexOf(DecimalTrenner)
52
+ if(positionDezimalTrenner > -1)
53
+ {
54
+ let decimals = localValueString.substring(positionDezimalTrenner);
55
+ if(decimals.length > AllowedDecimals || (Type == "currency" && decimals.length > 2))
56
+ {
57
+ ignoreInput(e);
58
+ }
59
+ }
60
+ }
61
+ else
62
+ {
63
+ ignoreInput(e);
64
+ }
65
+ }
66
+
67
+ // Prüfung auf Dezimaltrenner
68
+ else if (allowedDecimalTrenner.includes(e.key) == true)
69
+ {
70
+ if(localValueString.split(DecimalTrenner).length >= 2)
71
+ {
72
+ ignoreInput(e);
73
+ }
74
+ else if(e.key != DecimalTrenner)
75
+ {
76
+ ignoreInput(e);
77
+ }
78
+ }
79
+
80
+ // Prüfung auf Vorzeichen
81
+ else if (IsVorzeichenErlaubt && e.key == allowedVorzeichen)
82
+ {
83
+ if(!isBetweenMinMax(e))
84
+ {
85
+ ignoreInput(e);
86
+ }
87
+ else if(localValueString.startsWith(e.key))
88
+ {
89
+ ignoreInput(e);
90
+ }
91
+ else
92
+ {
93
+ Value = e.key + Value;
94
+ ignoreInput(e);
95
+ }
96
+ }
97
+
98
+ // Prüfung auf Funktionstasten wie [ENTF], [DEL], usw.
99
+ else if (allowedFunctionalKeys.includes(e.key) == true) { }
100
+
101
+ // Alles andere soll nicht erlaubt sein
102
+ else
103
+ {
104
+ ignoreInput(e);
105
+ }
106
+ }
107
+ function checkInputEMail(e)
108
+ {
109
+ let mailParts = Value.split("@");
110
+ errorHidden = false; // Pauschal einen Fehler anzeigen lassen - spart Codezeilen
111
+
112
+ if(mailParts[0].length > 64)
113
+ {
114
+ errorMessage = "Der Lokalteil der E-Mail Adresse (vor dem @-Zeichen) darf eine Maximallänge von 64 Zeichen nicht überschreiten."
115
+ }
116
+ else if(mailParts.length > 1 && mailParts[0].length < 1)
117
+ {
118
+ errorMessage = "Der Lokalteil der E-Mail Adresse (vor dem @-Zeichen) muss eine Mindestlänge von 1 Zeichen besitzen."
119
+ }
120
+ else if(mailParts.length > 1 && !mailParts[1].includes("."))
121
+ {
122
+ errorMessage = "Der Domainteil der E-Mail Adresse (nach dem @-Zeichen) muss einen Punkt (.) enthalten."
123
+ }
124
+ else if(Value.startsWith(".") || Value.endsWith("."))
125
+ {
126
+ errorMessage = "Die E-Mail Adresse darf mit einem Punkt weder beginnen noch enden."
127
+ }
128
+ else if(Value.startsWith("@") || Value.endsWith("@"))
129
+ {
130
+ errorMessage = "Die E-Mail Adresse darf mit einem @-Zeichen weder beginnen noch enden."
131
+ }
132
+ else if(!Value.includes("@") && e.key != "@")
133
+ {
134
+ errorMessage = "@-Zeichen muss enthalten sein."
135
+ }
136
+ else if(Value.length > 253)
137
+ {
138
+ errorMessage = "Maximallänge: 254 Zeichen.";
139
+ }
140
+ else if(Value.length < 6)
141
+ {
142
+ errorMessage = "Mindestlänge: 6 Zeichen.";
143
+ }
144
+ else
145
+ {
146
+ errorHidden = true;
147
+ errorMessage = ""; // einfach für die Sauberkeit
148
+ }
149
+ }
150
+ function executeAdditionalFunctions(e)
151
+ {
152
+ switch(e.key)
153
+ {
154
+ case "Enter":
155
+ if(typeof(KeyDownFunctionOnEnter) != 'undefined')
156
+ {
157
+ KeyDownFunctionOnEnter();
158
+ }
159
+ break;
160
+ case "Tab":
161
+ if(typeof(KeyDownFunctionOnTab) != 'undefined')
162
+ {
163
+ KeyDownFunctionOnTab();
164
+ }
165
+ break;
166
+ }
167
+ }
168
+ function ignoreInput(e)
169
+ {
170
+ e.preventDefault();
171
+ e.returnValue = false;
172
+ }
173
+ function isBetweenMinMax(e)
174
+ {
175
+ let isBetween = true;
176
+ let localValueString = Value.toLocaleString()
177
+
178
+ if(e.key == allowedVorzeichen)
179
+ {
180
+ localValueString = e.key + localValueString;
181
+ }
182
+ else
183
+ {
184
+ localValueString = localValueString + e.key;
185
+ }
186
+
187
+ // Replace wird benötigt, da sonst der Vergleich das deutsche "," als Dezimaltrenner nicht erkennt und ignoriert.
188
+ localValueString = localValueString.replaceAll(",",".");
189
+
190
+ if(MinValue == MaxValue || MinValue > MaxValue)
191
+ {
192
+ return isBetween;
193
+ }
194
+ else if(localValueString < MinValue)
195
+ {
196
+ Value = MinValue;
197
+ isBetween = false;
198
+ }
199
+ else if(localValueString > MaxValue)
200
+ {
201
+ Value = MaxValue;
202
+ isBetween = false;
203
+ }
204
+ return isBetween;
205
+ }
206
+ function thisKeyUp(e)
207
+ {
208
+ setFieldStyle();
209
+ }
210
+ function setFieldStyle()
211
+ {
212
+ console.log(Value);
213
+ if(IsPflichtfeld && Value != "")
214
+ {
215
+ style = style + " background: #f5fc99;"
216
+ }
217
+ else if(IsPflichtfeld && Value == "")
218
+ {
219
+ style = style + " background: #fc5d5d;"
220
+ }
221
+ }
222
+
223
+ $:if(DecimalTrenner)
224
+ {
225
+ // Dezimaltrenner und Tausendertrenner müssen für das US-Amerikanische Format getauscht werden
226
+ if(DecimalTrenner == allowedDecimalTrenner[1])
227
+ {
228
+ tausenderTrenner = allowedDecimalTrenner[0];
229
+ }
230
+ }
231
+ $:if(Type)
232
+ {
233
+ Type = Type.toLocaleLowerCase();
234
+ switch(Type)
235
+ {
236
+ case "currency":
237
+ case "number":
238
+ style = style + " text-align: right;"
239
+ break;
240
+ }
241
+ }
242
+ $:if(IsPflichtfeld)
243
+ {
244
+ setFieldStyle();
245
+ }
246
+ </script>
247
+
248
+ <!-- Datum -->
249
+ {#if (Type == 'date')}
250
+ <input type="date" style={style} on:keydown={checkInput} on:keyup={thisKeyUp} on bind:value={Value}/>
251
+ {/if}
252
+
253
+ <!-- Nummerisch -->
254
+ {#if (Type == 'number')}
255
+ <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
256
+ {/if}
257
+
258
+ <!-- Text -->
259
+ {#if (Type == 'text' && !Multiline) || (Type == 'email')}
260
+ <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
261
+ {/if}
262
+ {#if (Type == 'text' && Multiline)}
263
+ <textarea style={style} on:keydown={checkInput} bind:value={Value}/>
264
+ {/if}
265
+
266
+ <!-- Währung -->
267
+ {#if (Type == 'currency')}
268
+ <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
269
+ {/if}
270
+
271
+ <div class="card" hidden={errorHidden} style={styleError}>
272
+ {errorMessage}
273
+ </div>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ import { Button } from 'svelte-chota';
3
+ import { mdiTrashCan } from '@mdi/js'
4
+
5
+ export let Handler;
6
+ export let disabled;
7
+ export let title;
8
+ </script>
9
+
10
+ <Button error title={title} on:click={Handler} icon={mdiTrashCan} {disabled}>
11
+ </Button>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import { Button } from 'svelte-chota';
3
+ import { mdiCheck } from '@mdi/js'
4
+
5
+ export let Handler;
6
+ export let disabled;
7
+ export let title;
8
+ </script>
9
+
10
+ <Button primary title={title} on:click={Handler} icon={mdiCheck} {disabled}>
11
+ {title}
12
+ </Button>
Binary file
@@ -0,0 +1,11 @@
1
+ import AddButton from './AddButton.svelte';
2
+ import DataGrid from './DataGrid.svelte';
3
+ import Datepicker from './Datepicker.svelte';
4
+ import Inputbox from './Inputbox.svelte';
5
+ import RemoveButton from './RemoveButton.svelte';
6
+ import SaveButton from './SaveButton.svelte';
7
+
8
+ export {
9
+ DataGrid, Datepicker, Inputbox,
10
+ AddButton, RemoveButton, SaveButton
11
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@gandalan/weblibs",
3
+ "version": "0.0.1",
4
+ "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
+ "author": "Philipp Reif",
6
+ "license": "ISC",
7
+ "devDependencies": {
8
+ "chota": "^0.8.0",
9
+ "svelte": "^3.38.3",
10
+ "svelte-chota": "^1.8.4"
11
+ },
12
+ "dependencies": {
13
+ "@mdi/js": "^5.9.55",
14
+ "axios": "^0.21.1",
15
+ "uuid": "^8.3.2"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/gandalan/idas-client-libs"
20
+ },
21
+ "keywords": [
22
+ "gandalan"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }