Skip to content

Commit 98ecfa6

Browse files
commit lingering roles edits from laddr-v2-dev instance
1 parent 26d1376 commit 98ecfa6

File tree

4 files changed

+139
-64
lines changed

4 files changed

+139
-64
lines changed

html-templates/projects/project.tpl

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,34 @@
4545
</div>
4646
</form>
4747

48+
<form id="add-application" class="modal fade form-horizontal" tabindex="-1" role="dialog" aria-labelledby="add-member-title" action="/projects/{$Project->Handle}/add-application" method="POST">
49+
<div class="modal-dialog">
50+
<div class="modal-content">
51+
<div class="modal-header">
52+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
53+
<h2 id="add-application-title" class="modal-title"></h2>
54+
</div>
55+
<div class="modal-body">
56+
<div class="form-group" style="display: none;">
57+
<label for="inputRoleId" class="col-sm-2 control-label">{_ "Role"}</label>
58+
<div class="col-sm-10">
59+
<input type="text" id="inputRoleId" class="form-control" name="role_id" required>
60+
</div>
61+
</div>
62+
<div class="form-group">
63+
<label for="inputApplication" class="col-sm-2 control-label">{_ "Application"}</label>
64+
<div class="col-sm-10">
65+
<textarea rows="4" cols="50" id="inputApplication" class="form-control" name="application" placeholder="{_ 'optional'}"></textarea>
66+
</div>
67+
</div>
68+
</div>
69+
<div class="modal-footer">
70+
<button class="btn btn-primary">{_ "Apply"}</button>
71+
</div>
72+
</div>
73+
</div>
74+
</form>
75+
4876
<div class="page-header">
4977
<div class="btn-toolbar pull-right">
5078
<div class="btn-group">
@@ -233,7 +261,7 @@
233261
<span class="glyphicon glyphicon-transfer"></span>
234262
</a>
235263
{/if}
236-
<a href="role" data-toggle="modal" data-role_id="{$Role->ID}" data-role_name="{$Role->Role}" data-role_description="{$Role->Description}" data-role_person="{$Person->Username}" title="Edit Role" style="margin-left: 4px">
264+
<a href="role" data-toggle="modal" data-role_id="{$Role->ID}" data-role_name="{$Role->Role}" data-role_description="{$Role->Description}" data-role_person="{$Person->Username}" title="Edit Role" style="margin-left: 4px">
237265
<span class="glyphicon glyphicon-edit"></span>
238266
</a>
239267
<a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" data-toggle="modal" title="Trash" style="margin-left: 4px">
@@ -267,11 +295,11 @@
267295
{$Role->Role}
268296
</td>
269297
<td style="text-align:right">
270-
<a href="role_application" data-toggle="modal" data-role="{$Role->ID}" data-role_title="{$Project->Title} -- {$Role->Role}" title="Apply" style="margin-left: 4px">
298+
<a href="role_application" data-toggle="modal" data-role="{$Role->ID}" data-role_name="{$Role->Role}" data-role_title="{$Project->Title} -- {$Role->Role}" title="Apply" style="margin-left: 4px">
271299
<span class="glyphicon glyphicon-ok"></span>
272300
</a>
273301
{if $.Session->hasAccountLevel('Staff')}
274-
<a href="role" data-toggle="modal" data-role_id="{$Role->ID}" data-role_name="{$Role->Role}" data-role_description="{$Role->Description}" data-role_person="{$Person->Username}" title="Edit Role" style="margin-left: 4px">
302+
<a href="role" data-toggle="modal" data-role_id="{$Role->ID}" data-role_name="{$Role->Role}" data-role_description="{$Role->Description}" data-role_person="{$Person->Username}" title="Edit Role" style="margin-left: 4px">
275303
<span class="glyphicon glyphicon-edit"></span>
276304
</a>
277305
<a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" data-toggle="modal" title="Trash" style="margin-left: 4px">
@@ -405,34 +433,6 @@
405433
</div>
406434
</form>
407435

