@jd-data-limited/easy-fm 1.2.0-alpha1 → 1.2.2-alpha1
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/index.js +10 -13
- package/index.ts +13 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -284,7 +284,7 @@ class layoutRecordManager {
|
|
|
284
284
|
for (let _field of this.layout.metadata.fieldMetaData) {
|
|
285
285
|
fields[_field.name] = "";
|
|
286
286
|
}
|
|
287
|
-
resolve(new record(this
|
|
287
|
+
resolve(new record(this, -1, 0, fields));
|
|
288
288
|
}).catch(e => {
|
|
289
289
|
reject(e);
|
|
290
290
|
});
|
|
@@ -337,12 +337,14 @@ class record extends EventEmitter {
|
|
|
337
337
|
}
|
|
338
338
|
processPortalData(portalData) {
|
|
339
339
|
for (let item of Object.keys(portalData)) {
|
|
340
|
-
|
|
340
|
+
let _portal = new portal(this, item);
|
|
341
|
+
_portal.records = portalData[item].map(item => {
|
|
341
342
|
let fieldData = item;
|
|
342
343
|
delete fieldData.recordId;
|
|
343
344
|
delete fieldData.modId;
|
|
344
|
-
return new portalItem(this, item.recordId, item.modId, fieldData);
|
|
345
|
-
})
|
|
345
|
+
return new portalItem(this, _portal, item.recordId, item.modId, fieldData);
|
|
346
|
+
});
|
|
347
|
+
this.portals.push();
|
|
346
348
|
}
|
|
347
349
|
}
|
|
348
350
|
processFieldData(fieldData) {
|
|
@@ -599,7 +601,7 @@ class field {
|
|
|
599
601
|
};
|
|
600
602
|
}
|
|
601
603
|
if (this.record instanceof portalItem) {
|
|
602
|
-
return this.record.layout.metadata.portalMetaData.find(i => i.name === this.id) || {
|
|
604
|
+
return this.record.layout.metadata.portalMetaData[this.record.portal.name || "portal not attached"].find(i => i.name === this.id) || {
|
|
603
605
|
name: this.id.toString(),
|
|
604
606
|
type: 'normal',
|
|
605
607
|
displayType: 'editText',
|
|
@@ -672,24 +674,19 @@ class field {
|
|
|
672
674
|
}
|
|
673
675
|
}
|
|
674
676
|
class portal {
|
|
675
|
-
constructor(record, name
|
|
677
|
+
constructor(record, name) {
|
|
676
678
|
this.record = record;
|
|
677
679
|
this.name = name;
|
|
678
|
-
this.records = records;
|
|
679
|
-
for (let item of this.records)
|
|
680
|
-
item.attachPortal(this);
|
|
681
680
|
}
|
|
682
681
|
}
|
|
683
682
|
class portalItem extends record {
|
|
684
|
-
constructor(record, recordId, modId = recordId, fieldData = {}) {
|
|
683
|
+
constructor(record, portal, recordId, modId = recordId, fieldData = {}) {
|
|
685
684
|
super(record.layout, recordId, modId, fieldData);
|
|
685
|
+
this.portal = portal;
|
|
686
686
|
record.on("saved", () => {
|
|
687
687
|
this.emit("saved");
|
|
688
688
|
});
|
|
689
689
|
}
|
|
690
|
-
attachPortal(portal) {
|
|
691
|
-
this.portal = portal;
|
|
692
|
-
}
|
|
693
690
|
commit(extraBody = { fieldData: undefined }) {
|
|
694
691
|
return this.portal.record.commit(extraBody);
|
|
695
692
|
}
|
package/index.ts
CHANGED
|
@@ -475,12 +475,14 @@ class record extends EventEmitter {
|
|
|
475
475
|
|
|
476
476
|
private processPortalData(portalData): void {
|
|
477
477
|
for (let item of Object.keys(portalData)) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
delete fieldData.
|
|
482
|
-
|
|
483
|
-
|
|
478
|
+
let _portal = new portal(this, item)
|
|
479
|
+
_portal.records = portalData[item].map(item => {
|
|
480
|
+
let fieldData = item;
|
|
481
|
+
delete fieldData.recordId;
|
|
482
|
+
delete fieldData.modId;
|
|
483
|
+
return new portalItem(this, _portal, item.recordId, item.modId, fieldData);
|
|
484
|
+
})
|
|
485
|
+
this.portals.push();
|
|
484
486
|
}
|
|
485
487
|
}
|
|
486
488
|
|
|
@@ -755,7 +757,7 @@ class field {
|
|
|
755
757
|
} as fieldMetaData
|
|
756
758
|
}
|
|
757
759
|
if (this.record instanceof portalItem) {
|
|
758
|
-
return this.record.layout.metadata.portalMetaData.find(i => i.name === this.id) as fieldMetaData || {
|
|
760
|
+
return this.record.layout.metadata.portalMetaData[this.record.portal.name || "portal not attached"].find(i => i.name === this.id) as fieldMetaData || {
|
|
759
761
|
name: this.id.toString(),
|
|
760
762
|
type: 'normal',
|
|
761
763
|
displayType: 'editText',
|
|
@@ -834,28 +836,23 @@ class portal {
|
|
|
834
836
|
readonly name: string;
|
|
835
837
|
public records: portalItem[];
|
|
836
838
|
|
|
837
|
-
constructor(record: record, name: string
|
|
839
|
+
constructor(record: record, name: string) {
|
|
838
840
|
this.record = record
|
|
839
841
|
this.name = name
|
|
840
|
-
this.records = records
|
|
841
|
-
for (let item of this.records) item.attachPortal(this)
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
class portalItem extends record {
|
|
846
|
-
|
|
846
|
+
readonly portal: portal;
|
|
847
847
|
|
|
848
|
-
constructor(record, recordId, modId = recordId, fieldData = {}) {
|
|
848
|
+
constructor(record, portal, recordId, modId = recordId, fieldData = {}) {
|
|
849
849
|
super(record.layout, recordId, modId, fieldData);
|
|
850
|
+
this.portal = portal
|
|
850
851
|
record.on("saved", () => {
|
|
851
852
|
this.emit("saved")
|
|
852
853
|
})
|
|
853
854
|
}
|
|
854
855
|
|
|
855
|
-
attachPortal(portal) {
|
|
856
|
-
this.portal = portal
|
|
857
|
-
}
|
|
858
|
-
|
|
859
856
|
commit(extraBody = {fieldData: undefined}) {
|
|
860
857
|
return this.portal.record.commit(extraBody)
|
|
861
858
|
}
|