@gandalan/weblibs 1.0.32 → 1.0.33

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/.eslintrc.cjs CHANGED
@@ -15,20 +15,25 @@ module.exports = {
15
15
  node: true,
16
16
  },
17
17
  rules: {
18
+ "yoda": "error",
19
+ eqeqeq: ["warn", "smart"],
18
20
  //indent: ['error', 4],
19
- quotes: ["warn", "double"],
21
+ quotes: ["error", "double"],
20
22
  semi: ["off", "never"],
21
23
  "no-multi-spaces": ["error", { ignoreEOLComments: true }],
22
24
  "curly": "error",
23
25
  "comma-spacing": "error",
24
- "brace-style": "error",
26
+ "brace-style": ["error", "allman"],
25
27
  "no-var": "error",
26
28
  "key-spacing": "warn",
27
29
  "keyword-spacing": "warn",
28
30
  "space-infix-ops": "warn",
29
31
  "arrow-spacing": "warn",
30
- "no-trailing-spaces": "warn",
32
+ "no-trailing-spaces": "error",
31
33
  "space-before-blocks": "warn",
34
+ "no-unused-vars": ["warn", {
35
+ "args": "none",
36
+ }],
32
37
  "no-console": "warn",
33
38
  "no-extra-boolean-cast": "off",
34
39
  "no-multiple-empty-lines": ["warn", { "max": 1, "maxBOF": 0 }],
package/api/IDAS.js CHANGED
@@ -1,22 +1,23 @@
1
1
  import { isInvalid, currentToken} from "./authUtils";
2
2
  import { RESTClient } from "./RESTClient";
3
- import jwt_decode from 'jwt-decode';
3
+ import jwt_decode from "jwt-decode";
4
4
 
5
5
  export function IDASFactory(settings)
6
6
  {
7
7
  if (!isInvalid(settings))
8
- {
8
+ {
9
9
  return new IDAS(settings);
10
- }
11
- else throw("Invalid settings: call initIDAS() first to obtain a valid settings!");
10
+ }
11
+
12
+ throw ("Invalid settings: call initIDAS() first to obtain a valid settings!");
12
13
  }
13
14
 
14
- class IDAS
15
+ class IDAS
15
16
  {
16
17
  restClient = undefined;
17
18
  mandantGuid = undefined;
18
19
 
19
- constructor(settings)
20
+ constructor(settings)
20
21
  {
21
22
  this.settings = settings;
22
23
  this.mandantGuid = settings.mandantGuid; // for backwards compatiblity only
@@ -25,18 +26,27 @@ class IDAS
25
26
 
26
27
  auth = {
27
28
  _self: this,
28
- getCurrentAuthToken() {
29
+ getCurrentAuthToken()
30
+ {
29
31
  return currentToken;
30
32
  },
31
- getRights() {
33
+ getRights()
34
+ {
32
35
  if (!currentToken)
36
+ {
33
37
  return [];
38
+ }
39
+
34
40
  const decoded = jwt_decode(currentToken);
35
41
  return decoded.rights;
36
42
  },
37
- getRoles() {
43
+ getRoles()
44
+ {
38
45
  if (!currentToken)
46
+ {
39
47
  return [];
48
+ }
49
+
40
50
  const decoded = jwt_decode(currentToken);
41
51
  return decoded.role;
42
52
  },
@@ -48,66 +58,82 @@ class IDAS
48
58
  {
49
59
  return this.getRoles().some(r => r === code);
50
60
  },
51
- getUsername() {
61
+ getUsername()
62
+ {
52
63
  if (!currentToken)
64
+ {
53
65
  return undefined;
66
+ }
67
+
54
68
  const decoded = jwt_decode(currentToken);
55
69
  return decoded.id;
56
- }
70
+ },
57
71
  };
58
72
 
59
73
  mandanten = {
60
74
  _self: this,
61
- async getAll() {
75
+ async getAll()
76
+ {
62
77
  return await this._self.restClient.get("/Mandanten");
63
78
  },
64
- async get(guid) {
79
+ async get(guid)
80
+ {
65
81
  return await this._self.restClient.get(`/Mandanten/${guid}`);
66
82
  },
67
- async save(m) {
83
+ async save(m)
84
+ {
68
85
  await this._self.restClient.put("/Mandanten", m);
69
86
  },
70
87
  };
71
88
 
72
89
  benutzer = {
73
90
  _self: this,
74
- async getAll(mandantGuid) {
91
+ async getAll(mandantGuid)
92
+ {
75
93
  return await this._self.restClient.get(`/BenutzerListe/${mandantGuid }/?mitRollenUndRechten=true`);
76
94
  },
77
- async get(guid) {
95
+ async get(guid)
96
+ {
78
97
  return await this._self.restClient.get(`/Benutzer/${guid}`);
79
98
  },
80
- async save(m) {
99
+ async save(m)
100
+ {
81
101
  await this._self.restClient.put("/Benutzer", m);
82
102
  },
83
103
  };
84
104
 
85
105
  rollen = {
86
106
  _self: this,
87
- async getAll() {
107
+ async getAll()
108
+ {
88
109
  return await this._self.restClient.get("/Rollen");
89
110
  },
90
- async save(m) {
111
+ async save(m)
112
+ {
91
113
  await this._self.restClient.put("/Rollen", m);
92
114
  },
93
115
  };
94
116
 
95
117
  vorgaenge = {
96
118
  _self: this,
97
- async getByVorgangsnummer(vorgangsNummer, jahr) {
119
+ async getByVorgangsnummer(vorgangsNummer, jahr)
120
+ {
98
121
  return await this._self.restClient.get(`/Vorgang/${vorgangsNummer}/${jahr}`);
99
122
  },
100
- async getByGuid(guid) {
123
+ async getByGuid(guid)
124
+ {
101
125
  return await this._self.restClient.get(`/Vorgang/${guid}`);
102
126
  },
103
127
  };
104
128
 
105
129
  positionen = {
106
130
  _self: this,
107
- async getByPcode(pcode) {
131
+ async getByPcode(pcode)
132
+ {
108
133
  return await this._self.restClient.get(`/BelegPositionen/GetByPcode/${pcode}`);
109
134
  },
110
- async get(guid) {
135
+ async get(guid)
136
+ {
111
137
  return await this._self.restClient.get(`/BelegPositionen/Get/${guid}`);
112
138
  },
113
139
  };
package/api/RESTClient.js CHANGED
@@ -1,112 +1,145 @@
1
1
  import axios from "axios";
2
- import { isInvalid, tryRenew, currentToken, currentRefreshToken } from "./authUtils";
2
+ import { currentToken } from "./authUtils";
3
3
 
4
- export class RESTClient {
4
+ export class RESTClient
5
+ {
5
6
  lastError = "";
6
7
  settings = {};
7
8
  axiosInstance = null;
8
9
 
9
- constructor(settings) {
10
+ constructor(settings)
11
+ {
10
12
  this.settings = settings;
11
13
 
12
14
  this.axiosInstance = axios.create({
13
15
  baseURL: settings.apiBaseurl,
14
16
  headers: {
15
- "Authorization" : `Bearer ${currentToken}`
16
- }
17
+ "Authorization": `Bearer ${currentToken}`,
18
+ },
17
19
  });
18
20
 
19
- /*this.axiosInstance.interceptors.request.use(async (config) => {
21
+ /*this.axiosInstance.interceptors.request.use(async (config) =>
22
+ {
20
23
  console.log("intercept", config.baseURL, config.url);
21
24
  await this.checkTokenBeforeRequest(config);
22
25
  return config;
23
26
  });*/
24
27
  }
25
28
 
26
- /*async checkTokenBeforeRequest(config) {
27
- if (currentToken && isInvalid(this.settings)) { // ignore custom/different JWT tokens
29
+ /*async checkTokenBeforeRequest(config)
30
+ {
31
+ if (currentToken && isInvalid(this.settings))
32
+ { // ignore custom/different JWT tokens
28
33
  await tryRenew(this.settings);
29
34
  console.log(`Updating Header with new JWT Token: ${currentToken}`);
30
35
  this.axiosInstance.headers = {
31
- "Authorization" : `Bearer ${currentToken}`
36
+ "Authorization": `Bearer ${currentToken}`,
32
37
  }
33
38
  }
34
39
  }*/
35
40
 
36
- getUrlOptions() {
41
+ getUrlOptions()
42
+ {
37
43
  return { withCredentials: false };
38
44
  }
39
45
 
40
- async get(uri) {
41
- try {
46
+ async get(uri)
47
+ {
48
+ try
49
+ {
42
50
  const response = await this.axiosInstance.get(uri, this.getUrlOptions());
43
51
  this.lastError = "";
44
52
  return response.data;
45
- } catch (error) {
53
+ }
54
+ catch (error)
55
+ {
46
56
  this.handleError(error);
47
57
  }
48
58
  }
49
59
 
50
- async getFile(uri) {
51
- try {
60
+ async getFile(uri)
61
+ {
62
+ try
63
+ {
52
64
  const response = await this.axiosInstance.get(uri, { responseType: "blob" });
53
65
  let fileName = "1000.pdf";
54
- if (response.headers["content-disposition"]) {
66
+ if (response.headers["content-disposition"])
67
+ {
55
68
  fileName = response.headers["content-disposition"].split(";")[1];
56
69
  fileName = fileName.replace("filename=", "").trim();
57
70
  }
58
71
  this.lastError = "";
59
72
  return { data: response.data, filename: fileName, contentType: "application/pdf" };
60
- } catch (error) {
73
+ }
74
+ catch (error)
75
+ {
61
76
  this.handleError(error);
62
77
  }
63
78
  }
64
79
 
65
- async getRaw(uri) {
80
+ async getRaw(uri)
81
+ {
66
82
  let response = {};
67
- try {
83
+ try
84
+ {
68
85
  response = await this.axiosInstance.get(uri, this.getUrlOptions())
69
86
  this.lastError = "";
70
- } catch (error) {
87
+ }
88
+ catch (error)
89
+ {
71
90
  this.handleError(error);
72
91
  }
73
92
  return response;
74
93
  }
75
94
 
76
- async post(uri, formData) {
77
- try {
95
+ async post(uri, formData)
96
+ {
97
+ try
98
+ {
78
99
  const response = await this.axiosInstance.post(uri, formData, this.getUrlOptions());
79
100
  this.lastError = "";
80
101
  return response;
81
- } catch (error) {
102
+ }
103
+ catch (error)
104
+ {
82
105
  this.handleError(error);
83
106
  }
84
107
  }
85
108
 
86
- async put(uri, formData) {
87
- try {
109
+ async put(uri, formData)
110
+ {
111
+ try
112
+ {
88
113
  const response = await this.axiosInstance.put(uri, formData, this.getUrlOptions());
89
114
  this.lastError = "";
90
115
  return response;
91
- } catch (error) {
116
+ }
117
+ catch (error)
118
+ {
92
119
  this.handleError(error);
93
120
  }
94
121
  }
95
122
 
96
- async delete(uri) {
97
- try {
123
+ async delete(uri)
124
+ {
125
+ try
126
+ {
98
127
  const response = await this.axiosInstance.delete(uri, this.getUrlOptions());
99
128
  this.lastError = "";
100
129
  return response;
101
- } catch (error) {
130
+ }
131
+ catch (error)
132
+ {
102
133
  this.handleError(error);
103
134
  }
104
135
  }
105
136
 
106
137
  // eslint-disable-next-line no-unused-vars
107
- onError = (error, message) => { };
138
+ onError = (error, message) =>
139
+ { };
108
140
 
109
- handleError(error) {
141
+ handleError(error)
142
+ {
110
143
  let message = error ? error.message : "?";
111
144
  // eslint-disable-next-line no-console
112
145
  console.error(`API Error: ${message}`);
package/api/authUtils.js CHANGED
@@ -1,10 +1,11 @@
1
+ /* eslint-disable no-console */
1
2
  import jwt_decode from "jwt-decode";
2
3
 
3
4
  export let currentToken = undefined;
4
5
  export let currentRefreshToken = undefined;
5
6
 
6
- export async function initIDAS(appToken) {
7
-
7
+ export async function initIDAS(appToken)
8
+ {
8
9
  let jwtToken = "";
9
10
  let mandantGuid = "";
10
11
  let apiBaseurl = "https://api.dev.idas-cloudservices.net/api/";
@@ -12,10 +13,22 @@ export async function initIDAS(appToken) {
12
13
  let jwtRefreshToken = localStorage.getItem("IDAS_AuthJwtRefreshToken");
13
14
 
14
15
  let urlParams = new URLSearchParams(location.search);
15
- if (urlParams.has("m")) mandantGuid = urlParams.get("m");
16
- if (urlParams.has("a")) apiBaseurl = urlParams.get("a");
17
- if (urlParams.has("j")) jwtToken = urlParams.get("j");
18
- if (urlParams.has("t")) jwtRefreshToken = urlParams.get("t");
16
+ if (urlParams.has("m"))
17
+ {
18
+ mandantGuid = urlParams.get("m");
19
+ }
20
+ if (urlParams.has("a"))
21
+ {
22
+ apiBaseurl = urlParams.get("a");
23
+ }
24
+ if (urlParams.has("j"))
25
+ {
26
+ jwtToken = urlParams.get("j");
27
+ }
28
+ if (urlParams.has("t"))
29
+ {
30
+ jwtRefreshToken = urlParams.get("t");
31
+ }
19
32
 
20
33
  authUrl = apiBaseurl;
21
34
  currentToken = jwtToken;
@@ -23,10 +36,13 @@ export async function initIDAS(appToken) {
23
36
  localStorage.setItem("IDAS_AuthJwtRefreshToken", jwtRefreshToken);
24
37
 
25
38
  let settings = { appToken, mandantGuid, apiBaseurl, authUrl };
26
- try {
39
+ try
40
+ {
27
41
  await setup(settings);
28
42
  if (isInvalid(settings))
43
+ {
29
44
  redirectToLogin(settings, "/");
45
+ }
30
46
  }
31
47
  catch
32
48
  {
@@ -39,15 +55,20 @@ export async function setup(settings)
39
55
  {
40
56
  console.log("Setup IDAS");
41
57
  if (!currentToken && !currentRefreshToken)
42
- throw("Either currentToken or currentRefreshToken must be set to authenticate");
58
+ {
59
+ throw ("Either currentToken or currentRefreshToken must be set to authenticate");
60
+ }
43
61
 
44
62
  if (currentRefreshToken && isInvalid(settings))
45
63
  {
46
64
  await tryRenew(settings);
47
65
  if (isInvalid(settings))
66
+ {
48
67
  console.log("Refresh failed, invalid JWT token!");
49
-
50
- } else {
68
+ }
69
+ }
70
+ else
71
+ {
51
72
  console.log("Settings already have a valid JWT token, nothing to do");
52
73
  let decoded = jwt_decode(currentToken);
53
74
  let refreshToken = decoded["refreshToken"] || "";
@@ -60,7 +81,9 @@ export async function setup(settings)
60
81
  }
61
82
  let mandantGuid = decoded["mandantGuid"] || "";
62
83
  if (mandantGuid)
84
+ {
63
85
  settings.mandantGuid = mandantGuid;
86
+ }
64
87
  }
65
88
  console.log("Setup finished", settings);
66
89
  }
@@ -69,13 +92,16 @@ let timerRef = undefined;
69
92
  function startRefreshTimer(settings)
70
93
  {
71
94
  if (timerRef)
95
+ {
72
96
  clearInterval(timerRef);
73
- timerRef = setInterval(() => {
74
- if (currentToken)
97
+ }
98
+ timerRef = setInterval(() =>
99
+ {
100
+ if (currentToken)
75
101
  {
76
102
  let decoded = jwt_decode(currentToken);
77
103
  const utcNow = Date.parse(new Date().toUTCString()) / 1000;
78
- if (decoded && utcNow > decoded.exp - 120)
104
+ if (decoded && utcNow > decoded.exp - 120)
79
105
  {
80
106
  tryRenew(settings); // fire & forget/don't await --pr
81
107
  }
@@ -85,25 +111,29 @@ function startRefreshTimer(settings)
85
111
 
86
112
  export function isInvalid(settings)
87
113
  {
88
- if (!currentToken)
114
+ if (!currentToken)
115
+ {
89
116
  return true;
117
+ }
90
118
  let decoded = jwt_decode(currentToken);
91
119
  const utcNow = Date.parse(new Date().toUTCString()) / 1000;
92
- if (decoded && decoded.exp > utcNow)
120
+ if (decoded && decoded.exp > utcNow)
121
+ {
93
122
  return false;
123
+ }
94
124
  return true;
95
125
  }
96
126
 
97
- export async function tryRenew(settings)
127
+ export async function tryRenew(settings)
98
128
  {
99
129
  console.log("try to refresh");
100
130
 
101
131
  const url = settings.authUrl || settings.apiBaseurl;
102
- const payload = { "Token" : currentRefreshToken };
103
- const response = await fetch(url+"LoginJwt/Refresh", {
104
- method : "PUT",
105
- body : JSON.stringify(payload),
106
- headers: { 'Content-Type': 'application/json' }
132
+ const payload = { "Token": currentRefreshToken };
133
+ const response = await fetch(`${url}LoginJwt/Refresh`, {
134
+ method: "PUT",
135
+ body: JSON.stringify(payload),
136
+ headers: { "Content-Type": "application/json" },
107
137
  });
108
138
  const token = await response.json();
109
139
  currentToken = token;
@@ -121,13 +151,17 @@ export async function tryRenew(settings)
121
151
 
122
152
  let mandantGuid = decoded["mandantGuid"] || "";
123
153
  if (mandantGuid)
154
+ {
124
155
  settings.mandantGuid = mandantGuid;
156
+ }
125
157
 
126
158
  if (isInvalid(settings))
159
+ {
127
160
  console.log("Token is already expired!");
161
+ }
128
162
  }
129
163
 
130
- export function redirectToLogin(settings, authPath)
164
+ export function redirectToLogin(settings, authPath)
131
165
  {
132
166
  const authEndpoint = (new URL(window.location.href).origin) + authPath;
133
167
  let authUrlCallback = `${authEndpoint}?r=%target%&j=%jwt%&m=%mandant%`;
@@ -140,5 +174,3 @@ export function redirectToLogin(settings, authPath)
140
174
 
141
175
  window.location = jwtUrl;
142
176
  }
143
-
144
-
@@ -12,7 +12,8 @@
12
12
  export let marker = null;
13
13
  export let markerField = "";
14
14
 
15
- function setCurrent(item) {
15
+ function setCurrent(item)
16
+ {
16
17
  selectedItem = item;
17
18
  dispatch("selectedItemChanged", item);
18
19
  }
@@ -28,138 +28,179 @@
28
28
  let wochenImMonat = [];
29
29
  let monatIndex = 0;
30
30
 
31
- function alertFalschesDatum() {
31
+ function alertFalschesDatum()
32
+ {
32
33
  background = backgroundFalschesDatum;
33
34
  errorHidden = false;
34
35
  setFieldStyle();
35
36
  }
36
- function backToNormal() {
37
+ function backToNormal()
38
+ {
37
39
  background = backgroundNormal;
38
40
  errorHidden = true;
39
41
  setFieldStyle();
40
42
  }
41
- function checkGueltigesDatum() {
43
+ function checkGueltigesDatum()
44
+ {
42
45
  let error = false;
43
46
  let inhalt = Value.split(allowedSonderzeichen);
44
47
  let localTag = inhalt[0];
45
48
  let localMonat = inhalt[1];
46
49
 
47
- if (inhalt.length == 1 && Value.length == 2) {
50
+ if (inhalt.length === 1 && Value.length === 2)
51
+ {
48
52
  Value = Value + allowedSonderzeichen;
49
53
  }
50
- if (inhalt.length == 2 && localMonat.toLocaleString().length >= 2) {
54
+ if (inhalt.length === 2 && localMonat.toLocaleString().length >= 2)
55
+ {
51
56
  Value = Value + allowedSonderzeichen;
52
57
  }
53
58
 
54
59
  // Prüfung, ob der Monat korrekt eingegeben wurde
55
- if (localMonat != "undefined" && (localMonat < 1 || localMonat > 12)) {
60
+ if (localMonat !== "undefined" && (localMonat < 1 || localMonat > 12))
61
+ {
56
62
  error = true;
57
- } else {
63
+ }
64
+ else
65
+ {
58
66
  error = false;
59
67
  }
60
68
 
61
69
  // Prüfung, ob der Tag korrekt eingegeben wurde
62
- if (localTag < 1 || localTag > 31) {
70
+ if (localTag < 1 || localTag > 31)
71
+ {
63
72
  error = true;
64
73
  }
65
74
 
66
- if (localMonat != "undefined") {
75
+ if (localMonat !== "undefined")
76
+ {
67
77
  let localAllowedTage = allowedTage[inhalt[1]];
68
- if (localAllowedTage == "undefined") {
78
+ if (localAllowedTage === "undefined")
79
+ {
69
80
  error = true;
70
81
  }
71
- if (localTag > localAllowedTage) {
82
+ if (localTag > localAllowedTage)
83
+ {
72
84
  error = true;
73
85
  }
74
86
  }
75
87
 
76
- if (error) {
88
+ if (error)
89
+ {
77
90
  alertFalschesDatum();
78
- } else {
91
+ }
92
+ else
93
+ {
79
94
  backToNormal();
80
95
  }
81
96
  }
82
- function daysInMonth() {
97
+ function daysInMonth()
98
+ {
83
99
  wochenImMonat = [];
84
- monatIndex = monate.findIndex(item => item == currentMonat) + 1;
100
+ monatIndex = monate.findIndex(item => item === currentMonat) + 1;
85
101
  let tageImMonat = new Date(currentJahr, monatIndex, 0).getDate();
86
102
  let localTagIndex = 0;
87
103
  let woche = [];
88
104
 
89
- for (let counter = 0; counter < tageImMonat; counter++) {
105
+ for (let counter = 0; counter < tageImMonat; counter++)
106
+ {
90
107
  localTagIndex = new Date(currentJahr, monatIndex - 1, counter).getDay();
91
- if (counter == 0) {
108
+ if (counter === 0)
109
+ {
92
110
  // Am Anfang müssen erstmal x Leertage in die Woche eingefügt werden, damit der Monat
93
111
  // am passenden Wochentag startet => das macht es in der Anzeigeschleife leichter
94
- for (let bufferCounter = 0; bufferCounter < localTagIndex; bufferCounter++) {
112
+ for (let bufferCounter = 0; bufferCounter < localTagIndex; bufferCounter++)
113
+ {
95
114
  woche = [...woche, ""];
96
115
  }
97
116
  }
98
117
  woche = [...woche, counter + 1];
99
118
 
100
- if (woche.length >= 7) {
119
+ if (woche.length >= 7)
120
+ {
101
121
  wochenImMonat = [...wochenImMonat, woche]
102
122
  woche = [];
103
123
  }
104
- if (counter == tageImMonat - 1) {
124
+ if (counter === tageImMonat - 1)
125
+ {
105
126
  wochenImMonat = [...wochenImMonat, woche]
106
127
  woche = [];
107
128
  }
108
129
  }
109
130
  }
110
- function ignoreInput(e) {
131
+ function ignoreInput(e)
132
+ {
111
133
  e.preventDefault();
112
134
  e.returnValue = false;
113
135
  }
114
- function setFieldStyle() {
136
+ function setFieldStyle()
137
+ {
115
138
  buttonStyle = `background: transparent; border: 0px; height: ${buttonHeight}px; margin-left: 10px; margin-right: 8px; margin-top: 0px; width: ${buttonHeight}px;`;
116
139
  divStyle = `background: white; border: 0.5px solid lightgray; border-radius: 5px; display: flex; height: ${Height}px; width: ${Width}px;`;
117
140
  inputStyle = `background: ${background}; border: 0px; height: ${inputHeight}px; width: ${inputWidth}px;`;
118
141
  }
119
- function setJahr(selectedJahr) {
142
+ function setJahr(selectedJahr)
143
+ {
120
144
  currentJahr = selectedJahr.currentJahr;
121
145
  daysInMonth();
122
146
  }
123
- function setMonat(selectedMonat) {
147
+ function setMonat(selectedMonat)
148
+ {
124
149
  currentMonat = selectedMonat.currentMonat;
125
150
  daysInMonth();
126
151
  }
127
- function setPlaceholder(tag) {
128
- if (tag != "") {
152
+ function setPlaceholder(tag)
153
+ {
154
+ if (tag !== "")
155
+ {
129
156
  //Placeholder = getFormattedDate(tag);
130
157
  }
131
158
  }
132
- function setValue(tag) {
159
+ function setValue(tag)
160
+ {
133
161
  Value = new Date(`${currentJahr}-${currentMonat}-${tag}`);
134
162
  datePickerHidden = true;
135
163
  backToNormal();
136
164
  }
137
- function thisKeyDown(e) {
138
- if (allowedNumbers.includes(e.key) == true) {
139
- if (Value.length >= 10) {
165
+ function thisKeyDown(e)
166
+ {
167
+ if (allowedNumbers.includes(e.key) === true)
168
+ {
169
+ if (Value.length >= 10)
170
+ {
140
171
  ignoreInput(e);
141
172
  }
142
173
  checkGueltigesDatum();
143
- } else if (e.key == allowedSonderzeichen) {
174
+ }
175
+ else if (e.key === allowedSonderzeichen)
176
+ {
144
177
  // Kann nicht mit einer && Verknüpfung in die else if-Bedingung gepackt werden, da sonst gar kein Sonderzeichen mehr erlaubt ist... warum auch immer.
145
- if (Value.split(allowedSonderzeichen).length >= 3) {
178
+ if (Value.split(allowedSonderzeichen).length >= 3)
179
+ {
146
180
  ignoreInput(e);
147
181
  }
148
- } else if (allowedFunctionalKeys.includes(e.key) == true) {
182
+ }
183
+ else if (allowedFunctionalKeys.includes(e.key) === true)
184
+ {
149
185
  return;
150
- } else {
186
+ }
187
+ else
188
+ {
151
189
  ignoreInput(e);
152
190
  }
153
191
  }
154
- function getValueFormatted(oldValue) {
192
+ function getValueFormatted(oldValue)
193
+ {
155
194
  let localTag = (new Date(oldValue).getUTCDate()).toString();
156
195
  let localMonat = (new Date(oldValue).getMonth() + 1).toString();
157
196
  let localJahr = new Date(oldValue).getUTCFullYear().toString();
158
197
 
159
- if (localMonat.length < 2) {
198
+ if (localMonat.length < 2)
199
+ {
160
200
  localMonat = `0${localMonat}`;
161
201
  }
162
- if (localTag.length < 2) {
202
+ if (localTag.length < 2)
203
+ {
163
204
  localTag = `0${localTag}`;
164
205
  }
165
206
  return `${localTag }.${localMonat}.${localJahr}`;
@@ -168,7 +209,8 @@
168
209
  setFieldStyle();
169
210
  daysInMonth(currentMonat, currentJahr);
170
211
 
171
- $:if (Value) {
212
+ $:if (Value)
213
+ {
172
214
  Value = getValueFormatted(Value);
173
215
  }
174
216
  </script>
@@ -22,8 +22,10 @@
22
22
  let allowedFunctionalKeys = ["ArrowLeft", "ArrowRight", "Backspace", "Delete"];
23
23
  let allowedVorzeichen = "-";
24
24
 
25
- function checkInput(e) {
26
- switch (Type) {
25
+ function checkInput(e)
26
+ {
27
+ switch (Type)
28
+ {
27
29
  case "currency":
28
30
  case "number":
29
31
  checkInputNumber(e);
@@ -36,155 +38,218 @@
36
38
 
37
39
  executeAdditionalFunctions(e);
38
40
  }
39
- function checkInputNumber(e) {
41
+ function checkInputNumber(e)
42
+ {
40
43
  let localValueString = Value.toLocaleString();
41
44
 
42
45
  // Prüfung auf Ziffern
43
- if (allowedNumbers.includes(e.key) == true) {
44
- if (isBetweenMinMax(e)) {
46
+ if (allowedNumbers.includes(e.key) === true)
47
+ {
48
+ if (isBetweenMinMax(e))
49
+ {
45
50
  let positionDezimalTrenner = localValueString.indexOf(DecimalTrenner)
46
- if (positionDezimalTrenner > -1) {
51
+ if (positionDezimalTrenner > -1)
52
+ {
47
53
  let decimals = localValueString.substring(positionDezimalTrenner);
48
- if (decimals.length > AllowedDecimals || (Type == "currency" && decimals.length > 2)) {
54
+ if (decimals.length > AllowedDecimals || (Type === "currency" && decimals.length > 2))
55
+ {
49
56
  ignoreInput(e);
50
57
  }
51
58
  }
52
- } else {
59
+ }
60
+ else
61
+ {
53
62
  ignoreInput(e);
54
63
  }
55
- } else if (allowedDecimalTrenner.includes(e.key) == true) { // Prüfung auf Dezimaltrenner
56
- if (localValueString.split(DecimalTrenner).length >= 2) {
64
+ }
65
+ else if (allowedDecimalTrenner.includes(e.key) === true)
66
+ { // Prüfung auf Dezimaltrenner
67
+ if (localValueString.split(DecimalTrenner).length >= 2)
68
+ {
57
69
  ignoreInput(e);
58
- } else if (e.key != DecimalTrenner) {
70
+ }
71
+ else if (e.key !== DecimalTrenner)
72
+ {
59
73
  ignoreInput(e);
60
74
  }
61
- } else if (IsVorzeichenErlaubt && e.key == allowedVorzeichen) { // Prüfung auf Vorzeichen
62
- if (!isBetweenMinMax(e)) {
75
+ }
76
+ else if (IsVorzeichenErlaubt && e.key === allowedVorzeichen)
77
+ { // Prüfung auf Vorzeichen
78
+ if (!isBetweenMinMax(e))
79
+ {
63
80
  ignoreInput(e);
64
- } else if (localValueString.startsWith(e.key)) {
81
+ }
82
+ else if (localValueString.startsWith(e.key))
83
+ {
65
84
  ignoreInput(e);
66
- } else {
85
+ }
86
+ else
87
+ {
67
88
  Value = e.key + Value;
68
89
  ignoreInput(e);
69
90
  }
70
- } else if (allowedFunctionalKeys.includes(e.key) == true) { // Prüfung auf Funktionstasten wie [ENTF], [DEL], usw.
91
+ }
92
+ else if (allowedFunctionalKeys.includes(e.key) === true)
93
+ { // Prüfung auf Funktionstasten wie [ENTF], [DEL], usw.
71
94
  return;
72
- } else { // Alles andere soll nicht erlaubt sein
95
+ }
96
+ else
97
+ { // Alles andere soll nicht erlaubt sein
73
98
  ignoreInput(e);
74
99
  }
75
100
  }
76
- function checkInputEMail(e) {
101
+ function checkInputEMail(e)
102
+ {
77
103
  let mailParts = Value.split("@");
78
104
  errorHidden = false; // Pauschal einen Fehler anzeigen lassen - spart Codezeilen
79
105
 
80
- if (mailParts[0].length > 64) {
106
+ if (mailParts[0].length > 64)
107
+ {
81
108
  errorMessage = "Der Lokalteil der E-Mail Adresse (vor dem @-Zeichen) darf eine Maximallänge von 64 Zeichen nicht überschreiten."
82
- } else if (mailParts.length > 1 && mailParts[0].length < 1) {
109
+ }
110
+ else if (mailParts.length > 1 && mailParts[0].length < 1)
111
+ {
83
112
  errorMessage = "Der Lokalteil der E-Mail Adresse (vor dem @-Zeichen) muss eine Mindestlänge von 1 Zeichen besitzen."
84
- } else if (mailParts.length > 1 && !mailParts[1].includes(".")) {
113
+ }
114
+ else if (mailParts.length > 1 && !mailParts[1].includes("."))
115
+ {
85
116
  errorMessage = "Der Domainteil der E-Mail Adresse (nach dem @-Zeichen) muss einen Punkt (.) enthalten."
86
- } else if (Value.startsWith(".") || Value.endsWith(".")) {
117
+ }
118
+ else if (Value.startsWith(".") || Value.endsWith("."))
119
+ {
87
120
  errorMessage = "Die E-Mail Adresse darf mit einem Punkt weder beginnen noch enden."
88
- } else if (Value.startsWith("@") || Value.endsWith("@")) {
121
+ }
122
+ else if (Value.startsWith("@") || Value.endsWith("@"))
123
+ {
89
124
  errorMessage = "Die E-Mail Adresse darf mit einem @-Zeichen weder beginnen noch enden."
90
- } else if (!Value.includes("@") && e.key != "@") {
125
+ }
126
+ else if (!Value.includes("@") && e.key !== "@")
127
+ {
91
128
  errorMessage = "@-Zeichen muss enthalten sein."
92
- } else if (Value.length > 253) {
129
+ }
130
+ else if (Value.length > 253)
131
+ {
93
132
  errorMessage = "Maximallänge: 254 Zeichen.";
94
- } else if (Value.length < 6) {
133
+ }
134
+ else if (Value.length < 6)
135
+ {
95
136
  errorMessage = "Mindestlänge: 6 Zeichen.";
96
- } else {
137
+ }
138
+ else
139
+ {
97
140
  errorHidden = true;
98
141
  errorMessage = ""; // einfach für die Sauberkeit
99
142
  }
100
143
  }
101
- function executeAdditionalFunctions(e) {
102
- switch (e.key) {
144
+ function executeAdditionalFunctions(e)
145
+ {
146
+ switch (e.key)
147
+ {
103
148
  case "Enter":
104
- if (typeof(KeyDownFunctionOnEnter) != "undefined") {
149
+ if (typeof(KeyDownFunctionOnEnter) != "undefined")
150
+ {
105
151
  KeyDownFunctionOnEnter();
106
152
  }
107
153
  break;
108
154
  case "Tab":
109
- if (typeof(KeyDownFunctionOnTab) != "undefined") {
155
+ if (typeof(KeyDownFunctionOnTab) != "undefined")
156
+ {
110
157
  KeyDownFunctionOnTab();
111
158
  }
112
159
  break;
113
160
  }
114
161
  }
115
- function ignoreInput(e) {
162
+ function ignoreInput(e)
163
+ {
116
164
  e.preventDefault();
117
165
  e.returnValue = false;
118
166
  }
119
- function isBetweenMinMax(e) {
167
+ function isBetweenMinMax(e)
168
+ {
120
169
  let isBetween = true;
121
170
  let localValueString = Value.toLocaleString()
122
171
 
123
- if (e.key == allowedVorzeichen) {
172
+ if (e.key === allowedVorzeichen)
173
+ {
124
174
  localValueString = e.key + localValueString;
125
- } else {
175
+ }
176
+ else
177
+ {
126
178
  localValueString = localValueString + e.key;
127
179
  }
128
180
 
129
181
  // Replace wird benötigt, da sonst der Vergleich das deutsche "," als Dezimaltrenner nicht erkennt und ignoriert.
130
182
  localValueString = localValueString.replaceAll(",", ".");
131
183
 
132
- if (MinValue == MaxValue || MinValue > MaxValue) {
184
+ if (MinValue === MaxValue || MinValue > MaxValue)
185
+ {
133
186
  return isBetween;
134
- } if (localValueString < MinValue) {
187
+ }
188
+ if (localValueString < MinValue)
189
+ {
135
190
  Value = MinValue;
136
191
  isBetween = false;
137
- } else if (localValueString > MaxValue) {
192
+ }
193
+ else if (localValueString > MaxValue)
194
+ {
138
195
  Value = MaxValue;
139
196
  isBetween = false;
140
197
  }
141
198
  return isBetween;
142
199
  }
143
- function thisKeyUp() {
200
+ function thisKeyUp()
201
+ {
144
202
  setFieldStyle();
145
203
  }
146
- function setFieldStyle() {
147
- if (IsPflichtfeld && Value != "") {
204
+ function setFieldStyle()
205
+ {
206
+ if (IsPflichtfeld && Value !== "")
207
+ {
148
208
  style = `${style} background: #f5fc99;`
149
- } else if (IsPflichtfeld && Value == "") {
209
+ }
210
+ else if (IsPflichtfeld && Value === "")
211
+ {
150
212
  style = `${style} background: #fc5d5d;`
151
213
  }
152
214
  }
153
215
 
154
- $:if (Type) {
216
+ $:if (Type)
217
+ {
155
218
  Type = Type.toLocaleLowerCase();
156
- switch (Type) {
219
+ switch (Type)
220
+ {
157
221
  case "currency":
158
222
  case "number":
159
223
  style = `${style} text-align: right;`
160
224
  break;
161
225
  }
162
226
  }
163
- $:if (IsPflichtfeld) {
227
+ $:if (IsPflichtfeld)
228
+ {
164
229
  setFieldStyle();
165
230
  }
166
231
  </script>
167
232
 
168
233
  <!-- Datum -->
169
- {#if (Type == "date")}
234
+ {#if (Type === "date")}
170
235
  <input type="date" style={style} on:keydown={checkInput} on:keyup={thisKeyUp} on bind:value={Value}/>
171
236
  {/if}
172
237
 
173
238
  <!-- Nummerisch -->
174
- {#if (Type == "number")}
239
+ {#if (Type === "number")}
175
240
  <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
176
241
  {/if}
177
242
 
178
243
  <!-- Text -->
179
- {#if (Type == "text" && !Multiline) || (Type == "email")}
244
+ {#if (Type === "text" && !Multiline) || (Type === "email")}
180
245
  <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
181
246
  {/if}
182
- {#if (Type == "text" && Multiline)}
247
+ {#if (Type === "text" && Multiline)}
183
248
  <textarea style={style} on:keydown={checkInput} bind:value={Value}/>
184
249
  {/if}
185
250
 
186
251
  <!-- Währung -->
187
- {#if (Type == "currency")}
252
+ {#if (Type === "currency")}
188
253
  <input style={style} on:keydown={checkInput} on:keyup={thisKeyUp} bind:value={Value}/>
189
254
  {/if}
190
255
 
package/index.js CHANGED
@@ -9,7 +9,7 @@ import SaveButton from "./components/SaveButton.svelte";
9
9
 
10
10
  export {
11
11
  DataGrid, Datepicker, Inputbox, Dialog, GanTable,
12
- AddButton, RemoveButton, SaveButton
12
+ AddButton, RemoveButton, SaveButton,
13
13
  }
14
14
 
15
15
  import { IDASFactory } from "./api/IDAS";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "keywords": [
6
6
  "gandalan"