-
Notifications
You must be signed in to change notification settings - Fork 0
/
exo_tariffs.ex
59 lines (53 loc) · 2.01 KB
/
exo_tariffs.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
defmodule EXO.Tariffs do
require EXO
require BPE
require NITRO
def event(:init) do
:nitro.clear(:tableHead)
:nitro.clear(:tableRow)
:nitro.insert_top(:tableHead, header())
:nitro.clear(:frms)
:nitro.clear(:ctrl)
mod = Program.Form
form = :form.new(mod.new(mod,mod.id(), []), mod.id(), [])
:nitro.insert_bottom(:frms, form)
:nitro.insert_bottom(:ctrl,
NITRO.link(id: :creator, body: "Новий", postback: :create, class: [:button, :sgreen]))
:nitro.hide(:frms)
:lists.map(fn x -> :nitro.insert_top(:tableRow,
Program.Row.new(:form.atom([:row, EXO.program(x, :id)]), x, [])) end, :kvs.all('/exo/tariffs'))
end
def event(:create) do
:nitro.hide(:ctrl)
:nitro.show(:frms)
end
def event({:"CreateTariff", _}) do
date = :date_program_none |> :nitro.q
type = :type_program_none |> :nitro.q
name = :name_program_none |> :nitro.q
formula = :formula_program_none |> :nitro.q
id = :kvs.seq([],[])
tariff = EXO.program(date: date, id: id, formula: formula, name: name, type: type)
nitro = :form.new Program.Row.new(:form.atom([:row,name]), tariff, []), tariff, []
:kvs.append tariff, '/exo/tariffs'
:nitro.insert_top(:tableRow, nitro)
:nitro.hide(:frms)
:nitro.show(:ctrl)
end
def event({:"Close", []}) do
:nitro.hide(:frms)
:nitro.show(:ctrl)
end
def event(_), do: :ok
def header() do
NITRO.panel(id: :header,
class: :th,
body: [
NITRO.panel(class: :column20, body: "Імя"),
NITRO.panel(class: :column20, body: "Тип"),
NITRO.panel(class: :column20, body: "Формула"),
NITRO.panel(class: :column20, body: "Дата"),
NITRO.panel(class: :column20, body: "Коментар"),
] )
end
end