Skip to content

Commit

Permalink
Added the ability to add multiple values
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRiseGC authored and 5HT committed Oct 6, 2020
1 parent cb72e7b commit 615195a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/comboLookupEdit.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
-define(COMBO_LOOKUP_EDIT_HRL, true).

-include_lib("nitro/include/nitro.hrl").
-record(comboLookupEdit, {?ELEMENT_BASE(element_comboLookupEdit), input, disabled, form}).
-record(comboLookupEdit, {?ELEMENT_BASE(element_comboLookupEdit), input, disabled, form, values, multiple}).

-endif.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule NITRO.Mixfile do
def project do
[
app: :nitro,
version: "5.9.1",
version: "5.9.2",
description: "NITRO Nitrogen Web Framework",
package: package(),
deps: deps()
Expand Down
20 changes: 17 additions & 3 deletions src/elements/combo/element_comboLookupEdit.erl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
-module(element_comboLookupEdit).
-include_lib("nitro/include/comboLookupEdit.hrl").
-include_lib("nitro/include/comboLookup.hrl").
-include_lib("nitro/include/sortable_list.hrl").
-include_lib("nitro/include/nitro.hrl").
-include_lib("nitro/include/event.hrl").
-export([render_element/1]).

render_element(#comboLookupEdit{id=Id, input=Input, disabled=Disabled, validation=Validation, form=Form}) ->
render_element(#comboLookupEdit{id=Id, input=Input, disabled=Disabled, validation=Validation, form=Form, values=Values, multiple=Multiple}) ->
ListId = form:atom([Id, "list"]),
InputId = element(#element.id, Input),
nitro:render(
#panel{
Expand All @@ -17,12 +19,24 @@ render_element(#comboLookupEdit{id=Id, input=Input, disabled=Disabled, validatio
style = "display: flex; position: relative; width: 100%; justify-content: center;",
body =
[ Input,
case Multiple of
true ->
#link{
class = [button, sgreen],
style = "min-width: 40px; text-align: center; height: fit-content; margin-left: 5px;",
onclick = nitro:jse("addSortableItemFrom('#" ++ ListId ++ "', '" ++ InputId ++ "')"),
body = <<"+">>};
false -> []
end,
case Disabled of
true -> [];
_ ->
#panel{
id = form:atom([InputId, "form"]),
class = ['dropdown-content'],
body = #panel{class = ['dropdown-item'], body = Form}
} end ]}
]}).
} end ]},
case Multiple of
true -> #sortable_list{id = ListId, values = Values, closeable = true, disabled = Disabled};
false -> []
end ]}).

0 comments on commit 615195a

Please sign in to comment.