408-
<form id="add-application" class="modal fade form-horizontal" tabindex="-1" role="dialog" aria-labelledby="add-member-title" action="/projects/{$Project->Handle}/add-application" method="POST">
409-
<div class="modal-dialog">
410-
<div class="modal-content">
411-
<div class="modal-header">
412-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
413-
<h2 id="add-application-title" class="modal-title"></h2>
414-
</div>
415-
<div class="modal-body">
416-
<div class="form-group" style="display: none;">
417-
<label for="inputRoleId" class="col-sm-2 control-label">{_ "Role"}</label>
418-
<div class="col-sm-10">
419-
<input type="text" id="inputRoleId" class="form-control" name="role_id" required>
420-
</div>
421-
</div>
422-
<div class="form-group">
423-
<label for="inputApplication" class="col-sm-2 control-label">{_ "Application"}</label>
424-
<div class="col-sm-10">
425-
<textarea rows="4" cols="50" id="inputApplication" class="form-control" name="application" placeholder="{_ 'optional'}"></textarea>
426-
</div>
427-
</div>
428-
</div>
429-
<div class="modal-footer">
430-
<button class="btn btn-primary">{_ "Apply"}</button>
431-
</div>
432-
</div>
433-
</div>
434-
</form>
435-
436436
<form id="add-member" class="modal fade form-horizontal" tabindex="-1" role="dialog" aria-labelledby="add-member-title" action="/projects/{$Project->Handle}/add-member" method="POST">
437437
<div class="modal-dialog">
438438
<div class="modal-content">
@@ -517,7 +517,7 @@
517517
<span class="glyphicon glyphicon-transfer"></span>
518518
</a>
519519
{/if}
520-
<a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" title="Trash" style="margin-left: 4px">
520+
<a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" title="Trash" style="margin-left: 4px">
521521
<span class="glyphicon glyphicon-trash"></span>
522522
</a>
523523
</td>

html-templates/projects/projects.tpl

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,83 @@
2424
{contentBlock "projects-browse-introduction"}
2525

2626
<div class="row">
27-
<div class="col-sm-4 col-md-3 tags-ct">
28-
<div class="btn-group btn-group-justified btn-group-xs margin-bottom" role="group">
29-
<a href="#projects-by-topic" class="active btn btn-default" role="button" data-group="byTopic">{_ "topics"}</a>
30-
<a href="#projects-by-tech" class="btn btn-default" role="button" data-group="byTech">{_ "tech"}</a>
31-
<a href="#projects-by-event" class="btn btn-default" role="button" data-group="byEvent">{_ "events"}</a>
32-
<a href="#projects-by-event" class="btn btn-default" role="button" data-group="byStage">{_ "stages"}</a>
33-
</div>
34-
35-
{template tagLink tagData rootUrl linkCls=""}
36-
<a class="{$linkCls}" href="{$rootUrl}?tag={$tagData.Handle}">{$tagData.Title}{if $tagData.itemsCount} <span class="badge pull-right">{$tagData.itemsCount|number_format}</span>{/if}</a>
37-
{/template}
27+
<div class="col-sm-4 col-md-3">
28+
29+
<form id="add-application" class="" tabindex="-1" role="dialog" aria-labelledby="add-member-title" action="/projects/{$Project->Handle}/add-application" method="POST">
30+
<div class="radio list-group">
31+
<label>
32+
<input type="checkbox" name="stage[]" value="Commenting" checked>
33+
<b>{_ Commenting}</b>: {Laddr\Project::getStageDescription(Commenting)}
34+
</label>
35+
</div>
36+
<div class="radio list-group">
37+
<label>
38+
<input type="checkbox" name="stage[]" value="Bootstrapping" checked>
39+
<b>{_ Bootstrapping}</b>: {Laddr\Project::getStageDescription(Bootstrapping)}
40+
</label>
41+
</div>
42+
<div class="radio list-group">
43+
<label>
44+
<input type="checkbox" name="stage[]" value="Prototyping" checked>
45+
<b>{_ Prototyping}</b>: {Laddr\Project::getStageDescription(Prototyping)}
46+
</label>
47+
</div>
48+
<div class="radio list-group">
49+
<label>
50+
<input type="checkbox" name="stage[]" value="Testing" checked>
51+
<b>{_ Testing}</b>: {Laddr\Project::getStageDescription(Testing)}
52+
</label>
53+
</div>
54+
<div class="radio list-group">
55+
<label>
56+
<input type="checkbox" name="stage[]" value="Maintaining" checked>
57+
<b>{_ Maintaining}</b>: {Laddr\Project::getStageDescription(Maintaining)}
58+
</label>
59+
</div>
60+
<div class="radio list-group">
61+
<label>
62+
<input type="checkbox" name="stage[]" value="Drifting" checked>
63+
<b>{_ Drifting}</b>: {Laddr\Project::getStageDescription(Drifting)}
64+
</label>
65+
</div>
66+
<div class="radio list-group">
67+
<label>
68+
<input type="checkbox" name="stage[]" value="Hibernating">
69+
<b>{_ Hibernating}</b>: {Laddr\Project::getStageDescription(Hibernating)}
70+
</label>
71+
</div>
72+
<div class="">
73+
<button class="btn btn-primary">{_ "Apply"}</button>
74+
</div>
75+
</form>
3876

