Skip to content

Commit 8d4c407

Browse files
feat: replace tagsinput and combobox with new select2 integration
1 parent d692766 commit 8d4c407

File tree

18 files changed

+112
-3422
lines changed

18 files changed

+112
-3422
lines changed

.holo/branches/emergence-site/site-root/css/lib/_bootstrap-combobox.toml

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

.holo/branches/emergence-site/site-root/js/lib/_bootstrap-combobox.toml

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

.holo/sources/bootstrap-combobox.toml

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

html-templates/home.tpl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@
4949
<form class="checkin" action="/checkin" method="POST">
5050
<div class="form-group">
5151
<input type="hidden" name="MeetupID" value="{$currentMeetup.id}">
52-
<select name="ProjectID" class="project-picker form-control">
53-
<option value="">Current Project (if any)</option>
54-
{foreach item=Project from=Laddr\Project::getAll()}
55-
<option value="{$Project->ID}">{$Project->Title|escape}</option>
56-
{/foreach}
57-
</select>
52+
53+
{selectField inputName=ProjectID blankOption='Current Project (if any)' options=Laddr\Project::getAll() useKeyAsValue=no default=$Buzz->ProjectID}
5854
</div>
5955
<input type="submit" value="Check In" class="btn btn-success">
6056
</form>

html-templates/includes/site.js-bottom.tpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
"lib/jquery.js",
77
"lib/popper.js",
88
"lib/bootstrap.js",
9-
"lib/typeahead.bundle.js",
10-
"lib/bootstrap-combobox.js",
11-
"lib/bootstrap-tagsinput.js",
129
"lib/select2.js",
1310
"features/site-search.js",
1411
"features/site-search-renderers/*",

html-templates/profile/profileEdit.tpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
{field inputName="Location" label=_("Location") default=$User->Location}
6666
{textarea inputName="About" label=_("About Me") default=$User->About hint=markdown(_("Use [Markdown](http://daringfireball.net/projects/markdown) to give your text some style"))}
6767

68-
{load_templates subtemplates/tagsField.tpl}
69-
7068
{tagsField Record=$User prefix=topic label=_("Topics of interest") placeholder=_("Education, Mapping, Crime")}
7169
{tagsField Record=$User prefix=tech label=_("Technologies of interest") placeholder=_("PHP, Bootstrap, JavaScript")}
7270

html-templates/project-buzz/projectBuzzEdit.tpl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@
3030
<form method="POST" enctype="multipart/form-data">
3131
<div class="form-group">
3232
<label for="field-project" class="control-label">Project:</label>
33-
<select name="ProjectID" class="project-picker form-control" id="field-project" aria-required="true" required>
34-
<option value="">Select Project</option>
35-
{foreach item=Project from=Laddr\Project::getAll()}
36-
<option value="{$Project->ID}" {refill field=ProjectID default=$Buzz->ProjectID selected=$Project->ID}>{$Project->Title|escape}</option>
37-
{/foreach}
38-
</select>
33+
{selectField inputName=ProjectID blankOption='Select Project' options=Laddr\Project::getAll() useKeyAsValue=no default=$Buzz->ProjectID required=yes}
3934
</div>
4035
<div class="form-group">
4136
<label for="field-headline" class="control-label">Headline:</label>

