neo.mjs 7.0.5 → 7.1.0
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 -2
- package/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/index.html +1 -1
- package/apps/portal/model/Content.mjs +3 -2
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/portal/view/home/parts/Features.mjs +5 -5
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/todoList/version2/MainContainer.mjs +38 -48
- package/examples/todoList/version2/TodoList.mjs +6 -39
- package/examples/todoList/version2/TodoListModel.mjs +1 -1
- package/package.json +7 -7
- package/resources/data/deck/learnneo/pages/Welcome.md +0 -4
- package/resources/data/deck/learnneo/pages/guides/Forms.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/InstanceLifecycle.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/Layouts.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/Mixins.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/MultiWindow.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/Tables.md +1 -0
- package/resources/data/deck/learnneo/pages/guides/events/DomEvents.md +263 -0
- package/resources/data/deck/learnneo/pages/{TodoList.md → tutorials/TodoList.md} +23 -33
- package/resources/data/deck/learnneo/tree.json +45 -48
- package/resources/scss/src/component/Splitter.scss +10 -1
- package/resources/scss/theme-dark/component/Splitter.scss +6 -3
- package/resources/scss/theme-light/component/Splitter.scss +6 -3
- package/resources/scss/theme-neo-light/component/Splitter.scss +6 -20
- package/src/DefaultConfig.mjs +2 -2
- package/src/code/LivePreview.mjs +28 -1
- package/src/collection/Base.mjs +1 -0
- package/src/component/Splitter.mjs +22 -4
- package/src/controller/Component.mjs +10 -10
- package/src/core/Observable.mjs +4 -27
- package/src/draggable/DragZone.mjs +6 -5
- package/src/grid/View.mjs +82 -0
- package/src/list/Base.mjs +16 -0
- package/src/main/addon/DragDrop.mjs +3 -2
- package/src/manager/DomEvent.mjs +30 -18
- package/src/table/View.mjs +82 -0
- package/src/util/Function.mjs +24 -0
- package/resources/data/deck/learnneo/pages/2023-10-08T20-37-30-658Z.md +0 -0
- package/resources/data/deck/learnneo/pages/2023-10-08T22-22-11-013Z.md +0 -0
- package/resources/data/deck/learnneo/pages/Earthquakes-01-goals.md +0 -32
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-01-generate-a-workspace.md +0 -47
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-02-generate-the-starter-app.md +0 -150
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-03-debugging.md +0 -136
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-04-fetch-data.md +0 -146
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-05-refactor-the-table.md +0 -146
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-06-use-a-view-model.md +0 -301
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-07-use-the-google-maps-addon.md +0 -175
- package/resources/data/deck/learnneo/pages/Earthquakes-Lab-08-events.md +0 -38
- package/resources/data/deck/learnneo/pages/TestLivePreview.md +0 -32
- package/resources/data/deck/learnneo/pages/WhatAboutHTML.md +0 -1
- package/resources/data/deck/learnneo/pages/stylesheet.md +0 -57
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Effort.md → benefits/Effort.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Features.md → benefits/Features.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Intro.md → benefits/Introduction.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Multi-Window.md → benefits/Multi-Window.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Quick.md → benefits/Quick.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{WhyNeo-Speed.md → benefits/Speed.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{ComponentModels.md → gettingstarted/ComponentModels.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{Config.md → gettingstarted/Config.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{DescribingTheUI.md → gettingstarted/DescribingTheUI.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{Events.md → gettingstarted/Events.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{Extending.md → gettingstarted/Extending.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{References.md → gettingstarted/References.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{Setup.md → gettingstarted/Setup.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-14T19-25-08-153Z.md → gettingstarted/Workspaces.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{ComponentsAndContainers.md → guides/ComponentsAndContainers.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{CustomComponents.md → guides/CustomComponents.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{MainThreadAddonExample.md → guides/MainThreadAddonExample.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{MainThreadAddonIntro.md → guides/MainThreadAddonIntro.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{GuideViewModels.md → guides/ViewModels.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{GuideEvents.md → guides/events/CustomEvents.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-08T20-20-37-336Z.md → javascript/ClassFeatures.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-07T19-18-28-517Z.md → javascript/Classes.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-31T13-59-37-550Z.md → javascript/NewNode.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-08T20-20-07-934Z.md → javascript/Overrides.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{2023-10-08T21-58-25-809Z.md → javascript/Super.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{Earthquakes.md → tutorials/Earthquakes.md} +0 -0
- /package/resources/data/deck/learnneo/pages/{RSP.md → tutorials/RSP.md} +0 -0
@@ -1,301 +0,0 @@
|
|
1
|
-
<details>
|
2
|
-
<summary>Look at network traffic</summary>
|
3
|
-
|
4
|
-
Before making any changes, open devtools in the Network tab and refresh _earthquakes_. You'll see two
|
5
|
-
calls to the web service.
|
6
|
-
|
7
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTablesTwoCalls.png"></img>
|
8
|
-
|
9
|
-
</details>
|
10
|
-
|
11
|
-
<details>
|
12
|
-
<summary>Copy the store config to the view model</summary>
|
13
|
-
|
14
|
-
View models have two key configs: `data` and `stores`.
|
15
|
-
|
16
|
-
- `data` holds name/value pairs where the value can be a simple value, or object references
|
17
|
-
- `stores` holds configs of stores
|
18
|
-
|
19
|
-
Add a `stores` property to the view model config that holds a copy of the store.
|
20
|
-
|
21
|
-
<pre data-javascript>
|
22
|
-
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
23
|
-
import Controller from './MainViewController.mjs';
|
24
|
-
import EarthquakesTable from './earthquakes/Table.mjs';
|
25
|
-
import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
|
26
|
-
import ViewModel from './MainViewModel.mjs';
|
27
|
-
|
28
|
-
class MainView extends Base {
|
29
|
-
static config = {
|
30
|
-
className: 'Earthquakes.view.MainView',
|
31
|
-
ntype: 'earthquakes-main',
|
32
|
-
|
33
|
-
controller: {module: Controller},
|
34
|
-
model: {
|
35
|
-
module: ViewModel,
|
36
|
-
stores: {
|
37
|
-
earthquakes: {
|
38
|
-
module: Store,
|
39
|
-
model: {
|
40
|
-
fields: [{
|
41
|
-
name: "humanReadableLocation"
|
42
|
-
}, {
|
43
|
-
name: "size"
|
44
|
-
}, {
|
45
|
-
name: "timestamp",
|
46
|
-
type: "Date"
|
47
|
-
}]
|
48
|
-
},
|
49
|
-
url: "https://apis.is/earthquake/is",
|
50
|
-
responseRoot: "results",
|
51
|
-
autoLoad: true
|
52
|
-
},
|
53
|
-
}
|
54
|
-
},
|
55
|
-
|
56
|
-
layout: {
|
57
|
-
ntype: 'vbox', align: 'stretch'
|
58
|
-
},
|
59
|
-
items: [{
|
60
|
-
module: EarthquakesTable,
|
61
|
-
store: {
|
62
|
-
module: Store,
|
63
|
-
model: {
|
64
|
-
fields: [{
|
65
|
-
name: "humanReadableLocation"
|
66
|
-
}, {
|
67
|
-
name: "size"
|
68
|
-
}, {
|
69
|
-
name: "timestamp",
|
70
|
-
type: "Date"
|
71
|
-
}]
|
72
|
-
},
|
73
|
-
url: "https://apis.is/earthquake/is",
|
74
|
-
responseRoot: "results",
|
75
|
-
autoLoad: true
|
76
|
-
},
|
77
|
-
style: {width: '100%'}
|
78
|
-
},{
|
79
|
-
module: EarthquakesTable,
|
80
|
-
store: {
|
81
|
-
module: Store,
|
82
|
-
model: {
|
83
|
-
fields: [{
|
84
|
-
name: "humanReadableLocation"
|
85
|
-
}, {
|
86
|
-
name: "size"
|
87
|
-
}, {
|
88
|
-
name: "timestamp",
|
89
|
-
type: "Date"
|
90
|
-
}]
|
91
|
-
},
|
92
|
-
url: "https://apis.is/earthquake/is",
|
93
|
-
responseRoot: "results",
|
94
|
-
autoLoad: true
|
95
|
-
},
|
96
|
-
style: {width: '100%'}
|
97
|
-
}],
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
Neo.setupClass(MainView);
|
102
|
-
|
103
|
-
export default MainView;
|
104
|
-
|
105
|
-
</pre>
|
106
|
-
|
107
|
-
In the `stores` config we named the store _earthquakes_. We could have named it anything, like _foo_
|
108
|
-
or _myStore_. We're calling it _earthquakes_ simply because that seems like a good descriptive name
|
109
|
-
of the data the store holds.
|
110
|
-
|
111
|
-
At this point we have _three_ identical store configs! Save and refresh, and look at network traffic — you
|
112
|
-
should see three calls.
|
113
|
-
|
114
|
-
Having an instance in the view model means we can share it. It can be shared anywhere in the containment
|
115
|
-
hierarchy. The app doesn't have much of a hierarchy: it's just the main view and two child components (the two
|
116
|
-
tables). But now that the store is in the parent's view model we can share it.
|
117
|
-
|
118
|
-
</details>
|
119
|
-
|
120
|
-
<details>
|
121
|
-
<summary>Use the shared store</summary>
|
122
|
-
|
123
|
-
The way to bind an instance to a view model property is with the `bind` config. For example
|
124
|
-
|
125
|
-
bind: {
|
126
|
-
store: 'stores.earthquakes'
|
127
|
-
}
|
128
|
-
|
129
|
-
binds a `store` property to a store called `foo`. The code is saying _in the future, when the value
|
130
|
-
of "stores.earthquakes" changes, assign it to this object's "store" property_. In this case, `stores.earthquakes`
|
131
|
-
starts out undefined, then at runtime within a few milliseconds as the view model is processed, the configured
|
132
|
-
store is created and a reference is assigned to `stores.earthquakes`. That wakes the binding up, and the
|
133
|
-
value is assigned to the table's `store` property.
|
134
|
-
|
135
|
-
Replace each table's `store` config with the binding.
|
136
|
-
|
137
|
-
<pre data-javascript>
|
138
|
-
|
139
|
-
import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
140
|
-
import Controller from './MainViewController.mjs';
|
141
|
-
import EarthquakesTable from './earthquakes/Table.mjs';
|
142
|
-
import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
|
143
|
-
import ViewModel from './MainViewModel.mjs';
|
144
|
-
|
145
|
-
class MainView extends Base {
|
146
|
-
static config = {
|
147
|
-
className: 'Earthquakes.view.MainView',
|
148
|
-
ntype: 'earthquakes-main',
|
149
|
-
controller: {module: Controller},
|
150
|
-
model: {
|
151
|
-
module: ViewModel,
|
152
|
-
stores: {
|
153
|
-
earthquakes: {
|
154
|
-
module: Store,
|
155
|
-
model: {
|
156
|
-
fields: [{
|
157
|
-
name: "humanReadableLocation"
|
158
|
-
}, {
|
159
|
-
name: "size"
|
160
|
-
}, {
|
161
|
-
name: "timestamp",
|
162
|
-
type: "Date"
|
163
|
-
}]
|
164
|
-
},
|
165
|
-
url: "https://apis.is/earthquake/is",
|
166
|
-
responseRoot: "results",
|
167
|
-
autoLoad: true
|
168
|
-
},
|
169
|
-
}
|
170
|
-
},
|
171
|
-
|
172
|
-
layout: { ntype: 'vbox', align: 'stretch' },
|
173
|
-
items: [{
|
174
|
-
module: EarthquakesTable,
|
175
|
-
bind: {
|
176
|
-
store: 'stores.earthquakes'
|
177
|
-
},
|
178
|
-
style: {width: '100%'}
|
179
|
-
},{
|
180
|
-
module: EarthquakesTable,
|
181
|
-
bind: {
|
182
|
-
store: 'stores.earthquakes'
|
183
|
-
},
|
184
|
-
style: {width: '100%'}
|
185
|
-
}],
|
186
|
-
}
|
187
|
-
}
|
188
|
-
|
189
|
-
Neo.setupClass(MainView);
|
190
|
-
|
191
|
-
export default MainView;
|
192
|
-
</pre>
|
193
|
-
|
194
|
-
Save, refresh, and look at network traffic: you'll see a _single_ call to the web service.
|
195
|
-
|
196
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTablesOneCall.png"></img>
|
197
|
-
|
198
|
-
You can further prove we're using a shared instance by running these statements in the console.
|
199
|
-
|
200
|
-
<pre data-javascript>
|
201
|
-
a = Neo.findFirst({ntype:'earthquakes-main'}).model.stores.earthquakes;
|
202
|
-
b = Neo.find({ntype:'earthquakes-table'})[0].store;
|
203
|
-
c = Neo.find({ntype:'earthquakes-table'})[1].store;
|
204
|
-
|
205
|
-
(a === b) && (a === c) && (b === c) // true
|
206
|
-
</pre>
|
207
|
-
|
208
|
-
</details>
|
209
|
-
|
210
|
-
<details>
|
211
|
-
<summary>Use the view model class</summary>
|
212
|
-
|
213
|
-
We configured the view model in-line, in the `model` config at the top of `MainView`. But the starter app
|
214
|
-
has a `MainViewModel` class. In theory, if you have a trivial view model you could configure it in-line. But
|
215
|
-
in general you want to keep that code separate by coding it in a separate class. This is what we did for the
|
216
|
-
table config — we started by coding it in-line in the main view, then we refactored it into its own
|
217
|
-
class. The result was a simpler and more abstract main view. We want to do the same for the view model.
|
218
|
-
|
219
|
-
Since the starter app already provides `MainViewModel`, all we need to do is copy the `stores` property.
|
220
|
-
|
221
|
-
Here's the resulting code you should place into `MainViewModel.mjs`.
|
222
|
-
|
223
|
-
<pre data-javascript>
|
224
|
-
import Model from '../../../node_modules/neo.mjs/src/model/Component.mjs';
|
225
|
-
import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
|
226
|
-
|
227
|
-
class MainViewModel extends Model {
|
228
|
-
static config = {
|
229
|
-
className: 'Earthquakes.view.MainViewModel',
|
230
|
-
|
231
|
-
data: {},
|
232
|
-
stores: {
|
233
|
-
earthquakes: {
|
234
|
-
module: Store,
|
235
|
-
model: {
|
236
|
-
fields: [{
|
237
|
-
name: "humanReadableLocation"
|
238
|
-
}, {
|
239
|
-
name: "size"
|
240
|
-
}, {
|
241
|
-
name: "timestamp",
|
242
|
-
type: "Date"
|
243
|
-
}]
|
244
|
-
},
|
245
|
-
url: "https://apis.is/earthquake/is",
|
246
|
-
responseRoot: "results",
|
247
|
-
autoLoad: true
|
248
|
-
},
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
|
253
|
-
Neo.setupClass(MainViewModel);
|
254
|
-
|
255
|
-
export default MainViewModel;
|
256
|
-
</pre>
|
257
|
-
|
258
|
-
And you need to remove the `stores` config from the main view as follows.
|
259
|
-
|
260
|
-
<pre data-javascript>
|
261
|
-
import Container from '../../../node_modules/neo.mjs/src/container/Base.mjs';
|
262
|
-
import Controller from './MainViewController.mjs';
|
263
|
-
import EarthquakesTable from './earthquakes/Table.mjs';
|
264
|
-
import ViewModel from './MainViewModel.mjs';
|
265
|
-
|
266
|
-
class MainView extends Container {
|
267
|
-
static config = {
|
268
|
-
className: 'Earthquakes.view.MainView',
|
269
|
-
ntype: 'earthquakes-main',
|
270
|
-
controller: {module: Controller},
|
271
|
-
model: {
|
272
|
-
module: ViewModel
|
273
|
-
},
|
274
|
-
|
275
|
-
layout: { ntype: 'vbox', align: 'stretch' },
|
276
|
-
items: [{
|
277
|
-
module: EarthquakesTable,
|
278
|
-
bind: {
|
279
|
-
store: 'stores.earthquakes'
|
280
|
-
},
|
281
|
-
style: {width: '100%'}
|
282
|
-
},{
|
283
|
-
module: EarthquakesTable,
|
284
|
-
bind: {
|
285
|
-
store: 'stores.earthquakes'
|
286
|
-
},
|
287
|
-
style: {width: '100%'}
|
288
|
-
}]
|
289
|
-
}
|
290
|
-
}
|
291
|
-
|
292
|
-
Neo.setupClass(MainView);
|
293
|
-
|
294
|
-
export default MainView;
|
295
|
-
</pre>
|
296
|
-
|
297
|
-
The refactorings to have separate table and view model classes means the code is more modular, more reusable,
|
298
|
-
and each class is simpler than using complex source files that try to configure every detail.
|
299
|
-
|
300
|
-
</details>
|
301
|
-
|
@@ -1,175 +0,0 @@
|
|
1
|
-
<details>
|
2
|
-
<summary>Get the code for the custom add-on</summary>
|
3
|
-
At the time this tutorial was written, the Neo.mjs Google Maps addon was about to be updated to
|
4
|
-
accomodate Google's "AdvancedMarker" class. Until that's ready, we're going to use a modified version of the add-on.
|
5
|
-
|
6
|
-
Download and unzip this file, and copy the two source files to the corresponding subdirectories in
|
7
|
-
your workspace's `src` directory. Note that `src` already contains some files, so don't replace the whole
|
8
|
-
directory, but instead, move the files to their individual locations.
|
9
|
-
|
10
|
-
<a href="https://s3.amazonaws.com/mjs.neo.learning.images/zip/src.zip">src.zip</a>
|
11
|
-
|
12
|
-
<img src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/CopyGoogleMapsFiles.png" width="30%%"></img>
|
13
|
-
</details>
|
14
|
-
|
15
|
-
<details>
|
16
|
-
<summary>Specify the main-thread add-on</summary>
|
17
|
-
|
18
|
-
Edit `apps/earthquakes/neo-config.json` and add entries for the Google Maps add-on and the map key.
|
19
|
-
|
20
|
-
<pre data-javascript>
|
21
|
-
{
|
22
|
-
"appPath": "../../apps/earthquakes/app.mjs",
|
23
|
-
"basePath": "../../",
|
24
|
-
"environment": "development",
|
25
|
-
"mainPath": "../node_modules/neo.mjs/src/Main.mjs",
|
26
|
-
"mainThreadAddons": [
|
27
|
-
"DragDrop",
|
28
|
-
"WS/GoogleMaps",
|
29
|
-
"Stylesheet"
|
30
|
-
],
|
31
|
-
"googleMapsApiKey": "AIzaSyD4Y2xvl9mGT8HiVvQiZluT5gah3OIveCE",
|
32
|
-
"themes" : ["neo-theme-neo-light"],
|
33
|
-
"workerBasePath": "../../node_modules/neo.mjs/src/worker/"
|
34
|
-
}
|
35
|
-
</pre>
|
36
|
-
|
37
|
-
It's unusual to need to edit `neo-config.json`. The app theme is specified there, and so are main thread add-ons.
|
38
|
-
In our case, we're adding `WS/GoogleMaps` which in turn requires that we specify the map key. The `WS/`
|
39
|
-
prefix tells Neo.mjs that the add-on is in our workspace, rather than an add-on provided by Neo.mjs.
|
40
|
-
|
41
|
-
Save and refresh, and you'll see a console log emanating from the plugin.
|
42
|
-
|
43
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/GoogleMapsLoaded.png"></img>
|
44
|
-
|
45
|
-
</details>
|
46
|
-
|
47
|
-
<details>
|
48
|
-
<summary>Add the required fields to the records</summary>
|
49
|
-
|
50
|
-
The Google Maps component has a `markerStore` property, which is a reference to a store whose records have
|
51
|
-
the properties `title` and `location`, where `location` is of the form `{lat: 0, lng: 0}`. The `fields:[]`
|
52
|
-
lets us implement those via two properties:
|
53
|
-
|
54
|
-
- `mapping` — the path to a feed property holding the value
|
55
|
-
- `calculate` — a function that returns a value
|
56
|
-
|
57
|
-
Edit `apps/earthquakes/view/MainViewModel.mjs` and modify `fields` as follows.
|
58
|
-
|
59
|
-
<pre data-javascript>
|
60
|
-
fields: [{
|
61
|
-
name: "humanReadableLocation",
|
62
|
-
}, {
|
63
|
-
name: "size",
|
64
|
-
}, {
|
65
|
-
name: "timestamp",
|
66
|
-
type: "Date",
|
67
|
-
}, {
|
68
|
-
name: 'title',
|
69
|
-
mapping: "humanReadableLocation"
|
70
|
-
}, {
|
71
|
-
name: "position",
|
72
|
-
calculate: (data, field, item)=>({lat: item.latitude, lng: item.longitude})
|
73
|
-
}],
|
74
|
-
</pre>
|
75
|
-
|
76
|
-
As you can see, _title_ is mapped to the existing feed value _humanReadableLocation_, and _position_ is
|
77
|
-
calculated by returning an object with _lat_ and _lng_ set to the corresponding values from the feed.
|
78
|
-
|
79
|
-
Save and refresh _earthquakes_. You can use the debugger to inspect the store via _Shift-Ctrl-right-click_ and
|
80
|
-
putting the main view into a global variable. Then run
|
81
|
-
|
82
|
-
temp1.getModel().stores.earthquakes.items
|
83
|
-
|
84
|
-
Look at one of the items and you should see that _title_ and _location_ are in each record.
|
85
|
-
|
86
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/StoreHasTitleAndLocation.png"></img>
|
87
|
-
|
88
|
-
</details>
|
89
|
-
|
90
|
-
<details>
|
91
|
-
<summary>Use the Google Map Component</summary>
|
92
|
-
|
93
|
-
We're going to replace the top table with a Google Map. To do that we need to import the Google Maps component
|
94
|
-
and show it implace of the top table. The map should be centered on Iceland. To wit
|
95
|
-
|
96
|
-
<pre>
|
97
|
-
{
|
98
|
-
module: GoogleMapsComponent,
|
99
|
-
flex: 1,
|
100
|
-
center: {
|
101
|
-
lat: 64.8014187,
|
102
|
-
lng: -18.3096357
|
103
|
-
},
|
104
|
-
zoom: 6
|
105
|
-
}
|
106
|
-
</pre>
|
107
|
-
|
108
|
-
If we replace the top table with the map, `view/MainView.mjs` ends up with this content.
|
109
|
-
|
110
|
-
<pre data-javascript>
|
111
|
-
|
112
|
-
import Container from '../container/Base.mjs';
|
113
|
-
import Controller from './MainViewController.mjs';
|
114
|
-
import EarthquakesTable from './earthquakes/Table.mjs';
|
115
|
-
import GoogleMapsComponent from '../component/wrapper/GoogleMaps.mjs';
|
116
|
-
import ViewModel from './MainViewModel.mjs';
|
117
|
-
|
118
|
-
class MainView extends Container {
|
119
|
-
static config = {
|
120
|
-
className: 'Earthquakes.view.MainView',
|
121
|
-
ntype: 'earthquakes-main',
|
122
|
-
controller: {module: Controller},
|
123
|
-
model: {
|
124
|
-
module: ViewModel
|
125
|
-
},
|
126
|
-
|
127
|
-
layout: { ntype: 'vbox', align: 'stretch' },
|
128
|
-
items: [{
|
129
|
-
module: GoogleMapsComponent,
|
130
|
-
flex: 1,
|
131
|
-
center: {
|
132
|
-
lat: 64.8014187,
|
133
|
-
lng: -18.3096357
|
134
|
-
},
|
135
|
-
zoom: 6
|
136
|
-
},{
|
137
|
-
module: EarthquakesTable,
|
138
|
-
bind: {
|
139
|
-
store: 'stores.earthquakes'
|
140
|
-
},
|
141
|
-
style: {width: '100%'},
|
142
|
-
wrapperStyle: {
|
143
|
-
height: 'auto' // Because neo-table-wrapper sets height:'100%', which it probably shouldn't
|
144
|
-
}
|
145
|
-
}],
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
Neo.setupClass(MainView);
|
150
|
-
|
151
|
-
export default MainView;
|
152
|
-
</pre>
|
153
|
-
|
154
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/CenteredMap.png"></img>
|
155
|
-
|
156
|
-
|
157
|
-
</details>
|
158
|
-
|
159
|
-
<details>
|
160
|
-
<summary>Show the markers</summary>
|
161
|
-
|
162
|
-
The markers are shown by setting up the marker store, which is a regular store whose records must contain
|
163
|
-
_location_ and _title_. We assign the store using a `bind`, just like we did with the tables.
|
164
|
-
|
165
|
-
Add this config to the map.
|
166
|
-
|
167
|
-
<pre data-javascript>
|
168
|
-
bind: {
|
169
|
-
markerStore: 'stores.earthquakes'
|
170
|
-
},
|
171
|
-
</pre>
|
172
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/InitialMapWithMarkers.png"></img>
|
173
|
-
|
174
|
-
</details>
|
175
|
-
|
@@ -1,38 +0,0 @@
|
|
1
|
-
In this lab you'll set up an event handler for the table and map.
|
2
|
-
|
3
|
-
<details>
|
4
|
-
<summary>Add a listener to the table</summary>
|
5
|
-
|
6
|
-
Tables fire a select event, passing an object that contains a reference to the corresponding row.
|
7
|
-
|
8
|
-
Add this table config:
|
9
|
-
|
10
|
-
listeners: {
|
11
|
-
select: (data) => console.log(data.record)
|
12
|
-
}
|
13
|
-
|
14
|
-
Save and refresh, then click on a table row. If you look at the debugger console you'll see the record being logged.
|
15
|
-
|
16
|
-
Just for fun, expand the logged value and look for the size property. If you recall, that's a value from the feed, and one of the things we configured in the store's fields:[].
|
17
|
-
|
18
|
-
In the console, click on the ellipses by size and enter a new value, like 2.5. (Don't enter a larger value, or you may destroy that part of Iceland.)
|
19
|
-
|
20
|
-
<img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/LogTableClick.png"></img>
|
21
|
-
|
22
|
-
After changing the value you should immediately see it reflected in the table row.
|
23
|
-
|
24
|
-
</details>
|
25
|
-
|
26
|
-
<details>
|
27
|
-
<summary>Add a listener to a map event
|
28
|
-
</summary>
|
29
|
-
|
30
|
-
Now add a `markerClick` listener to the Google Map.
|
31
|
-
|
32
|
-
listeners: {
|
33
|
-
markerClick: data => console.log(data.data.record)
|
34
|
-
},
|
35
|
-
|
36
|
-
Save, refresh, and confirm that you see the value logged when you click on a map marker.
|
37
|
-
|
38
|
-
</details>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
To code a live preview, enclose the code in a `pre` tag with the `data-neo` attribute.
|
2
|
-
|
3
|
-
<code><pre data-neo>...</pre> <</code>
|
4
|
-
|
5
|
-
Imports are relative to the portal app running within the framework. That means
|
6
|
-
Neo.mjs imports should be coded to go up four levels, then look into the `src`
|
7
|
-
directory. For example, to import _container_, use `import Base from '../container/Base.mjs`
|
8
|
-
|
9
|
-
You can define as many classes you need, such as component models and controllers, but the the _last_
|
10
|
-
class being defined is assumed to be the view being rendered. In other words, if the final class definition is a component, it's rendered.
|
11
|
-
|
12
|
-
<pre data-neo>
|
13
|
-
import Base from '../container/Base.mjs';
|
14
|
-
import Button from '../button/Base.mjs';
|
15
|
-
import Split from '../button/Split.mjs';
|
16
|
-
|
17
|
-
class Bar extends Base {
|
18
|
-
static config = {
|
19
|
-
ntype: 'demoFoo',
|
20
|
-
className: 'Foo.Bar',
|
21
|
-
layout: {ntype: 'hbox'},
|
22
|
-
items: [{
|
23
|
-
module: Button,
|
24
|
-
text: 'Button One'
|
25
|
-
},{
|
26
|
-
module: Button,
|
27
|
-
text: 'Button Two'
|
28
|
-
}]
|
29
|
-
}
|
30
|
-
}
|
31
|
-
Bar = Neo.setupClass(Bar);
|
32
|
-
</pre>
|
@@ -1 +0,0 @@
|
|
1
|
-
### todo: What about HTML tags?
|
@@ -1,57 +0,0 @@
|
|
1
|
-
<details>
|
2
|
-
<summary>Training material advice</summary>
|
3
|
-
Training content is different than self-study content.
|
4
|
-
Training material _augments_ the lecture. The audience should be focused on what the speaker is
|
5
|
-
saying; the slides support the lecture. An important concept in writing
|
6
|
-
training material is to avoid a _wall of words_, where there are lengthy
|
7
|
-
paragraphs. People will read what's in front of them. If you have a lecture slide
|
8
|
-
with a lot of text, your audience will be reading while you are lecturing,
|
9
|
-
and information is lost.
|
10
|
-
</details>
|
11
|
-
|
12
|
-
|
13
|
-
# This is an h1
|
14
|
-
## This is an h2
|
15
|
-
### This is an h3
|
16
|
-
#### This is an h4
|
17
|
-
|
18
|
-
<br>
|
19
|
-
|
20
|
-
To show highlighted Neo.mjs source code use
|
21
|
-
<pre data-javascript>
|
22
|
-
// Source code goes here
|
23
|
-
</pre>
|
24
|
-
|
25
|
-
<pre data-javascript>
|
26
|
-
import Base from '../../../node_modules/neo.mjs/src/core/Base.mjs';
|
27
|
-
|
28
|
-
class Mammal extends Base {
|
29
|
-
static config = {
|
30
|
-
className: 'Simple.example.Mammal'
|
31
|
-
}
|
32
|
-
}
|
33
|
-
</pre>
|
34
|
-
|
35
|
-
For short in-line statements of code use <code> or backticks.
|
36
|
-
|
37
|
-
When defining variables avoid `var` — use `let` or `const` instead.
|
38
|
-
|
39
|
-
<br>
|
40
|
-
|
41
|
-
For expandable bullet points and lab steps use a <details> tag
|
42
|
-
<pre>
|
43
|
-
<details>
|
44
|
-
<summary>This describes the item</summary>
|
45
|
-
This is the item contents.
|
46
|
-
</details>
|
47
|
-
</pre>
|
48
|
-
|
49
|
-
<details>
|
50
|
-
<summary>This describes the item</summary>
|
51
|
-
This is the item contents.
|
52
|
-
</details>
|
53
|
-
|
54
|
-
<pre data-neo>
|
55
|
-
let a = 1;
|
56
|
-
</pre>
|
57
|
-
|
File without changes
|
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{WhyNeo-Multi-Window.md → benefits/Multi-Window.md}
RENAMED
File without changes
|
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{ComponentModels.md → gettingstarted/ComponentModels.md}
RENAMED
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{DescribingTheUI.md → gettingstarted/DescribingTheUI.md}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{CustomComponents.md → guides/CustomComponents.md}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{GuideEvents.md → guides/events/CustomEvents.md}
RENAMED
File without changes
|
File without changes
|
/package/resources/data/deck/learnneo/pages/{2023-10-07T19-18-28-517Z.md → javascript/Classes.md}
RENAMED
File without changes
|
/package/resources/data/deck/learnneo/pages/{2023-10-31T13-59-37-550Z.md → javascript/NewNode.md}
RENAMED
File without changes
|
/package/resources/data/deck/learnneo/pages/{2023-10-08T20-20-07-934Z.md → javascript/Overrides.md}
RENAMED
File without changes
|
/package/resources/data/deck/learnneo/pages/{2023-10-08T21-58-25-809Z.md → javascript/Super.md}
RENAMED
File without changes
|
File without changes
|
File without changes
|