pict-section-workspace 1.0.0 → 1.0.2
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/README.md +2 -0
- package/package.json +15 -5
- package/source/Pict-Section-Workspace-Provider.js +26 -5
- package/source/Pict-Section-Workspace.js +9 -0
- package/types/Pict-Section-Workspace-Provider.d.ts +8 -2
- package/types/Pict-Section-Workspace-Provider.d.ts.map +1 -1
- package/types/Pict-Section-Workspace.d.ts +2 -0
- package/types/Pict-Section-Workspace.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,8 @@ libWorkspace.registerWorkspaceRoutes(_Pict.providers.ApplicationRouter, OrderWor
|
|
|
80
80
|
- [createWorkspace](https://fable-retold.github.io/pict-section-workspace/#/page/api/createWorkspace)
|
|
81
81
|
- [registerWorkspaceRoutes](https://fable-retold.github.io/pict-section-workspace/#/page/api/registerWorkspaceRoutes)
|
|
82
82
|
- [setDefaultDestination](https://fable-retold.github.io/pict-section-workspace/#/page/api/setDefaultDestination)
|
|
83
|
+
- [setDefaultRestClientName](https://fable-retold.github.io/pict-section-workspace/#/page/api/setDefaultRestClientName)
|
|
84
|
+
- [setAssociationEditorLib](https://fable-retold.github.io/pict-section-workspace/#/page/api/setAssociationEditorLib)
|
|
83
85
|
- [Base Provider](https://fable-retold.github.io/pict-section-workspace/#/page/api/provider)
|
|
84
86
|
|
|
85
87
|
## Ecosystem
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pict-section-workspace",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A declarative, config-driven tabbed workspace for a single entity record: a header, a tab bar, and per-tab content resolvers (overview / render / embed / assoc / childlist), plus view/edit/create modes and GUID-bridge routing.",
|
|
5
5
|
"main": "source/Pict-Section-Workspace.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,13 @@
|
|
|
12
12
|
"types": "tsc -p ."
|
|
13
13
|
},
|
|
14
14
|
"types": "types/Pict-Section-Workspace.d.ts",
|
|
15
|
-
"files": [
|
|
16
|
-
|
|
15
|
+
"files": [
|
|
16
|
+
"source",
|
|
17
|
+
"types"
|
|
18
|
+
],
|
|
19
|
+
"directories": {
|
|
20
|
+
"test": "test"
|
|
21
|
+
},
|
|
17
22
|
"repository": {
|
|
18
23
|
"type": "git",
|
|
19
24
|
"url": "git+https://github.com/fable-retold/pict-section-workspace.git"
|
|
@@ -35,13 +40,18 @@
|
|
|
35
40
|
},
|
|
36
41
|
"mocha": {
|
|
37
42
|
"diff": true,
|
|
38
|
-
"extension": [
|
|
43
|
+
"extension": [
|
|
44
|
+
"js"
|
|
45
|
+
],
|
|
39
46
|
"package": "./package.json",
|
|
40
47
|
"reporter": "spec",
|
|
41
48
|
"slow": "75",
|
|
42
49
|
"timeout": "5000",
|
|
43
50
|
"ui": "tdd",
|
|
44
|
-
"watch-files": [
|
|
51
|
+
"watch-files": [
|
|
52
|
+
"source/**/*.js",
|
|
53
|
+
"test/**/*.js"
|
|
54
|
+
]
|
|
45
55
|
},
|
|
46
56
|
"dependencies": {
|
|
47
57
|
"pict-provider": "^1.0.13",
|
|
@@ -10,6 +10,19 @@ let libRecordSetAssociationEditor = null;
|
|
|
10
10
|
try { libRecordSetAssociationEditor = require([ 'pict-section-recordset', 'source/views/associate/RecordSet-AssociationEditor.js' ].join('/')); }
|
|
11
11
|
catch (pError) { /* assoc tabs unavailable without pict-section-recordset */ }
|
|
12
12
|
|
|
13
|
+
// Host-settable defaults. These let an application wire the framework ONCE (next to `setDefaultDestination`)
|
|
14
|
+
// instead of threading the same value through every workspace config:
|
|
15
|
+
// - DEFAULT_REST_CLIENT_NAME: which fable service speaks to the record API. A host that registers its client
|
|
16
|
+
// under a name other than `RestClient` (and may also have a differently-based `RestClient` registered) sets
|
|
17
|
+
// this so the base resolves the right one — otherwise the read hits the wrong base URL.
|
|
18
|
+
// - libRecordSetAssociationEditor: the base association editor. The optional require above is written as a
|
|
19
|
+
// computed path so bundlers/typecheckers treat pict-section-recordset as runtime-only; some bundlers
|
|
20
|
+
// (e.g. browserify) will not include a computed require at all, leaving it null and breaking every assoc
|
|
21
|
+
// tab. `setAssociationEditorLib()` lets such a host inject the editor it already bundles.
|
|
22
|
+
let DEFAULT_REST_CLIENT_NAME = 'RestClient';
|
|
23
|
+
function setDefaultRestClientName(pName) { if (pName && (typeof pName === 'string')) { DEFAULT_REST_CLIENT_NAME = pName; } }
|
|
24
|
+
function setAssociationEditorLib(pLib) { if (pLib) { libRecordSetAssociationEditor = pLib; } }
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* pict-section-workspace base provider — owns everything every entity workspace shares: the REST + format helpers,
|
|
15
28
|
* the GUID-bridge loader, tab routing, permissions, the shell render (header + tab bar + body panel), and the four
|
|
@@ -60,9 +73,9 @@ class PictSectionWorkspaceProvider extends libPictProvider
|
|
|
60
73
|
|
|
61
74
|
// --- REST + helpers --------------------------------------------------------------------------------------
|
|
62
75
|
/** Name of the fable service that speaks to the record API (getJSON/putJSON/postJSON). Override per workspace
|
|
63
|
-
* via config `RestClientName`; defaults to `RestClient`. Falls
|
|
64
|
-
* registered its client under a different name still resolves. */
|
|
65
|
-
get restClientName() { return this.workspaceConfig.RestClientName ||
|
|
76
|
+
* via config `RestClientName`, or app-wide via `setDefaultRestClientName()`; defaults to `RestClient`. Falls
|
|
77
|
+
* back to a couple of common names so a host that registered its client under a different name still resolves. */
|
|
78
|
+
get restClientName() { return this.workspaceConfig.RestClientName || DEFAULT_REST_CLIENT_NAME; }
|
|
66
79
|
get restClient()
|
|
67
80
|
{
|
|
68
81
|
const tmpFable = this.pict.fable || {};
|
|
@@ -415,7 +428,12 @@ class PictSectionWorkspaceProvider extends libPictProvider
|
|
|
415
428
|
const tmpHost = `${this.identifier}-Assoc-${pLeaf.Key}`;
|
|
416
429
|
this.pict.ContentAssignment.assignContent(pBodySel, `<div id="${tmpHost}"></div>`);
|
|
417
430
|
const tmpManager = this.pict.providers.RecordSetAssociationManager;
|
|
418
|
-
|
|
431
|
+
// Resolve the editor lib first: a config `editorLib` (registered via EditorLibs) wins, otherwise the base
|
|
432
|
+
// editor (the optional pict-section-recordset peer, or whatever `setAssociationEditorLib` injected). Gate on
|
|
433
|
+
// the RESOLVED lib — not the module-level var — so an injected/per-tab editor works even when the optional
|
|
434
|
+
// require did not resolve (e.g. a bundler dropped the computed require).
|
|
435
|
+
const tmpLib = (pContent.editorLib && this.pict.__workspaceEditorLibs && this.pict.__workspaceEditorLibs[pContent.editorLib]) || libRecordSetAssociationEditor;
|
|
436
|
+
if (!tmpLib || !tmpManager || (typeof tmpManager.getAssociation !== 'function') || !tmpManager.getAssociation(pContent.ref))
|
|
419
437
|
{
|
|
420
438
|
this.pict.ContentAssignment.assignContent(pBodySel, `<div class="pw-empty"><p>Association “${this._esc(pContent.ref)}” is not registered.</p></div>`); return;
|
|
421
439
|
}
|
|
@@ -423,7 +441,6 @@ class PictSectionWorkspaceProvider extends libPictProvider
|
|
|
423
441
|
let tmpEditor = this.pict.views[tmpHash];
|
|
424
442
|
if (!tmpEditor)
|
|
425
443
|
{
|
|
426
|
-
const tmpLib = pContent.editorLib ? (this.pict.__workspaceEditorLibs && this.pict.__workspaceEditorLibs[pContent.editorLib]) || libRecordSetAssociationEditor : libRecordSetAssociationEditor;
|
|
427
444
|
this.pict.addView(tmpHash, Object.assign({}, tmpLib.default_configuration,
|
|
428
445
|
{ ViewIdentifier: tmpHash, AssociationHash: pContent.ref, ThisRecordSet: pContent.thisRecordSet || this.entityName, DefaultDestinationAddress: `#${tmpHost}`, PickerMode: pContent.pickerMode || 'single' },
|
|
429
446
|
pContent.editorOptions || {}), tmpLib);
|
|
@@ -458,4 +475,8 @@ class PictSectionWorkspaceProvider extends libPictProvider
|
|
|
458
475
|
}
|
|
459
476
|
}
|
|
460
477
|
|
|
478
|
+
// Host-config hooks (also re-exported from the factory index next to `setDefaultDestination`).
|
|
479
|
+
PictSectionWorkspaceProvider.setDefaultRestClientName = setDefaultRestClientName;
|
|
480
|
+
PictSectionWorkspaceProvider.setAssociationEditorLib = setAssociationEditorLib;
|
|
481
|
+
|
|
461
482
|
module.exports = PictSectionWorkspaceProvider;
|
|
@@ -35,6 +35,13 @@ const { WORKSPACE_CSS } = require('./Pict-Section-Workspace-CSS.js');
|
|
|
35
35
|
let DEFAULT_DESTINATION = '#Pict-Application-Container';
|
|
36
36
|
function setDefaultDestination(pSelector) { if (pSelector) { DEFAULT_DESTINATION = pSelector; } }
|
|
37
37
|
|
|
38
|
+
// App-wide config hooks that live on the provider module (symmetric with setDefaultDestination):
|
|
39
|
+
// setDefaultRestClientName(name) — the fable service the base uses for record reads/writes (default 'RestClient').
|
|
40
|
+
// setAssociationEditorLib(lib) — inject the RecordSet association editor when the optional computed require did
|
|
41
|
+
// not resolve in the host's bundle (keeps kind:'assoc' tabs working).
|
|
42
|
+
const setDefaultRestClientName = PictSectionWorkspaceProvider.setDefaultRestClientName;
|
|
43
|
+
const setAssociationEditorLib = PictSectionWorkspaceProvider.setAssociationEditorLib;
|
|
44
|
+
|
|
38
45
|
/** Register a workspace's provider + view pair with a pict application. */
|
|
39
46
|
function createWorkspace(pPict, pConfig)
|
|
40
47
|
{
|
|
@@ -142,6 +149,8 @@ module.exports = {
|
|
|
142
149
|
createWorkspace,
|
|
143
150
|
registerWorkspaceRoutes,
|
|
144
151
|
setDefaultDestination,
|
|
152
|
+
setDefaultRestClientName,
|
|
153
|
+
setAssociationEditorLib,
|
|
145
154
|
PictSectionWorkspaceProvider,
|
|
146
155
|
PictSectionWorkspaceView,
|
|
147
156
|
WORKSPACE_CSS,
|
|
@@ -32,8 +32,8 @@ declare class PictSectionWorkspaceProvider extends libPictProvider {
|
|
|
32
32
|
get idRecord(): number;
|
|
33
33
|
get state(): any;
|
|
34
34
|
/** Name of the fable service that speaks to the record API (getJSON/putJSON/postJSON). Override per workspace
|
|
35
|
-
* via config `RestClientName`; defaults to `RestClient`. Falls
|
|
36
|
-
* registered its client under a different name still resolves. */
|
|
35
|
+
* via config `RestClientName`, or app-wide via `setDefaultRestClientName()`; defaults to `RestClient`. Falls
|
|
36
|
+
* back to a couple of common names so a host that registered its client under a different name still resolves. */
|
|
37
37
|
get restClientName(): any;
|
|
38
38
|
get restClient(): any;
|
|
39
39
|
_getJSON(pURL: any): Promise<any>;
|
|
@@ -88,5 +88,11 @@ declare class PictSectionWorkspaceProvider extends libPictProvider {
|
|
|
88
88
|
_renderAssoc(pLeaf: any, pContent: any, pBodySel: any): void;
|
|
89
89
|
_renderChildList(pLeaf: any, pContent: any, pBodySel: any): Promise<void>;
|
|
90
90
|
}
|
|
91
|
+
declare namespace PictSectionWorkspaceProvider {
|
|
92
|
+
export { setDefaultRestClientName };
|
|
93
|
+
export { setAssociationEditorLib };
|
|
94
|
+
}
|
|
91
95
|
import libPictProvider = require("pict-provider");
|
|
96
|
+
declare function setDefaultRestClientName(pName: any): void;
|
|
97
|
+
declare function setAssociationEditorLib(pLib: any): void;
|
|
92
98
|
//# sourceMappingURL=Pict-Section-Workspace-Provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Section-Workspace-Provider.d.ts","sourceRoot":"","sources":["../source/Pict-Section-Workspace-Provider.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Pict-Section-Workspace-Provider.d.ts","sourceRoot":"","sources":["../source/Pict-Section-Workspace-Provider.js"],"names":[],"mappings":";AAyBA;;;;;;;;GAQG;AACH;IAEC,2DAUC;IALA,aAAmB;IACnB,YAAY;IACZ,gBAAsB;IACtB,cAAmB;IACnB,iCAA0C;IAI3C,2BAAoE;IACpE,sBAA4D;IAC5D,sBAA6D;IAC7D,mBAAuF;IACvF,sBAA4F;IAC5F,qBAA6F;IAC7F,4BAA6H;IAC7H;wHACoH;IACpH,uBAAiF;IAEjF,gCAAmE;IACnE,2BAAyD;IACzD,gBAAuD;IACvD,kBAA2C;IAC3C,uBAAmC;IAEnC,iBAKC;IAGD;;uHAEmH;IACnH,0BAAgG;IAChG,sBAIC;IACD,kCAAsL;IACtL,8CAA+N;IAC/N,+CAAiO;IACjO,wBAAwK;IAExK,gHAAgH;IAChH,gDAYC;IAGD,uBAAmI;IACnI,yCAKC;IACD,+GAA+G;IAC/G,mBAOC;IAGD,iHAAiH;IACjH,yBAAgF;IAChF,mBAAiC;IAEjC,0DA2BC;IAbC,mBAAwB;IAe1B,uDAiBC;IAED,6GAA6G;IAC7G,2CAWC;IAGD,mBAAyD;IACzD,uHAAuH;IACvH,wBAUC;IACD,mBASC;IACD,sBAAmE;IACnE,kBAAqG;IACrG,8BAA4H;IAC5H,mBAA+F;IAE/F,6BAIC;IACD,iDAKC;IACD,iCAMC;IACD,oCASC;IAGD,wBAuCC;IAED,0HAA0H;IAC1H,+BAAiH;IAEjH,6BAgBC;IAED,mBAA0L;IAC1L,sGAAsG;IACtG,iBAAwK;IACxK,iBAAiC;IAEjC,uFAAuF;IACvF,oBAA2C;IAE3C,0BAoBC;IAED,2GAA2G;IAC3G,oCAmBC;IAGD,qCAoBC;IAGD,+DAWC;IAGD,oBAAiL;IACjL,iCAAsI;IACtI,4CAQC;IACD,6DAYC;IAGD,6DA4BC;IAGD,0EAkBC;CACD;;;;;;AArcD,4DAA4H;AAC5H,0DAA8F"}
|
|
@@ -11,6 +11,8 @@ export function createWorkspace(pPict: any, pConfig: any): {
|
|
|
11
11
|
*/
|
|
12
12
|
export function registerWorkspaceRoutes(pRouter: any, pConfig: any): void;
|
|
13
13
|
export function setDefaultDestination(pSelector: any): void;
|
|
14
|
+
export const setDefaultRestClientName: (pName: any) => void;
|
|
15
|
+
export const setAssociationEditorLib: (pLib: any) => void;
|
|
14
16
|
import PictSectionWorkspaceProvider = require("./Pict-Section-Workspace-Provider.js");
|
|
15
17
|
import PictSectionWorkspaceView = require("./Pict-Section-Workspace-View.js");
|
|
16
18
|
import { WORKSPACE_CSS } from "./Pict-Section-Workspace-CSS.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pict-Section-Workspace.d.ts","sourceRoot":"","sources":["../source/Pict-Section-Workspace.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Pict-Section-Workspace.d.ts","sourceRoot":"","sources":["../source/Pict-Section-Workspace.js"],"names":[],"mappings":"AA4CA,2EAA2E;AAC3E;;EA6BC;AAED;;;;;;GAMG;AACH,0EA8DC;AA9GD,4DAAiG;AAMjG,4DAAuF;AACvF,0DAAqF"}
|