Skip to content

Commit d657580

Browse files
authored
Merge pull request #196 from aktos-io/dev
Dev
2 parents 7a0807e + 71e1759 commit d657580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+25498
-421
lines changed

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
VENV_NAME := scadajs1
1+
DIR:=$(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
2+
23
APP := main
3-
CONFIG := ../dcs-modules.txt
4+
CONFIG := $(DIR)../dcs-modules.txt
45

5-
.PHONY: test update-deps update-app-version
6+
.PHONY: test-es6-compat update-deps update-app-version
67

78
# Check if we are in a VIRTUAL_ENV:
9+
# the `NODE_VIRTUAL_ENV` variable is set by nodeenv after activating the environment.
810
__c:
911
$(if $(NODE_VIRTUAL_ENV),,$($(warning ************ WARNING: NOT INSIDE A VIRTUAL ENV ************)))
1012

1113
__app: # Check if APP name is set
1214
$(if $(APP),,$($(error *** APP variable is not set. ***)))
1315

14-
test: __c
15-
es-check es5 './release/$(APP)/**/*.js'
16+
test-es6-compat: __c
17+
es-check es6 './release/$(APP)/**/*.js'
1618

1719
update-deps: __c
1820
npm run interactive-update
1921

2022
update-app-version:
2123
touch lib/app-version.json
2224

23-
release: __c __prepare_release_dir __production __release_commit
25+
# Skip es-check with "make release ES_CHECK=skip
26+
ifeq ($(ES_CHECK),skip)
27+
release: __c __prepare_release_dir __production __release_commit
28+
else
29+
release: __c __prepare_release_dir __production test-es6-compat __release_commit
30+
endif
2431

2532
__production: __app
2633
gulp --webapp $(APP) --production
@@ -51,13 +58,25 @@ freeze-venv: __c
5158
freeze ./requirements.txt
5259

5360
create-venv:
54-
$(if $(SCADAJS_1_ENV),$(error SCADAJS_1_ENV variable is set, use it instead: $(SCADAJS_1_ENV)))
61+
ifndef SCADAJS_VENV_PATH
62+
$(error SCADAJS_VENV_PATH can not be empty. Please provide an installation path to create a venv.)
63+
endif
64+
ifneq ($(wildcard $(SCADAJS_VENV_PATH)/.*),)
65+
$(error SCADAJS_VENV_PATH is already created, use that instead: $(SCADAJS_VENV_PATH)))
66+
endif
67+
$(eval VENV_NAME := $(shell basename $(SCADAJS_VENV_PATH)))
5568
$(eval NODE_VERSION := $(shell echo `grep "^#node@" nodeenv.txt | cut -d@ -f2` | sed 's/^$$/system/'))
56-
nodeenv --requirement=./nodeenv.txt --node=$(NODE_VERSION) --prompt="($(VENV_NAME))" --jobs=4 nodeenv
69+
nodeenv --requirement=./nodeenv.txt --node=$(NODE_VERSION) --prompt="($(VENV_NAME))" --jobs=4 $(SCADAJS_VENV_PATH)
5770

5871
use-venv:
5972
./venv
6073

