Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions lib/forms/wms_operator_toolbar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule WMS.Operator.Toolbar do

def list_mode() do
NITRO.panel(
class: :operator_toolbar,
class: :wms_toolbar,
body: [
NITRO.panel(
class: :toolbar_actions,
Expand Down Expand Up @@ -64,20 +64,10 @@ defmodule WMS.Operator.Toolbar do
)
end

def form_mode(title) do
NITRO.panel(
class: :operator_toolbar,
body: [
NITRO.panel(
class: :toolbar_actions,
body: [
NITRO.panel(
class: :button,
body: title
)
]
)
]
)
def form_mode() do
NITRO.panel(
class: :wms_toolbar,
body: []
)
end
end
89 changes: 89 additions & 0 deletions lib/forms/wms_part_edit_form.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
defmodule WMS.Part.EditForm do
require EXO
require FORM

def id(), do: EXO.wms_part()

def new(name, part, _) do
FORM.document(
name: :form.atom([:wms_part_edit, name]),
sections: [
FORM.sec(name: ["Редагування деталі: ", EXO.wms_part(part, :id)])
],
buttons: [
FORM.but(
id: :decline,
name: :decline,
title: "Відміна",
class: [:button, :cancel],
postback: {:Close, []}
),
FORM.but(
id: :proceed,
name: :proceed,
title: "Зберегти",
class: [:button, :sgreen],
sources: [
:serial_number_wms_part_create,
:part_type_wms_part_create,
:part_status_wms_part_create,
:installed_in_weapon_wms_part_create,
:storage_location_wms_part_create,
:manufacturer_wms_part_create
],
postback: {:UpdatePart, EXO.wms_part(part, :id)}
)
],
fields: [
FORM.field(
id: :serial_number,
name: :serial_number,
type: :string,
title: "Серійний номер",
labelClass: :label,
default: EXO.wms_part(part, :serial_number)
),
FORM.field(
id: :part_type,
name: :part_type,
type: :string,
title: "Тип",
labelClass: :label,
default: EXO.wms_part(part, :part_type)
),
FORM.field(
id: :part_status,
name: :part_status,
type: :string,
title: "Статус",
labelClass: :label,
default: EXO.wms_part(part, :part_status)
),
FORM.field(
id: :installed_in_weapon,
name: :installed_in_weapon,
type: :string,
title: "ID зброї",
labelClass: :label,
default: EXO.wms_part(part, :installed_in_weapon)
),
FORM.field(
id: :storage_location,
name: :storage_location,
type: :string,
title: "Локація зберігання",
labelClass: :label,
default: EXO.wms_part(part, :storage_location)
),
FORM.field(
id: :manufacturer,
name: :manufacturer,
type: :string,
title: "Виробник",
labelClass: :label,
default: EXO.wms_part(part, :manufacturer)
)
]
)
end
end
20 changes: 17 additions & 3 deletions lib/forms/wms_part_row.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ defmodule WMS.Part.Row do
id = EXO.wms_part(part, :id)
serial_number = EXO.wms_part(part, :serial_number)
part_type = EXO.wms_part(part, :part_type)
part_status = EXO.wms_part(part, :part_status)

part_status =
part
|> EXO.wms_part(:part_status)
|> WMS.PartRules.clean()
|> WMS.PartRules.status_title()

installed_in_weapon = EXO.wms_part(part, :installed_in_weapon)
storage_location = EXO.wms_part(part, :storage_location)
manufacturer = EXO.wms_part(part, :manufacturer)
Expand All @@ -27,8 +33,16 @@ defmodule WMS.Part.Row do
NITRO.panel(class: :column20, body: :nitro.to_binary(part_status)),
NITRO.panel(class: :column20, body: :nitro.to_binary(installed_in_weapon)),
NITRO.panel(class: :column20, body: :nitro.to_binary(storage_location)),
NITRO.panel(class: :column20, body: :nitro.to_binary(manufacturer))

NITRO.panel(class: :column20, body: :nitro.to_binary(manufacturer)),
NITRO.panel(
class: :column20,
body:
NITRO.link(
body: "Редагувати",
postback: {:EditPart, id},
class: [:button, :sgreen]
)
)
]
)
end
Expand Down
50 changes: 43 additions & 7 deletions lib/forms/wms_part_toolbar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,57 @@ defmodule WMS.Part.Toolbar do