html-templates/projects/projectEdit.tpl

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,11 @@
5555
<label for="field-chat-channel">{_ "Chat Channel/Hashtag"}:</label>
5656
<input name="ChatChannel" id="field-chat-channel" class="form-control" placeholder="train_schedule_analyzer" value="{refill field=ChatChannel default=$Project->ChatChannel}" pattern="[A-Za-z0-9_-]+" title="Hash tag containing only letters, numbers, dashes or underscores without leading #"/>
5757
</div>
58-
<div class="form-group">
59-
<label for="topicTagsInput">{_ 'Topic Tags'}:</label>
60-
<select id="topicTagsInput" class="form-control select2-tags" multiple="multiple" name="tags[topic]">
61-
{foreach item=Topic from=Tag::getTagsString($Project->Tags, topic)}
62-
<option value="{$Topic}" selected="selected">{$Topic}</option>
63-
{/foreach}
64-
<option value="Education">Education</option>
65-
<option value="Mapping">Mapping</option>
66-
<option value="Crime">Crime</option>
67-
</select>
68-
</div>
69-
<div class="form-group">
70-
<label for="techTagsInput">{_ 'Technology Tags'}:</label>
71-
<select id="techTagsInput" class="form-control select2-tags" multiple="multiple" name="tags[tech]">
72-
{foreach item=Topic from=Tag::getTagsString($Project->Tags, tech)}
73-
<option value="{$Topic}" selected="selected">{$Topic}</option>
74-
{/foreach}
75-
<option value="Python">Python</option>
76-
<option value="JavaScript">JavaScript</option>
77-
<option value="Bootstrap">Bootstrap</option>
78-
</select>
79-
</div>
80-
<div class="form-group">
81-
<label for="eventTagsInput">{_ 'Event Tags'}:</label>
82-
<select id="eventTagsInput" class="form-control select2-tags" multiple="multiple" name="tags[event]">
83-
{foreach item=Topic from=Tag::getTagsString($Project->Tags, event)}
84-
<option value="{$Topic}" selected="selected">{$Topic}</option>
85-
{/foreach}
86-
<option value="Education Hackathon 2014">Education Hackathon 2014</option>
87-
</select>
88-
</div>
58+
59+
{tagsField Record=$Project prefix=topic label=_("Topic tags") placeholder=_("Education, Mapping, Crime")}
60+
{tagsField Record=$Project prefix=tech label=_("Technology tags") placeholder=_("PHP, Bootstrap, JavaScript")}
61+
{tagsField Record=$Project prefix=event label=_("Connected events") placeholder=_("Education Hackathon 2014")}
62+
8963
<p id="project-stage"><b>{_ 'Stage'}:</b></p>
9064
<div aria-labelledby="project-stage">
9165
<div class="radio">

html-templates/subtemplates/forms.tpl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{if $unsetValue !== null}
4242
<input type="hidden" name="{$inputName|escape}" value="{$unsetValue|escape}">
4343
{/if}
44-
44+
4545
<label>
4646
<input type="checkbox"
4747
class="{$class}"
@@ -69,10 +69,59 @@
6969
{$attribs}
7070
>{refill field=$inputName default=$default}</textarea>
7171
{/capture}
72-
72+
7373
{labeledField html=$html type=textarea label=$label error=$error hint=$hint required=$required}
7474
</div>
7575
{/template}
7676

7777
{template loginField}{field inputName=_LOGIN[username] label=Username required=true attribs='autofocus autocapitalize="none" autocorrect="off"' hint='You can also log in with your email address.'}{/template}
7878
{template passwordField}{field inputName=_LOGIN[password] label=Password hint='<a href="/register/recover">Forgot?</a>' required=true refill=false type=password}{/template}
79+
80+
{template selectField inputName label='' options=null useKeyAsValue=yes default=null multiple=no error='' hint='' required=false attribs='' class=null fieldClass=null blankOption='Select' blankValue=''}
81+
<div class="form-group">
82+
{capture assign=html}
83+
<select
84+
class="form-control {$class}"
85+
name="{$inputName}"
86+
{if $required}required aria-required="true"{/if}
87+
{if $multiple}multiple{/if}
88+
{$attribs}
89+
>
90+
{if $blankOption && !$multiple}
91+
<option value="{$blankValue|escape}">{$blankOption|escape}</option>
92+
{/if}
93+
94+
{foreach key=value item=text from=$options}
95+
{$value = tif($useKeyAsValue, $value, tif(is_a($text, 'ActiveRecord'), $text->ID, $text))}
96+
{$text = tif(is_a($text, 'ActiveRecord'), $text->getTitle(), $text)}
97+
<option {refill field=$inputName default=$default selected=$value} value="{$value|escape}">{$text|escape}</option>
98+
{/foreach}
99+
</select>
100+
{/capture}
101+
102+
{labeledField html=$html type='select' label=$label error=$error hint=$hint required=$required class=$fieldClass}
103+
</div>
104+
{/template}
105+
106+
{template tagsField Record baseName=tags prefix=no label='' blankOption='Select' attribs='' placeholder='' error='' hint='' required=false}
107+
{$inputName = tif($prefix, cat($baseName, "[$prefix][]"), $baseName)}
108+
{capture assign=attribs}{strip}
109+
{$attribs}
110+
{if $prefix} data-tag-prefix="{$prefix|escape}"{/if}
111+
{if $placeholder} data-tag-placeholder="{$placeholder|escape}"{/if}
112+
{/strip}{/capture}
113+
114+
{selectField
115+
inputName=$inputName
116+
label=$label
117+
blankOption=$blankOption
118+
options=Tag::filterTagsByPrefix($Record->Tags, $prefix)
119+
default=true
120+
multiple=yes
121+
useKeyAsValue=no
122+
error=$error
123+
hint=$hint
124+
required=$required
125+
attribs=$attribs
126+
}
127+
{/template}

html-templates/subtemplates/tagsField.tpl

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

0 commit comments

Comments
 (0)