39-
<div class="tags list-group byTopic">
40-
{foreach item=tag from=$projectsTags.byTopic}
41-
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
42-
{/foreach}
43-
</div>
44-
<div class="tags list-group byTech" style="display: none">
45-
{foreach item=tag from=$projectsTags.byTech}
46-
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
47-
{/foreach}
48-
</div>
49-
<div class="tags list-group byEvent" style="display: none">
50-
{foreach item=tag from=$projectsTags.byEvent}
51-
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
52-
{/foreach}
53-
</div>
54-
<div class="tags list-group byStage" style="display: none">
55-
{foreach item=stage from=$projectsStages}
56-
<a class="list-group-item" href="/projects?stage={$stage.Stage}">{$stage.Stage} <span class="badge pull-right">{$stage.itemsCount|number_format}</span></a>
57-
{/foreach}
77+
78+
<div class="tags-ct">
79+
<div class="btn-group btn-group-justified btn-group-xs margin-bottom" role="group">
80+
<a href="#projects-by-topic" class="active btn btn-default" role="button" data-group="byTopic">{_ "topics"}</a>
81+
<a href="#projects-by-tech" class="btn btn-default" role="button" data-group="byTech">{_ "tech"}</a>
82+
<a href="#projects-by-event" class="btn btn-default" role="button" data-group="byEvent">{_ "events"}</a>
83+
</div>
84+
85+
{template tagLink tagData rootUrl linkCls=""}
86+
<a class="{$linkCls}" href="{$rootUrl}?tag={$tagData.Handle}">{$tagData.Title}{if $tagData.itemsCount} <span class="badge pull-right">{$tagData.itemsCount|number_format}</span>{/if}</a>
87+
{/template}
88+
89+
<div class="tags list-group byTopic">
90+
{foreach item=tag from=$projectsTags.byTopic}
91+
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
92+
{/foreach}
93+
</div>
94+
<div class="tags list-group byTech" style="display: none">
95+
{foreach item=tag from=$projectsTags.byTech}
96+
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
97+
{/foreach}
98+
</div>
99+
<div class="tags list-group byEvent" style="display: none">
100+
{foreach item=tag from=$projectsTags.byEvent}
101+
{tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"}
102+
{/foreach}
103+
</div>
58104
</div>
59105
</div>
60106
<div class="col-sm-8 col-md-9">

php-classes/Laddr/ProjectsRequestHandler.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public static function handleBrowseRequest($options = [], $conditions = [], $res
5656

5757
// apply stage filter
5858
if (!empty($_REQUEST['stage'])) {
59-
$conditions['Stage'] = $_REQUEST['stage'];
59+
$conditions['Stage'] = [
60+
'operator' => 'in',
61+
'values' => is_array($_REQUEST['stage']) ? $_REQUEST['stage'] : explode(',', $_REQUEST['stage'])
62+
];
6063
}
6164

6265
$responseData['projectsTotal'] = Project::getCount();
@@ -155,6 +158,31 @@ public static function handleModifyRoleRequest(Project $Project)
155158
public static function handleAddRoleApplicationRequest(Project $Project){
156159
$GLOBALS['Session']->requireAuthentication();
157160

161+
$Person = User::getByUsername($_POST['username']);
162+
163+
$recordData = [
164+
'ProjectID' => $Project->ID,
165+
'PersonID' => (!$Person)?null:$Person->ID,
166+
'Status' => 'Pending'
167+
];
168+
169+
$RoleApplication = RoleApplication::create($recordData);
170+
171+
if (!empty($_POST['role'])) {
172+
$RoleApplication->RoleID = $_POST['role'];
173+
}
174+
175+
if (!empty($_POST['application'])) {
176+
$RoleApplication->Application = $_POST['application'];
177+
}
178+
179+
$RoleApplication->save();
180+
181+
return static::respond('roleAdded', [
182+
'data' => $RoleApplication,
183+
'Project' => $Project,
184+
'Member' => $Person
185+
]);
158186
}
159187

160188
public static function handleRemoveRoleRequest(Project $Project)
@@ -174,7 +202,7 @@ public static function handleRemoveRoleRequest(Project $Project)
174202
return static::respond('confirm', [
175203
'question' => sprintf(
176204
_('Are you sure you want to remove %s from %s?'),
177-
htmlspecialchars($Role->Role),
205+
htmlspecialchars($ProjectRole->Role),
178206
htmlspecialchars($Project->Title)
179207
)
180208
]);

site-root/js/pages/project.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
$( "#open_role_table" ).on( "click", "a[title^='Apply']", function( event ) {
3838
$('#add-application').modal({show: 'true'});
39+
$("#add-application-title").text($( this ).attr( "data-role_name"));
3940
$("#inputRoleId").val($( this ).attr( "data-role_id"));
4041
});
4142

0 commit comments

Comments
 (0)