74+
update-venv:
75+
@echo "Virtual environment should not be updated. Create a new virtual environment"
76+
@echo "with the new dependency versions and use that venv instead. If there is no "
77+
@echo "breaking changes, simply backup the old venv and replace the new venv with "
78+
@echo "the old one. This is the safest path to follow."
79+
6180
__prepare_release_dir:
6281
@( if [ ! -d release/$(APP) ]; then \
6382
mkdir -p release; \

components/accordion/index.ls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Ractive.components['accordion'] = Ractive.extend do
2+
template: '<div class="ui accordion {{class}}">{{yield}}</div>'
3+
onrender: ->
4+
element = $ '.ui.accordion'
5+
element.accordion!
6+
@set 'element', element
7+
8+
data: ->
9+
element: null

components/ack-button/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
my-param = btn.get 'my-param'
2525
err, res <~ btn.actor.send-request "@foo.bar", {my: my-param}
2626
if err
27-
btn.state \error
27+
btn.error err
2828
else
2929
btn.state \done
3030
```
@@ -62,3 +62,7 @@ if err => btn?error "Some error message"
6262
btn?state \done...
6363
@logger.clog "changes done..."
6464
```
65+
66+
### Timeout
67+
68+
Use `timeout=` attribute to set timeout. Unit is `ms`.

components/ack-button/index.ls

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Ractive.components['ack-button'] = Ractive.extend do
2727

2828
set-button = (mode, message) ~>
2929
@set \state, mode
30-
message = if message then " |!| #{message}" else ''
30+
message = if message then " (!) #{message}" else ''
3131
@set \tooltip, "#{orig-tooltip}#{message}"
3232
unless mode is \doing
3333
@doing-watchdog.go!
@@ -61,18 +61,18 @@ Ractive.components['ack-button'] = Ractive.extend do
6161

6262
@state = (state) ~>
6363
switch state
64-
when \done =>
64+
| \done =>
6565
set-button \done
6666

67-
when \done... =>
67+
| \done... =>
6868
set-button \done
6969
<~ sleep 3000ms
7070
set-button \normal
7171

72-
when \normal =>
72+
| \normal =>
7373
set-button \normal
7474

75-
when \doing =>
75+
| \doing =>
7676
set-button \doing
7777
@set \selfDisabled, yes
7878
timeout <~ @doing-watchdog.wait @button-timeout
@@ -82,9 +82,12 @@ Ractive.components['ack-button'] = Ractive.extend do
8282
#logger.error msg
8383
set-button \error, msg
8484

85+
|_ => logger.error "Undefined ack-button state: #{state}"
86+
8587
@error = (msg, callback) ~>
86-
logger.error msg, callback
87-
set-button \error, (msg.message or msg)
88+
err = msg?.message or msg
89+
logger.error err, callback
90+
set-button \error, err
8891

8992
@warn = (msg, callback) ~>
9093
try
@@ -112,6 +115,9 @@ Ractive.components['ack-button'] = Ractive.extend do
112115
<~ sleep 200ms
113116
@set \heartbeat, no
114117

118+
@send-request = (opts={}, msg, callback) ~>
119+
@actor.send-request (opts <<< {timeout: @button-timeout}), msg, callback
120+
115121
if @get \auto
116122
logger.clog "auto firing ack-button!"
117123
@fire \_click

components/aktos-dcs/index.ls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Ractive.defaults.able = (permission) ->
1111
null
1212
permission `topic-match` permissions
1313

14+
Ractive.defaults.isAble = Ractive.defaults.able
15+
1416
Ractive.defaults.hasRoute = (route) ->
1517
routes = try
1618
@get \@global.session.routes
@@ -21,6 +23,8 @@ Ractive.defaults.hasRoute = (route) ->
2123
Ractive.defaults.unable = (...args) ->
2224
not Ractive.defaults.able.apply this, args
2325

26+
Ractive.defaults.isUnable = Ractive.defaults.unable
27+
2428
Ractive.defaults.loggedIn = ->
2529
if not @get('@global.session.token') or @get('@global.session.user') is \public
2630
return no

components/assign-if-null/index.ls

Lines changed: 0 additions & 10 deletions
This file was deleted.

components/checklist-button/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
items =
2+
* id: ...
3+
name: ...
4+
checked: true/false
5+
...
6+
7+
8+
Example usage:
9+
10+
Example Data:
11+
12+
items:
13+
* id: 1
14+
name: "rengine baktın mı "
15+
checked: yes
16+
* id: 2
17+
name: "kokusu uygun mu "
18+
* id: 3
19+
name: "ambalajı açılmış mı?"
20+
* id: 4
21+
name: "seri numarası var mı "
22+
* id: 5
23+
name: "hoşuna gitti mi"
24+
25+
JADE:
26+
27+
checklist-button(
28+
items="{{ xitems }}"
29+
on-success="checklistSucceeded"
30+
on-fail="checklistFailed"
31+
value="{{ xitems[0] }}"
32+
success-text="Mal Kabul Tamam"
33+
fail-text="Mal Kabul Reddedildi"
34+
)
35+
36+
LS:
37+
38+
39+
checklist-succeeded: (e, value) ->
40+
e.component.fire \state, \doing
41+
console.log "checklist succeeded: ", value
42+
<- sleep 2000ms
43+
e.component.fire \state, \done...
44+
45+
checklist-failed: (e, value) ->
46+
e.component.fire \state, \doing
47+
console.log "checklist failed: ", value
48+
<- sleep 2000ms
49+
e.component.fire \state, \done...
50+
51+
52+

components/checklist-button/index.pug

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,3 @@
1-
//-
2-
items =
3-
* id: ...
4-
name: ...
5-
checked: true/false
6-
...
7-
8-
9-
Example usage:
10-
11-
Example Data:
12-
13-
xitems:
14-
* id: 1
15-
name: "rengine baktın mı "
16-
checked: yes
17-
* id: 2
18-
name: "kokusu uygun mu "
19-
* id: 3
20-
name: "ambalajı açılmış mı?"
21-
* id: 4
22-
name: "seri numarası var mı "
23-
* id: 5
24-
name: "hoşuna gitti mi"
25-
26-
JADE:
27-
28-
checklist-button(
29-
items="{{ xitems }}"
30-
on-success="checklistSucceeded"
31-
on-fail="checklistFailed"
32-
value="{{ xitems[0] }}"
33-
success-text="Mal Kabul Tamam"
34-
fail-text="Mal Kabul Reddedildi"
35-
)
36-
37-
LS:
38-
39-
40-
checklist-succeeded: (e, value) ->
41-
e.component.fire \state, \doing
42-
console.log "checklist succeeded: ", value
43-
<- sleep 2000ms
44-
e.component.fire \state, \done...
45-
46-
checklist-failed: (e, value) ->
47-
e.component.fire \state, \doing
48-
console.log "checklist failed: ", value
49-
<- sleep 2000ms
50-
e.component.fire \state, \done...
51-
52-
53-
54-
55-
561
checklist(items="{{ items }}" completed="{{ completed }}")
572
ack-button(
583
on-click="success"

components/data-table/README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,30 @@ See https://aktos.io/st/#/showcase/data-table
44

55
# Properties
66

7-
- Marks last clicked row
8-
- Display a message while opening a row
7+
- Provides `on-init = (cb) -> cb!` function for initialization.
8+
- Executes a function while opening a row (`on-create-view = (row, cb) -> return cb(err, curr)` or `(row) ->> return curr`. `row` is the relevant element of `tableview` array.)
99
- Displays error or info messages
1010
- Opens appropriate row if url matches with document id
1111
- Scrolls to clicked row (or opening row by url)
12+
- Memorizes last clicked row (`isLastClicked(.id)`)
1213
- Disables other rows in order to prevent accidental openings while a row is opened
1314
- Displays a warning if a filter is selected other than `all`
1415

15-
# Names
16+
# Variables
1617

17-
tableview : whole array that has the minimum data to create table view
18+
`tableview` : Whole array that has the minimum data to create table view
1819

19-
tableview_visible: only the items for the current (selected) page of `tableview`
20+
`tableview_visible`: only the items for the current (selected) page of `tableview`
2021

21-
curr: current document that is selected or being created
22+
`curr`: current document that is selected or being created
2223

23-
readonly: if data-table has no `editForm` partial or set `readonly` explicitly, then it is readonly
24+
`readonly`: if data-table has no `editForm` partial or set `readonly` explicitly, then it is readonly
25+
26+
`print_mode`: (Bool) Indicates that current view form is in print mode.
27+
28+
`tmp`: (Object) A temporary variable that resets on every view-form creation.
29+
30+
`this.actor`: Data-table's actor.
2431

2532
# Partials (sections)
2633

@@ -35,16 +42,24 @@ editForm: The section that appears when something "Edit" button is pressed
3542

3643
`data-table` won't display any new entries unless it's successfully written to the database.
3744

38-
`curr` document will be fetched from database everytime
45+
`curr` document must be manually assigned within `on-create-view` handler.
46+
47+
if `auto-refresh` is not set to `yes`, a `Click to update` button will popup when table data is modified outside current window.
3948

40-
if `auto-refresh` is not set to `yes`, a `Click to update` button will popup when table data is
41-
modified outside current window.
49+
Fields declared in `search-field` must be maximum of 2 levels deep (`value.foo_bar` is okay but `value.foo.bar` is not okay).
4250

4351
# Mark last clicked row
4452

4553
Use `isLastClicked(rowId)`:
4654

47-
4855
.ui.basic.label(
4956
on-click="openRow"
5057
class="{{#if isLastClicked(.id)}}orange{{/if}}") {{.id}}
58+
59+
# Full screen
60+
61+
Any opened row may be displayed as full screen for printing purposes. To make a row go full screen,
62+
63+
1. Design your edit/view form with `{{print_mode}}` (`true`/`false`) variable to hide elements in print mode.
64+
2. Use `fire('make_row_full_screen')` and `fire('make_row_normal')` events to go to and return from full page.
65+
3. `@global.fullScreen` variable is set to true while in full page. Use this variable to hide the main menu.

components/data-table/controls.pug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
on-click="@.set('editable', true)"
1010
class-orange="editable"
1111
): icon.write
12+
13+
btn.inverted.red.icon(on-click="closeRow" tooltip="Close"): icon.remove

components/data-table/index.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,28 @@
1111
.data-table-clickable-row {
1212
cursor: pointer;
1313
}
14+
15+
.data-table-opened-row-full-screen {
16+
/*border: 4px dashed red; */ /* for debugging purposes */
17+
position:absolute;
18+
top:0px;
19+
left:0px;
20+
overflow-x: hidden;
21+
z-index: 999;
22+
background-color: white;
23+
}
24+
25+
.data-table-opened-row-full-screen .data-table-opened-row {
26+
width: 100vw;
27+
28+
-webkit-box-shadow: none;
29+
-moz-box-shadow: none;
30+
box-shadow: none;
31+
border-radius: 0;
32+
}
33+
34+
@media print {
35+
.data-table-opened-row {
36+
break-inside: avoid;
37+
}
38+
}

0 commit comments

Comments
 (0)