@andersonalmeidax0/webcomponents 0.1.11 → 0.1.13
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/RestAPIAdapter.js +31 -30
- package/jzcomponents/XFormEdit.jsx +81 -72
- package/package.json +1 -1
- package/releasenotes.txt +6 -0
package/RestAPIAdapter.js
CHANGED
|
@@ -42,35 +42,35 @@ import {PlatAPIError,PlatAPIReturnCodeError,PlatAPIAuthError,PlatAPIDBNotFound,P
|
|
|
42
42
|
X-Colocar o MetalMarlek em outro server AWS ... com docker... com outra conta de mongodb "andermusicdevelopment" free.. com CI/CD
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
function getStorage(key) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* ************************************************** */
|
|
55
|
-
/* ************************************************** */
|
|
56
|
-
function getStorageWithExpiry(key) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
45
|
+
// function getStorage(key) {
|
|
46
|
+
// const itemStr = sessionStorage.getItem(key)
|
|
47
|
+
// if (!itemStr) {
|
|
48
|
+
// return null;
|
|
49
|
+
// }
|
|
50
|
+
// const item = JSON.parse(itemStr)
|
|
51
|
+
// return item;
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
// /* ************************************************** */
|
|
55
|
+
// /* ************************************************** */
|
|
56
|
+
// function getStorageWithExpiry(key) {
|
|
57
|
+
// const itemStr = sessionStorage.getItem(key)
|
|
58
|
+
// // if the item doesn't exist, return null
|
|
59
|
+
// if (!itemStr) {
|
|
60
|
+
// return null;
|
|
61
|
+
// }
|
|
62
|
+
// const item = JSON.parse(itemStr)
|
|
63
|
+
// const now = new Date()
|
|
64
|
+
// // compare the expiry time of the item with the current time
|
|
65
|
+
// if (now.getTime() > item.expiry) {
|
|
66
|
+
// // If the item is expired, delete the item from storage
|
|
67
|
+
// // and return null
|
|
68
|
+
// //alert('Session: expired'+key);
|
|
69
|
+
// sessionStorage.removeItem(key)
|
|
70
|
+
// return null
|
|
71
|
+
// }
|
|
72
|
+
// return item.value
|
|
73
|
+
// }
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
/** **********************************************
|
|
@@ -129,7 +129,8 @@ function getStorageWithExpiry(key) {
|
|
|
129
129
|
*********************** */
|
|
130
130
|
async callAPI(q,vo,context,filter) {
|
|
131
131
|
var r = null;
|
|
132
|
-
var ptoken=this.token
|
|
132
|
+
var ptoken=this.token;
|
|
133
|
+
//?this.token:(getStorageWithExpiry('sid'));
|
|
133
134
|
//if(ptoken==null)
|
|
134
135
|
// throw new PlatAPIAuthError( `An error has occured: ${response.status}`);
|
|
135
136
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {XButton}
|
|
3
|
-
import {XInputExternal} from "../XInput.jsx"
|
|
4
|
-
import {XSelect3}
|
|
5
|
-
import {XTextArea}
|
|
6
|
-
import {XCheckbox}
|
|
7
|
-
import {XDateSelect}
|
|
2
|
+
import { XButton } from "../XButton.jsx"
|
|
3
|
+
import { XInputExternal } from "../XInput.jsx"
|
|
4
|
+
import { XSelect3 } from "../XSelect"
|
|
5
|
+
import { XTextArea } from "../XTextArea"
|
|
6
|
+
import { XCheckbox } from "../XCheckbox.jsx"
|
|
7
|
+
import { XDateSelect } from "../XDateSelect.jsx"
|
|
8
8
|
|
|
9
9
|
import { JZInPlaceListComponent } from "./JZInPlaceListComponent.jsx";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
const DEBUG_ID=false;
|
|
14
|
-
const DEBUG_ID2=DEBUG_ID;
|
|
15
|
-
const DEBUG_ID3=false;
|
|
13
|
+
const DEBUG_ID = false;
|
|
14
|
+
const DEBUG_ID2 = DEBUG_ID;
|
|
15
|
+
const DEBUG_ID3 = false;
|
|
16
16
|
|
|
17
17
|
//TODO: tirar debug de celulas (DEBUF_2)
|
|
18
18
|
//atualizar e refres
|
|
@@ -23,83 +23,92 @@ const DEBUG_ID3=false;
|
|
|
23
23
|
/** *********************************************************
|
|
24
24
|
* XFormEdit: metadata, formData, btn0, btn0.label, btn0.evt
|
|
25
25
|
* altera diretamente a prop, por isso nao tem estado (via input external)
|
|
26
|
-
* ********************************************************* */
|
|
26
|
+
* ********************************************************* */
|
|
27
27
|
class XFormEdit extends React.Component {
|
|
28
28
|
constructor(props) {
|
|
29
29
|
super(props)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
inputChangeNew = (value,context) => {
|
|
33
|
-
console.log("u.XFormEdit.inputChgNew.context"+context);
|
|
34
|
-
var v=context.v;
|
|
35
|
-
var item=context.item;
|
|
36
|
-
console.log("u.XFormEdit.inputChgNew.value"+value);
|
|
37
|
-
item[v.attr]=value;
|
|
32
|
+
inputChangeNew = (value, context) => {
|
|
33
|
+
console.log("u.XFormEdit.inputChgNew.context" + context);
|
|
34
|
+
var v = context.v;
|
|
35
|
+
var item = context.item;
|
|
36
|
+
console.log("u.XFormEdit.inputChgNew.value" + value);
|
|
37
|
+
item[v.attr] = value;
|
|
38
38
|
//this.evtRefresh();
|
|
39
39
|
//this.props.notifyChangeFn();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
render
|
|
44
|
-
if(!this.props.metadata.fields)
|
|
45
|
-
|
|
43
|
+
render() {
|
|
44
|
+
if (!this.props.metadata.fields)
|
|
45
|
+
return <h3>No metadata.fields on XFormEdit</h3>
|
|
46
46
|
else
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
return (
|
|
48
|
+
<React.Fragment>
|
|
49
|
+
<h6>{DEBUG_ID2 && '[' + this.props.id + ']'}</h6>
|
|
50
|
+
<h3>{this.props.metadata.title}</h3>
|
|
51
|
+
|
|
52
|
+
{this.props.metadata.fields.filter((item) => { return (item.show) }).map((v, i) => {
|
|
53
|
+
if (v.type === 'l') /*list*/ {
|
|
54
|
+
return <React.Fragment key={i}>
|
|
55
|
+
<div xclassName="card">
|
|
56
|
+
<div>{v.label}</div>
|
|
57
|
+
<XSelect3 list={v.lov} value={this.props.formData[v.attr]} disabled={v.readOnly} onChange={(ev) => this.props.formData[v.attr] = ev.target.value} />
|
|
58
|
+
<br />
|
|
59
|
+
<p> </p>
|
|
60
|
+
</div>
|
|
61
|
+
</React.Fragment>
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (v.type === 'a') /* array */ {
|
|
65
|
+
return (
|
|
66
|
+
<React.Fragment key={i}>
|
|
67
|
+
<div xclassName="card"><div>{v.label}</div>
|
|
68
|
+
<JZInPlaceListComponent _id={this.props.id + '_F' + i} textlabels={true} list={this.props.formData[v.attr]} listConfig={v.listConfig} newItemFN={v.newItemFN} />
|
|
69
|
+
</div>
|
|
70
|
+
</React.Fragment>)
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
if (v.type === 'd') /* date */ {
|
|
74
|
+
return (
|
|
75
|
+
<React.Fragment key={i}>
|
|
76
|
+
<div className=""><div>{v.label}</div>
|
|
77
|
+
<XDateSelect id={this.props.id + '_F' + i} width={v.width} label={v.label} disabled={v.readOnly} value={this.props.formData[v.attr]} onChange={(v) => this.props.formData[v.attr] = v} />
|
|
60
78
|
</div>
|
|
61
|
-
</React.Fragment>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<React.Fragment key={i} >{DEBUG_ID2&&'['+this.props.id+'_F'+i+']'}
|
|
93
|
-
<XInputExternal type={v.type=='n'?'number':''} id={this.props.id+'_F'+i} width={v.width} label = {v.label} readOnly={v.readOnly} value={this.props.formData[v.attr]} /*onChangeNew={(value)=>this.props.formData[v.attr]=ev.target.value}*/ onChangeNew={this.inputChangeNew} context={{item:this.props.formData,v:v}} />
|
|
94
|
-
</React.Fragment>)
|
|
95
|
-
}
|
|
96
|
-
})}
|
|
97
|
-
{this.props.btn0&& <XButton label = {this.props.btn0.label} onClick={this.props.btn0.evt} />}
|
|
98
|
-
</React.Fragment>
|
|
99
|
-
);
|
|
79
|
+
</React.Fragment>)
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
if (v.type === 'c') /* check */ {
|
|
83
|
+
return (
|
|
84
|
+
<React.Fragment key={i}>
|
|
85
|
+
<div className=""><div>{v.label}</div>
|
|
86
|
+
<XCheckbox id={this.props.id + '_F' + i} width={v.width} label={v.label} disabled={v.readOnly} value={this.props.formData[v.attr]} onChange={(v) => this.props.formData[v.attr] = v} />
|
|
87
|
+
</div>
|
|
88
|
+
</React.Fragment>)
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
if (v.type === 'f') /* file */ {
|
|
92
|
+
return (
|
|
93
|
+
<React.Fragment key={i}>
|
|
94
|
+
<div className=""><div>{v.label}</div>
|
|
95
|
+
<p>{this.props.formData[v.attr]}</p>
|
|
96
|
+
<XButton id={this.props.id + '_F' + i} attachFile={true} disabled={v.readOnly} onClick={(e)=>{this.props.formData[v.attr]=e.target.files[0].name;this.props.formData.filedata=e.target.files[0]}} textlabel='Select File'></XButton>
|
|
97
|
+
</div>
|
|
98
|
+
</React.Fragment>)
|
|
99
|
+
} else
|
|
100
|
+
return (
|
|
101
|
+
<React.Fragment key={i} >{DEBUG_ID2 && '[' + this.props.id + '_F' + i + ']'}
|
|
102
|
+
<XInputExternal type={v.type == 'n' ? 'number' : ''} id={this.props.id + '_F' + i} width={v.width} label={v.label} readOnly={v.readOnly} value={this.props.formData[v.attr]} /*onChangeNew={(value)=>this.props.formData[v.attr]=ev.target.value}*/ onChangeNew={this.inputChangeNew} context={{ item: this.props.formData, v: v }} />
|
|
103
|
+
</React.Fragment>)
|
|
104
|
+
}
|
|
105
|
+
})}
|
|
106
|
+
{this.props.btn0 && <XButton label={this.props.btn0.label} onClick={this.props.btn0.evt} />}
|
|
107
|
+
</React.Fragment>
|
|
108
|
+
);
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
|
|
105
|
-
export {XFormEdit};
|
|
114
|
+
export { XFormEdit };
|
package/package.json
CHANGED
package/releasenotes.txt
CHANGED