pict-section-recordset 1.0.1 → 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/example_applications/ServeExamples.js +1 -1
- package/example_applications/mocks/book-edit-view.html +145 -0
- package/example_applications/mocks/book-read-view.html +139 -0
- package/example_applications/simple_entity/Simple-RecordSet-Application.js +3 -3
- package/package.json +5 -4
- package/source/application/Pict-Application-RecordSet.js +12 -4
- package/source/providers/RecordSet-Router.js +64 -0
- package/source/services/RecordsSet-MetaController.js +89 -17
- package/source/views/RecordSet-RecordBaseView.js +84 -0
- package/source/views/RecordsSet-MacroView.js +63 -0
- package/source/views/dashboard/RecordSet-Dashboard.js +2 -2
- package/source/views/edit/RecordSet-Edit.js +2 -2
- package/source/views/list/RecordSet-List-PaginationBottom.js +42 -42
- package/source/views/list/RecordSet-List-PaginationTop.js +102 -90
- package/source/views/list/RecordSet-List-RecordList.js +3 -3
- package/source/views/list/RecordSet-List-RecordListEntry.js +15 -21
- package/source/views/list/RecordSet-List-RecordListHeader.js +3 -13
- package/source/views/list/RecordSet-List-Title.js +0 -1
- package/source/views/list/RecordSet-List.js +163 -20
- package/source/views/read/RecordSet-Read.js +150 -51
- package/test/PictSectionRecordSet-Basic_tests.js +5 -1
- package/test/PictSectionRecordSet-RecordProvider-Meadow_tests.js +1 -1
- package/types/Pict-Section-RecordSet.d.ts +5 -1
- package/types/application/Pict-Application-RecordSet.d.ts +5 -5
- package/types/application/Pict-Application-RecordSet.d.ts.map +1 -1
- package/types/providers/RecordSet-Router.d.ts +36 -0
- package/types/providers/RecordSet-Router.d.ts.map +1 -0
- package/types/services/RecordsSet-MetaController.d.ts +12 -6
- package/types/services/RecordsSet-MetaController.d.ts.map +1 -1
- package/types/views/RecordSet-RecordBaseView.d.ts +49 -0
- package/types/views/RecordSet-RecordBaseView.d.ts.map +1 -0
- package/types/views/RecordsSet-MacroView.d.ts +33 -0
- package/types/views/RecordsSet-MacroView.d.ts.map +1 -1
- package/types/views/dashboard/RecordSet-Dashboard.d.ts +2 -3
- package/types/views/dashboard/RecordSet-Dashboard.d.ts.map +1 -1
- package/types/views/edit/RecordSet-Edit.d.ts +2 -3
- package/types/views/edit/RecordSet-Edit.d.ts.map +1 -1
- package/types/views/list/RecordSet-List-PaginationBottom.d.ts.map +1 -1
- package/types/views/list/RecordSet-List-PaginationTop.d.ts.map +1 -1
- package/types/views/list/RecordSet-List-RecordListEntry.d.ts.map +1 -1
- package/types/views/list/RecordSet-List-RecordListHeader.d.ts.map +1 -1
- package/types/views/list/RecordSet-List.d.ts +7 -3
- package/types/views/list/RecordSet-List.d.ts.map +1 -1
- package/types/views/read/RecordSet-Read.d.ts +13 -3
- package/types/views/read/RecordSet-Read.d.ts.map +1 -1
- /package/example_applications/{list_view/index.html → mocks/list-view.html} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Example Pict-Section-Form List View </title>
|
|
7
|
+
<style>
|
|
8
|
+
.grid-container {
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
11
|
+
gap: 10px;
|
|
12
|
+
}
|
|
13
|
+
.grid-item{
|
|
14
|
+
background-color: #f0f0f0;
|
|
15
|
+
padding: 10px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
border: 1px solid #ccc;
|
|
18
|
+
list-style-type: none;
|
|
19
|
+
}
|
|
20
|
+
.grid-item.active {
|
|
21
|
+
background-color: aliceblue
|
|
22
|
+
}
|
|
23
|
+
article {
|
|
24
|
+
padding: 20px;
|
|
25
|
+
border: 1px solid #ccc;
|
|
26
|
+
margin: 10px 0;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<!-- START Header template -->
|
|
32
|
+
<header id="RSP-Header-Container">
|
|
33
|
+
<!-- START Header-Title template -->
|
|
34
|
+
<input type="text" style="font-size: 24px; margin-top: 20px;" value="Book Title" />
|
|
35
|
+
<br>
|
|
36
|
+
<!-- END Header-Title template -->
|
|
37
|
+
<!-- START Header-Nav template -->
|
|
38
|
+
<nav id="RSP-Header-Nav">
|
|
39
|
+
<ul class="grid-container">
|
|
40
|
+
<li class="grid-item active"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-1')">Details</a></li>
|
|
41
|
+
<li class="grid-item"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-2')">Author</a></li>
|
|
42
|
+
<li class="grid-item"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-3')">Series</a></li>
|
|
43
|
+
</ul>
|
|
44
|
+
</nav>
|
|
45
|
+
<!-- END Header-Nav template -->
|
|
46
|
+
</header>
|
|
47
|
+
<!-- END Header template -->
|
|
48
|
+
|
|
49
|
+
<!-- START Record template -->
|
|
50
|
+
<section id="RSP-Record-Container">
|
|
51
|
+
<!-- START Record Content -->
|
|
52
|
+
<article id="RSP-Record-Toggleable-Content-1">
|
|
53
|
+
<!-- START Record Content-Description template -->
|
|
54
|
+
<br />
|
|
55
|
+
<textarea>Book Description</textarea>
|
|
56
|
+
<br />
|
|
57
|
+
<!-- END Record Content-Description template -->
|
|
58
|
+
<!-- START Record Content-Image template -->
|
|
59
|
+
<img src="image.jpg" alt="Book Image">
|
|
60
|
+
<button type="button" id="RSP-Record-Image-Button">Change Image</button>
|
|
61
|
+
<!-- END Record Content-Image template -->
|
|
62
|
+
<!-- START Record Content-Details template -->
|
|
63
|
+
<h4>Book Metadata:</h4>
|
|
64
|
+
<ul>
|
|
65
|
+
<li><input type="text" value="Info 1" /></li>
|
|
66
|
+
<li><input type="text" value="Info 2" /></li>
|
|
67
|
+
<li><input type="text" value="Info 3" /></li>
|
|
68
|
+
</ul>
|
|
69
|
+
<!-- END Record Content-Details template -->
|
|
70
|
+
</article>
|
|
71
|
+
<!-- END Record Content -->
|
|
72
|
+
|
|
73
|
+
<!-- START Record Content -->
|
|
74
|
+
<article id="RSP-Record-Toggleable-Content-2" style="display:none;">
|
|
75
|
+
<!-- START Record Content-Title template -->
|
|
76
|
+
<input type="text" value="Joined Entity 1 Title" />
|
|
77
|
+
<!-- END Record Content-Title template -->
|
|
78
|
+
<!-- START Record Content-Description template -->
|
|
79
|
+
<br />
|
|
80
|
+
<textarea>Joined Entity 1 Description</textarea>
|
|
81
|
+
<!-- END Record Content-Description template -->
|
|
82
|
+
<!-- START Record Content-Details template -->
|
|
83
|
+
<ul>
|
|
84
|
+
<li><input type="text" value="Detail A" /></li>
|
|
85
|
+
<li><input type="text" value="Detail B" /></li>
|
|
86
|
+
<li><input type="text" value="Detail C" /></li>
|
|
87
|
+
</ul>
|
|
88
|
+
<!-- END Record Content-Details template -->
|
|
89
|
+
</article>
|
|
90
|
+
<!-- END Record Content -->
|
|
91
|
+
|
|
92
|
+
<!-- START Record Content -->
|
|
93
|
+
<article id="RSP-Record-Toggleable-Content-3" style="display:none;">
|
|
94
|
+
<!-- START Record Content-Title template -->
|
|
95
|
+
<input type="text" value="Joined Entity 2 Title" />
|
|
96
|
+
<!-- END Record Content-Title template -->
|
|
97
|
+
<!-- START Record Content-Description template -->
|
|
98
|
+
<br />
|
|
99
|
+
<textarea>Joined Entity 2 Description</textarea>
|
|
100
|
+
<!-- END Record Content-Description template -->
|
|
101
|
+
<!-- START Record Content-Details template -->
|
|
102
|
+
<ul>
|
|
103
|
+
<li><input type="text" value="Detail X" /></li>
|
|
104
|
+
<li><input type="text" value="Detail Y" /></li>
|
|
105
|
+
<li><input type="text" value="Detail Z" /></li>
|
|
106
|
+
</ul>
|
|
107
|
+
<!-- END Record Content-Details template -->
|
|
108
|
+
</article>
|
|
109
|
+
<!-- END Record Content -->
|
|
110
|
+
|
|
111
|
+
</section>
|
|
112
|
+
<!-- END Record template -->
|
|
113
|
+
|
|
114
|
+
<!-- Footer template -->
|
|
115
|
+
<footer id="RSP-Footer-Container">
|
|
116
|
+
<!-- NOTE: slot for additional set actions -->
|
|
117
|
+
<!-- START Record Content-Button template -->
|
|
118
|
+
<button type="button" id="RSP-Record-Button" onclick="window.location='./book-read-view.html'">Save Changes</button>
|
|
119
|
+
<!-- END Record Content-Button template -->
|
|
120
|
+
</footer>
|
|
121
|
+
<!-- END Footer template -->
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
<script>
|
|
125
|
+
function toggleTabContent(event, contentId) {
|
|
126
|
+
// Remove 'active' class from all tabs
|
|
127
|
+
const tabs = document.querySelectorAll('#RSP-Header-Nav .grid-item');
|
|
128
|
+
tabs.forEach(tab => {
|
|
129
|
+
tab.classList.remove('active');
|
|
130
|
+
});
|
|
131
|
+
// Add 'active' class to the clicked tab
|
|
132
|
+
event.currentTarget.parentElement.classList.add('active');
|
|
133
|
+
// Hide all content sections
|
|
134
|
+
const contents = document.querySelectorAll('article[id^="RSP-Record-Toggleable-Content-"]');
|
|
135
|
+
contents.forEach(content => {
|
|
136
|
+
if (content.id === contentId) {
|
|
137
|
+
content.style.display = 'block';
|
|
138
|
+
} else {
|
|
139
|
+
content.style.display = 'none';
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
</script>
|
|
144
|
+
</body>
|
|
145
|
+
</html>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Example Pict-Section-Form List View </title>
|
|
7
|
+
<style>
|
|
8
|
+
.grid-container {
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
11
|
+
gap: 10px;
|
|
12
|
+
}
|
|
13
|
+
.grid-item{
|
|
14
|
+
background-color: #f0f0f0;
|
|
15
|
+
padding: 10px;
|
|
16
|
+
text-align: center;
|
|
17
|
+
border: 1px solid #ccc;
|
|
18
|
+
list-style-type: none;
|
|
19
|
+
}
|
|
20
|
+
.grid-item.active {
|
|
21
|
+
background-color: aliceblue
|
|
22
|
+
}
|
|
23
|
+
article {
|
|
24
|
+
padding: 20px;
|
|
25
|
+
border: 1px solid #ccc;
|
|
26
|
+
margin: 10px 0;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<!-- START Header template -->
|
|
32
|
+
<header id="RSP-Header-Container">
|
|
33
|
+
<!-- START Header-Title template -->
|
|
34
|
+
<h1>Book Title</h1>
|
|
35
|
+
<!-- END Header-Title template -->
|
|
36
|
+
<!-- START Header-Nav template -->
|
|
37
|
+
<nav id="RSP-Header-Nav">
|
|
38
|
+
<ul class="grid-container">
|
|
39
|
+
<li class="grid-item active"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-1')">Details</a></li>
|
|
40
|
+
<li class="grid-item"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-2')">Author</a></li>
|
|
41
|
+
<li class="grid-item"><a href="javascript:void(0);" onclick="toggleTabContent(event, 'RSP-Record-Toggleable-Content-3')">Series</a></li>
|
|
42
|
+
</ul>
|
|
43
|
+
</nav>
|
|
44
|
+
<!-- END Header-Nav template -->
|
|
45
|
+
</header>
|
|
46
|
+
<!-- END Header template -->
|
|
47
|
+
|
|
48
|
+
<!-- START Record template -->
|
|
49
|
+
<section id="RSP-Record-Container">
|
|
50
|
+
<!-- START Record Content -->
|
|
51
|
+
<article id="RSP-Record-Toggleable-Content-1">
|
|
52
|
+
<!-- START Record Content-Description template -->
|
|
53
|
+
<p>Book Description</p>
|
|
54
|
+
<!-- END Record Content-Description template -->
|
|
55
|
+
<!-- START Record Content-Image template -->
|
|
56
|
+
<img src="image.jpg" alt="Book Image">
|
|
57
|
+
<!-- END Record Content-Image template -->
|
|
58
|
+
<!-- START Record Content-Details template -->
|
|
59
|
+
<h4>Book Metadata:</h4>
|
|
60
|
+
<ul>
|
|
61
|
+
<li>Info 1</li>
|
|
62
|
+
<li>Info 2</li>
|
|
63
|
+
<li>Info 3</li>
|
|
64
|
+
</ul>
|
|
65
|
+
<!-- END Record Content-Details template -->
|
|
66
|
+
</article>
|
|
67
|
+
<!-- END Record Content -->
|
|
68
|
+
|
|
69
|
+
<!-- START Record Content -->
|
|
70
|
+
<article id="RSP-Record-Toggleable-Content-2" style="display:none;">
|
|
71
|
+
<!-- START Record Content-Title template -->
|
|
72
|
+
<h3>Joined Entity 1 Title</h3>
|
|
73
|
+
<!-- END Record Content-Title template -->
|
|
74
|
+
<!-- START Record Content-Description template -->
|
|
75
|
+
<p>Joined Entity 1 Description</p>
|
|
76
|
+
<!-- END Record Content-Description template -->
|
|
77
|
+
<!-- START Record Content-Details template -->
|
|
78
|
+
<ul>
|
|
79
|
+
<li>Detail A</li>
|
|
80
|
+
<li>Detail B</li>
|
|
81
|
+
<li>Detail C</li>
|
|
82
|
+
</ul>
|
|
83
|
+
<!-- END Record Content-Details template -->
|
|
84
|
+
</article>
|
|
85
|
+
<!-- END Record Content -->
|
|
86
|
+
|
|
87
|
+
<!-- START Record Content -->
|
|
88
|
+
<article id="RSP-Record-Toggleable-Content-3" style="display:none;">
|
|
89
|
+
<!-- START Record Content-Title template -->
|
|
90
|
+
<h3>Joined Entity 2 Title</h3>
|
|
91
|
+
<!-- END Record Content-Title template -->
|
|
92
|
+
<!-- START Record Content-Description template -->
|
|
93
|
+
<p>Joined Entity 2 Description</p>
|
|
94
|
+
<!-- END Record Content-Description template -->
|
|
95
|
+
<!-- START Record Content-Details template -->
|
|
96
|
+
<ul>
|
|
97
|
+
<li>Detail X</li>
|
|
98
|
+
<li>Detail Y</li>
|
|
99
|
+
<li>Detail Z</li>
|
|
100
|
+
</ul>
|
|
101
|
+
<!-- END Record Content-Details template -->
|
|
102
|
+
</article>
|
|
103
|
+
<!-- END Record Content -->
|
|
104
|
+
|
|
105
|
+
</section>
|
|
106
|
+
<!-- END Record template -->
|
|
107
|
+
|
|
108
|
+
<!-- Footer template -->
|
|
109
|
+
<footer id="RSP-Footer-Container">
|
|
110
|
+
<!-- NOTE: slot for additional set actions -->
|
|
111
|
+
<!-- START Record Content-Button template -->
|
|
112
|
+
<button type="button" id="RSP-Record-Button" onclick="window.location='./book-edit-view.html'">Edit Record</button>
|
|
113
|
+
<!-- END Record Content-Button template -->
|
|
114
|
+
</footer>
|
|
115
|
+
<!-- END Footer template -->
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
<script>
|
|
119
|
+
function toggleTabContent(event, contentId) {
|
|
120
|
+
// Remove 'active' class from all tabs
|
|
121
|
+
const tabs = document.querySelectorAll('#RSP-Header-Nav .grid-item');
|
|
122
|
+
tabs.forEach(tab => {
|
|
123
|
+
tab.classList.remove('active');
|
|
124
|
+
});
|
|
125
|
+
// Add 'active' class to the clicked tab
|
|
126
|
+
event.currentTarget.parentElement.classList.add('active');
|
|
127
|
+
// Hide all content sections
|
|
128
|
+
const contents = document.querySelectorAll('article[id^="RSP-Record-Toggleable-Content-"]');
|
|
129
|
+
contents.forEach(content => {
|
|
130
|
+
if (content.id === contentId) {
|
|
131
|
+
content.style.display = 'block';
|
|
132
|
+
} else {
|
|
133
|
+
content.style.display = 'none';
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
</body>
|
|
139
|
+
</html>
|
|
@@ -20,7 +20,7 @@ module.exports.default_configuration.pict_configuration = (
|
|
|
20
20
|
"RecordSetType": "MeadowEndpoint", // Could be "Custom" which would require a provider to already be created for the record set.
|
|
21
21
|
"RecordSetMeadowEntity": "Book", // This leverages the /Schema endpoint to get the record set columns.
|
|
22
22
|
|
|
23
|
-
"RecordSetURLPrefix": "
|
|
23
|
+
"RecordSetURLPrefix": "/1.0/"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"RecordSet": "Author",
|
|
@@ -28,7 +28,7 @@ module.exports.default_configuration.pict_configuration = (
|
|
|
28
28
|
"RecordSetType": "MeadowEndpoint",
|
|
29
29
|
"RecordSetMeadowEntity": "Author",
|
|
30
30
|
|
|
31
|
-
"RecordSetURLPrefix": "
|
|
31
|
+
"RecordSetURLPrefix": "/1.0/"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"RecordSet": "RandomizedValues",
|
|
@@ -36,4 +36,4 @@ module.exports.default_configuration.pict_configuration = (
|
|
|
36
36
|
"RecordSetType": "Custom" // This means the `PS-RSP-RandomizedValues` provider will be checked for to get records.
|
|
37
37
|
}
|
|
38
38
|
]
|
|
39
|
-
});
|
|
39
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pict-section-recordset",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Pict dynamic record set management views",
|
|
5
5
|
"main": "source/Pict-Section-RecordSet.js",
|
|
6
6
|
"directories": {
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
"@types/mocha": "^10.0.10",
|
|
32
32
|
"@types/node": "^16.18.126",
|
|
33
33
|
"browser-env": "^3.3.0",
|
|
34
|
-
"eslint": "^9.
|
|
34
|
+
"eslint": "^9.26.0",
|
|
35
35
|
"jquery": "^3.7.1",
|
|
36
|
-
"pict": "^1.0.
|
|
36
|
+
"pict": "^1.0.248",
|
|
37
37
|
"pict-application": "^1.0.25",
|
|
38
38
|
"pict-service-commandlineutility": "^1.0.15",
|
|
39
39
|
"quackage": "^1.0.41",
|
|
40
|
-
"typescript": "^5.
|
|
40
|
+
"typescript": "^5.8.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"fable-serviceproviderbase": "^3.0.15",
|
|
44
44
|
"pict-provider": "^1.0.3",
|
|
45
45
|
"pict-router": "^1.0.3",
|
|
46
|
+
"pict-section-form": "^1.0.90",
|
|
46
47
|
"pict-template": "^1.0.10",
|
|
47
48
|
"pict-view": "^1.0.60"
|
|
48
49
|
},
|
|
@@ -3,14 +3,14 @@ const libPictApplication = require('pict-application');
|
|
|
3
3
|
const libPictSectionRecordSet = require('../Pict-Section-RecordSet.js');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Represents a
|
|
6
|
+
* Represents a PictSectionRecordSetApplication.
|
|
7
7
|
*
|
|
8
|
-
* This is the automagic controller for a
|
|
8
|
+
* This is the automagic controller for a dynamic record set application.
|
|
9
9
|
*
|
|
10
10
|
* @class
|
|
11
11
|
* @extends libPictApplication
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class PictSectionRecordSetApplication extends libPictApplication
|
|
14
14
|
{
|
|
15
15
|
constructor(pFable, pOptions, pServiceHash)
|
|
16
16
|
{
|
|
@@ -32,9 +32,17 @@ class PictSectionFormApplication extends libPictApplication
|
|
|
32
32
|
// Initialize the parent class
|
|
33
33
|
return super.onInitialize();
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
onAfterInitialize()
|
|
37
|
+
{
|
|
38
|
+
// Now add the routes
|
|
39
|
+
this.pict.providers.RecordSetRouter.addRoutes(this.fable.providers.RecordSetRouter.pictRouter);
|
|
40
|
+
|
|
41
|
+
return super.onAfterInitialize();
|
|
42
|
+
}
|
|
35
43
|
};
|
|
36
44
|
|
|
37
|
-
module.exports =
|
|
45
|
+
module.exports = PictSectionRecordSetApplication
|
|
38
46
|
|
|
39
47
|
module.exports.default_configuration = (
|
|
40
48
|
{
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const libPictProvider = require('pict-provider');
|
|
2
|
+
const libPictRouter = require('pict-router');
|
|
3
|
+
|
|
4
|
+
const _DEFAULT_PROVIDER_CONFIGURATION =
|
|
5
|
+
{
|
|
6
|
+
ProviderIdentifier: 'Pict-RecordSet-Router',
|
|
7
|
+
|
|
8
|
+
AutoInitialize: true,
|
|
9
|
+
AutoInitializeOrdinal: 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class PictRecordSetRouter extends libPictProvider
|
|
13
|
+
{
|
|
14
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
15
|
+
{
|
|
16
|
+
let tmpOptions = Object.assign({}, _DEFAULT_PROVIDER_CONFIGURATION, pOptions);
|
|
17
|
+
super(pFable, tmpOptions, pServiceHash);
|
|
18
|
+
|
|
19
|
+
/** @type {Record<string, any>} */
|
|
20
|
+
this.options;
|
|
21
|
+
/** @type {import('pict') & { PictSectionRecordSet: InstanceType<import('../Pict-Section-RecordSet.js')> }} */
|
|
22
|
+
this.pict;
|
|
23
|
+
|
|
24
|
+
this.pictRouter = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onInitialize()
|
|
28
|
+
{
|
|
29
|
+
if (!('PictRouter' in this.pict.providers))
|
|
30
|
+
{
|
|
31
|
+
this.pictRouter = this.pict.addProvider('PictRouter', { RouterMode: 'memory' }, libPictRouter);
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
{
|
|
35
|
+
this.pictRouter = this.pict.providers.PictRouter;
|
|
36
|
+
}
|
|
37
|
+
return super.onInitialize();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addRoutes(pRouter)
|
|
41
|
+
{
|
|
42
|
+
// TODO: Create some kind of state tracking to see if these routes have already been added
|
|
43
|
+
//this.pictRouter.addRoute('/PSRS/:RecordSet/List/:Begin/:Cap', "{~LV:Record~}");
|
|
44
|
+
this.pict.views['RSP-RecordSet-List'].addRoutes(pRouter);
|
|
45
|
+
this.pict.views['RSP-RecordSet-Read'].addRoutes(pRouter);
|
|
46
|
+
this.pict.views['RSP-RecordSet-Edit'].addRoutes(pRouter);
|
|
47
|
+
this.pict.views['RSP-RecordSet-Dashboard'].addRoutes(pRouter);
|
|
48
|
+
|
|
49
|
+
this.pict.PictSectionRecordSet.addRoutes(pRouter);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Navigate to a given route (set the browser URL string, add to history, trigger router)
|
|
54
|
+
*
|
|
55
|
+
* @param {string} pRoute - The route to navigate to
|
|
56
|
+
*/
|
|
57
|
+
navigate(pRoute)
|
|
58
|
+
{
|
|
59
|
+
this.pictRouter.navigate(pRoute);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = PictRecordSetRouter;
|
|
64
|
+
module.exports.default_configuration = _DEFAULT_PROVIDER_CONFIGURATION;
|
|
@@ -9,16 +9,19 @@ const viewRecordSetDashboard = require('../views/dashboard/RecordSet-Dashboard.j
|
|
|
9
9
|
const providerBase = require('../providers/RecordSet-RecordProvider-Base.js');
|
|
10
10
|
const providerMeadowEndpoints = require('../providers/RecordSet-RecordProvider-MeadowEndpoints.js');
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const providerRouter = require('../providers/RecordSet-Router.js');
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const _DEFAULT_CONFIGURATION =
|
|
15
|
+
{
|
|
16
|
+
DefaultMeadowURLPrefix: '/1.0/'
|
|
17
|
+
};
|
|
15
18
|
|
|
16
19
|
class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
17
20
|
{
|
|
18
21
|
constructor(pFable, pOptions, pServiceHash)
|
|
19
22
|
{
|
|
20
|
-
|
|
21
|
-
super(pFable,
|
|
23
|
+
let tmpOptions = Object.assign({}, _DEFAULT_CONFIGURATION, pOptions);
|
|
24
|
+
super(pFable, tmpOptions, pServiceHash);
|
|
22
25
|
|
|
23
26
|
/** @type {import('pict') & { addAndInstantiateSingletonService: (hash: string, options: any, prototype: any) => any }} */
|
|
24
27
|
this.fable;
|
|
@@ -81,6 +84,8 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
81
84
|
return false;
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
let tmpProvider = false;
|
|
88
|
+
|
|
84
89
|
const providerConfiguration = Object.assign({}, {Hash: `RSP-Provider-${pRecordSetConfiguration.RecordSet}`}, pRecordSetConfiguration);
|
|
85
90
|
this.recordSetProviderConfigurations[providerConfiguration.RecordSet] = providerConfiguration;
|
|
86
91
|
|
|
@@ -98,7 +103,7 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
98
103
|
providerConfiguration.Entity = pRecordSetConfiguration.RecordSet;
|
|
99
104
|
}
|
|
100
105
|
// Default the URLPrefix to the base URLPrefix
|
|
101
|
-
if (`
|
|
106
|
+
if (`RecordSetURLPrefix` in pRecordSetConfiguration)
|
|
102
107
|
{
|
|
103
108
|
providerConfiguration.URLPrefix = pRecordSetConfiguration.RecordSetURLPrefix;
|
|
104
109
|
}
|
|
@@ -106,7 +111,7 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
106
111
|
{
|
|
107
112
|
providerConfiguration.URLPrefix = '/1.0/';
|
|
108
113
|
}
|
|
109
|
-
this.recordSetProviders[pRecordSetConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerMeadowEndpoints);
|
|
114
|
+
tmpProvider = this.recordSetProviders[pRecordSetConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerMeadowEndpoints);
|
|
110
115
|
break;
|
|
111
116
|
default:
|
|
112
117
|
case 'Custom':
|
|
@@ -116,21 +121,21 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
116
121
|
if (!(providerConfiguration.ProviderHash in this.fable.servicesMap))
|
|
117
122
|
{
|
|
118
123
|
this.fable.log.error(`RecordSetMetacontroller: ${this.UUID} loadRecordSetConfiguration called with invalid configuration. ProviderHash ${providerConfiguration.ProviderHash} not found. Falling back to base.`);
|
|
119
|
-
this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.servicesMap[providerConfiguration.ProviderHash];
|
|
124
|
+
tmpProvider = this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.servicesMap[providerConfiguration.ProviderHash];
|
|
120
125
|
}
|
|
121
126
|
else
|
|
122
127
|
{
|
|
123
|
-
this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerBase);
|
|
128
|
+
tmpProvider = this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerBase);
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
131
|
else
|
|
127
132
|
{
|
|
128
|
-
this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerBase);
|
|
133
|
+
tmpProvider = this.recordSetProviders[providerConfiguration.RecordSet] = this.fable.addProvider(providerConfiguration.Hash, providerConfiguration, providerBase);
|
|
129
134
|
}
|
|
130
135
|
break;
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
return
|
|
138
|
+
return tmpProvider;
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
loadRecordSetConfigurationArray(pRecordSetConfigurationArray)
|
|
@@ -154,6 +159,72 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
|
|
162
|
+
loadRecordSetDynamcally(pRecordSet, pEntity, pDefaultFilter)
|
|
163
|
+
{
|
|
164
|
+
if (typeof(pRecordSet) === 'object')
|
|
165
|
+
{
|
|
166
|
+
const tmpRecordSetProviderHash = `RSP-Provider-${pRecordSet.RecordSet}`;
|
|
167
|
+
this.loadRecordSetConfiguration(pRecordSet);
|
|
168
|
+
|
|
169
|
+
return this.fable.providers[tmpRecordSetProviderHash].initializeAsync((pError) =>
|
|
170
|
+
{
|
|
171
|
+
this.log.trace(`RecordSet [${pRecordSet.RecordSet} dynamically loaded.`);
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (typeof(pRecordSet) === 'string')
|
|
176
|
+
{
|
|
177
|
+
const tmpRecordSet = pRecordSet;
|
|
178
|
+
const tmpRecordSetProviderHash = `RSP-Provider-${tmpRecordSet}`;
|
|
179
|
+
|
|
180
|
+
const tmpEntity = (typeof(pEntity) === 'string') ? pEntity : tmpRecordSet;
|
|
181
|
+
const tmpDefaultFilter = (typeof(pDefaultFilter) === 'string') ? pDefaultFilter : '';
|
|
182
|
+
const tmpRecordSetConfiguration = {
|
|
183
|
+
"RecordSet": tmpRecordSet,
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
"RecordSetType": "MeadowEndpoint",
|
|
187
|
+
"RecordSetMeadowEntity": tmpEntity,
|
|
188
|
+
"RecordSetDefaultFilter": tmpDefaultFilter,
|
|
189
|
+
|
|
190
|
+
"RecordSetURLPrefix": "/1.0/"
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
this.loadRecordSetConfiguration(tmpRecordSetConfiguration);
|
|
194
|
+
return this.fable.providers[tmpRecordSetProviderHash].initializeAsync(
|
|
195
|
+
(pError) =>
|
|
196
|
+
{
|
|
197
|
+
this.log.trace(`RecordSet [${tmpRecordSetConfiguration.RecordSet} dynamically loaded.`);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.log.error(`RecordSet MetaController loadRecordSetDynamically called with invalid parameter (expected an Object or String - parameter was ${typeof(pRecordSet)}.`);
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
handleLoadDynamicRecordSetRoute(pRoutePayload)
|
|
206
|
+
{
|
|
207
|
+
if (typeof(pRoutePayload) != 'object')
|
|
208
|
+
{
|
|
209
|
+
throw new Error(`Pict RecordSet List view route handler called with invalid route payload.`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const tmpRecordSet = pRoutePayload.data.RecordSet;
|
|
213
|
+
|
|
214
|
+
const tmpEntity = pRoutePayload.data.Entity ? pRoutePayload.data.Entity : tmpRecordSet;
|
|
215
|
+
const tmpDefaultFilter = pRoutePayload.data.DefaultFilter ? pRoutePayload.data.DefaultFilter : '';
|
|
216
|
+
|
|
217
|
+
return this.loadRecordSetDynamcally(tmpRecordSet, tmpEntity, tmpDefaultFilter);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
addRoutes(pPictRouter)
|
|
221
|
+
{
|
|
222
|
+
pPictRouter.addRoute('/PSRS/:RecordSet/LoadDynamic', this.handleLoadDynamicRecordSetRoute.bind(this));
|
|
223
|
+
pPictRouter.addRoute('/PSRS/:RecordSet/LoadDynamic/:Entity', this.handleLoadDynamicRecordSetRoute.bind(this));
|
|
224
|
+
pPictRouter.addRoute('/PSRS/:RecordSet/LoadDynamic/:Entity/:DefaultFilter', this.handleLoadDynamicRecordSetRoute.bind(this));
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
157
228
|
initialize()
|
|
158
229
|
{
|
|
159
230
|
if (this.has_initialized)
|
|
@@ -174,23 +245,24 @@ class RecordSetMetacontroller extends libFableServiceProviderBase
|
|
|
174
245
|
this.childViews.read.initialize();
|
|
175
246
|
this.childViews.dashboard.initialize();
|
|
176
247
|
|
|
248
|
+
// Now initialize the router
|
|
249
|
+
|
|
177
250
|
if (this.fable.settings.hasOwnProperty('DefaultRecordSetConfigurations'))
|
|
178
251
|
{
|
|
179
252
|
this.loadRecordSetConfigurationArray(this.fable.settings.DefaultRecordSetConfigurations);
|
|
180
253
|
}
|
|
181
254
|
|
|
182
|
-
// Load pict-router if it isn't loaded
|
|
183
|
-
if (!('
|
|
255
|
+
this.has_initialized = true; // Load pict-router if it isn't loaded
|
|
256
|
+
if (!('RecordSetRouter' in this.fable.providers))
|
|
184
257
|
{
|
|
185
|
-
this.fable.addProvider('
|
|
258
|
+
this.fable.addProvider('RecordSetRouter', {}, providerRouter);
|
|
259
|
+
this.fable.providers.RecordSetRouter.initialize();
|
|
186
260
|
}
|
|
187
261
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return this;
|
|
262
|
+
return true;
|
|
191
263
|
}
|
|
192
264
|
}
|
|
193
265
|
|
|
194
266
|
module.exports = RecordSetMetacontroller;
|
|
195
267
|
|
|
196
|
-
RecordSetMetacontroller.default_configuration =
|
|
268
|
+
RecordSetMetacontroller.default_configuration = _DEFAULT_CONFIGURATION;
|