def list_mode() do
NITRO.panel(
class: :part_create_button,
class: :wms_toolbar,
body: [
NITRO.link(
id: :creator,
body: "Додати деталь",
postback: :create,
class: [:button, :sgreen]
NITRO.panel(
class: :toolbar_actions,
body: [
NITRO.link(
id: :add_part,
body: "Додати деталь",
postback: :create,
class: [:button, :sgreen]
)
]
),
NITRO.panel(
class: :toolbar_filters,
body: [
NITRO.input(
id: :part_search,
placeholder: "ID, серійний номер, тип, виробник"
),
NITRO.select(
id: :part_status_filter,
body: [
NITRO.option(value: "all", body: "Усі статуси"),
NITRO.option(value: "installed", body: "Встановлена"),
NITRO.option(value: "spare", body: "Запасна"),
NITRO.option(value: "broken", body: "Несправна"),
NITRO.option(value: "removed", body: "Знята"),
NITRO.option(value: "decommissioned", body: "Списана")
]
),
NITRO.link(
body: "Пошук",
postback: :search_part,
class: [:button, :sgreen],
source: [:part_search, :part_status_filter]
),
NITRO.link(
body: "Очистити",
postback: :clear_part_search,
class: [:button, :sgreen]
)
]
)
]
)
end

def form_mode() do
NITRO.panel(
class: :part_toolbar,
class: :wms_toolbar,
body: []
)
end
Expand Down
37 changes: 15 additions & 22 deletions lib/forms/wms_weapon_row.ex
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
defmodule WMS.Weapon.Row do
defmodule WMS.Weapon.Row do
require EXO
require NITRO
require FORM

def id(), do: EXO.wms_weapon()
def doc(), do: "Форма реєстрації зброї (таблична частина)"

def status_title("active"), do: "На озброєнні"
def status_title("repair"), do: "На ремонті"
def status_title("maintenance"), do: "На обслуговуванні"
def status_title("destroyed"), do: "Знищено"
def status_title("decommissioned"), do: "Списана"
def status_title("transfer"), do: "У дорозі"
def status_title(value), do: value

def new(name, weapon, _) do
id = EXO.wms_weapon(weapon, :id)
serial_number = EXO.wms_weapon(weapon, :serial_number)
model = EXO.wms_weapon(weapon, :weapon_model)
owner = EXO.wms_weapon(weapon, :owner)
license = EXO.wms_weapon(weapon, :license)
storage_location = EXO.wms_weapon(weapon, :storage_location)
status = EXO.wms_weapon(weapon, :status)

status_value =
status
|> :nitro.to_binary()
|> String.trim()
status =
weapon
|> EXO.wms_weapon(:status)
|> WMS.WeaponRules.clean()
|> WMS.WeaponRules.status_title()

NITRO.panel(
id: :form.atom([:tr, name]),
Expand All @@ -38,14 +30,15 @@ defmodule WMS.Weapon.Row do
NITRO.panel(class: :column20, body: :nitro.to_binary(owner)),
NITRO.panel(class: :column10, body: :nitro.to_binary(license)),
NITRO.panel(class: :column20, body: :nitro.to_binary(storage_location)),
NITRO.panel(class: :column20, body: status_title(status_value)),
NITRO.panel(class: :column20,
body:
NITRO.link(
body: "Редагувати",
postback: {:EditWeapon, id},
class: [:button, :sgreen]
)
NITRO.panel(class: :column20, body: :nitro.to_binary(status)),
NITRO.panel(
class: :column20,
body:
NITRO.link(
body: "Редагувати",
postback: {:EditWeapon, id},
class: [:button, :sgreen]
)
)
]
)
Expand Down
10 changes: 5 additions & 5 deletions lib/pages/wms_operator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ defmodule EXO.WMS.Operator do
if weapon != nil do
:nitro.clear(:frms)

render_toolbar({:form, "Редагування зброї: #{:nitro.to_binary(id)}"})
render_toolbar(:form)

:nitro.insert_bottom(
:frms,
Expand Down Expand Up @@ -211,10 +211,10 @@ defmodule EXO.WMS.Operator do
:nitro.insert_bottom(:ctrl, WMS.Operator.Toolbar.list_mode())
end

def render_toolbar({:form, title}) do
:nitro.clear(:ctrl)
:nitro.insert_bottom(:ctrl, WMS.Operator.Toolbar.form_mode(title))
end
def render_toolbar(:form) do
:nitro.clear(:ctrl)
:nitro.insert_bottom(:ctrl, WMS.Operator.Toolbar.form_mode())
end

def event(:create_service_order) do
:nitro.redirect("repair.htm")
Expand Down
Loading