diff --git a/html-templates/projects/project.tpl b/html-templates/projects/project.tpl index b312f601..dbe0971d 100644 --- a/html-templates/projects/project.tpl +++ b/html-templates/projects/project.tpl @@ -45,6 +45,34 @@ </div> </form> + <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"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h2 id="add-application-title" class="modal-title"></h2> + </div> + <div class="modal-body"> + <div class="form-group" style="display: none;"> + <label for="inputRoleId" class="col-sm-2 control-label">{_ "Role"}</label> + <div class="col-sm-10"> + <input type="text" id="inputRoleId" class="form-control" name="role_id" required> + </div> + </div> + <div class="form-group"> + <label for="inputApplication" class="col-sm-2 control-label">{_ "Application"}</label> + <div class="col-sm-10"> + <textarea rows="4" cols="50" id="inputApplication" class="form-control" name="application" placeholder="{_ 'optional'}"></textarea> + </div> + </div> + </div> + <div class="modal-footer"> + <button class="btn btn-primary">{_ "Apply"}</button> + </div> + </div> + </div> + </form> + <div class="page-header"> <div class="btn-toolbar pull-right"> <div class="btn-group"> @@ -233,7 +261,7 @@ <span class="glyphicon glyphicon-transfer"></span> </a> {/if} - <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"> + <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"> <span class="glyphicon glyphicon-edit"></span> </a> <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 @@ {$Role->Role} </td> <td style="text-align:right"> - <a href="role_application" data-toggle="modal" data-role="{$Role->ID}" data-role_title="{$Project->Title} -- {$Role->Role}" title="Apply" style="margin-left: 4px"> + <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"> <span class="glyphicon glyphicon-ok"></span> </a> {if $.Session->hasAccountLevel('Staff')} - <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"> + <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"> <span class="glyphicon glyphicon-edit"></span> </a> <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 @@ </div> </form> - <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"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> - <h2 id="add-application-title" class="modal-title"></h2> - </div> - <div class="modal-body"> - <div class="form-group" style="display: none;"> - <label for="inputRoleId" class="col-sm-2 control-label">{_ "Role"}</label> - <div class="col-sm-10"> - <input type="text" id="inputRoleId" class="form-control" name="role_id" required> - </div> - </div> - <div class="form-group"> - <label for="inputApplication" class="col-sm-2 control-label">{_ "Application"}</label> - <div class="col-sm-10"> - <textarea rows="4" cols="50" id="inputApplication" class="form-control" name="application" placeholder="{_ 'optional'}"></textarea> - </div> - </div> - </div> - <div class="modal-footer"> - <button class="btn btn-primary">{_ "Apply"}</button> - </div> - </div> - </div> - </form> - <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"> <div class="modal-dialog"> <div class="modal-content"> @@ -517,7 +517,7 @@ <span class="glyphicon glyphicon-transfer"></span> </a> {/if} - <a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" title="Trash" style="margin-left: 4px"> + <a href="/projects/{$Project->Handle}/remove-role?role_id={$Role->ID|escape:url}" title="Trash" style="margin-left: 4px"> <span class="glyphicon glyphicon-trash"></span> </a> </td> diff --git a/html-templates/projects/projects.tpl b/html-templates/projects/projects.tpl index 37f30536..b8cbaf8a 100644 --- a/html-templates/projects/projects.tpl +++ b/html-templates/projects/projects.tpl @@ -24,37 +24,83 @@ {contentBlock "projects-browse-introduction"} <div class="row"> - <div class="col-sm-4 col-md-3 tags-ct"> - <div class="btn-group btn-group-justified btn-group-xs margin-bottom" role="group"> - <a href="#projects-by-topic" class="active btn btn-default" role="button" data-group="byTopic">{_ "topics"}</a> - <a href="#projects-by-tech" class="btn btn-default" role="button" data-group="byTech">{_ "tech"}</a> - <a href="#projects-by-event" class="btn btn-default" role="button" data-group="byEvent">{_ "events"}</a> - <a href="#projects-by-event" class="btn btn-default" role="button" data-group="byStage">{_ "stages"}</a> - </div> - - {template tagLink tagData rootUrl linkCls=""} - <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> - {/template} + <div class="col-sm-4 col-md-3"> + + <form id="add-application" class="" tabindex="-1" role="dialog" aria-labelledby="add-member-title" action="/projects/{$Project->Handle}/add-application" method="POST"> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Commenting" checked> + <b>{_ Commenting}</b>: {Laddr\Project::getStageDescription(Commenting)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Bootstrapping" checked> + <b>{_ Bootstrapping}</b>: {Laddr\Project::getStageDescription(Bootstrapping)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Prototyping" checked> + <b>{_ Prototyping}</b>: {Laddr\Project::getStageDescription(Prototyping)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Testing" checked> + <b>{_ Testing}</b>: {Laddr\Project::getStageDescription(Testing)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Maintaining" checked> + <b>{_ Maintaining}</b>: {Laddr\Project::getStageDescription(Maintaining)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Drifting" checked> + <b>{_ Drifting}</b>: {Laddr\Project::getStageDescription(Drifting)} + </label> + </div> + <div class="radio list-group"> + <label> + <input type="checkbox" name="stage[]" value="Hibernating"> + <b>{_ Hibernating}</b>: {Laddr\Project::getStageDescription(Hibernating)} + </label> + </div> + <div class=""> + <button class="btn btn-primary">{_ "Apply"}</button> + </div> + </form> - <div class="tags list-group byTopic"> - {foreach item=tag from=$projectsTags.byTopic} - {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} - {/foreach} - </div> - <div class="tags list-group byTech" style="display: none"> - {foreach item=tag from=$projectsTags.byTech} - {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} - {/foreach} - </div> - <div class="tags list-group byEvent" style="display: none"> - {foreach item=tag from=$projectsTags.byEvent} - {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} - {/foreach} - </div> - <div class="tags list-group byStage" style="display: none"> - {foreach item=stage from=$projectsStages} - <a class="list-group-item" href="/projects?stage={$stage.Stage}">{$stage.Stage} <span class="badge pull-right">{$stage.itemsCount|number_format}</span></a> - {/foreach} + + <div class="tags-ct"> + <div class="btn-group btn-group-justified btn-group-xs margin-bottom" role="group"> + <a href="#projects-by-topic" class="active btn btn-default" role="button" data-group="byTopic">{_ "topics"}</a> + <a href="#projects-by-tech" class="btn btn-default" role="button" data-group="byTech">{_ "tech"}</a> + <a href="#projects-by-event" class="btn btn-default" role="button" data-group="byEvent">{_ "events"}</a> + </div> + + {template tagLink tagData rootUrl linkCls=""} + <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> + {/template} + + <div class="tags list-group byTopic"> + {foreach item=tag from=$projectsTags.byTopic} + {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} + {/foreach} + </div> + <div class="tags list-group byTech" style="display: none"> + {foreach item=tag from=$projectsTags.byTech} + {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} + {/foreach} + </div> + <div class="tags list-group byEvent" style="display: none"> + {foreach item=tag from=$projectsTags.byEvent} + {tagLink tagData=$tag rootUrl="/projects" linkCls="list-group-item"} + {/foreach} + </div> </div> </div> <div class="col-sm-8 col-md-9"> diff --git a/php-classes/Laddr/ProjectsRequestHandler.php b/php-classes/Laddr/ProjectsRequestHandler.php index e398f457..67365f1a 100644 --- a/php-classes/Laddr/ProjectsRequestHandler.php +++ b/php-classes/Laddr/ProjectsRequestHandler.php @@ -56,7 +56,10 @@ public static function handleBrowseRequest($options = [], $conditions = [], $res // apply stage filter if (!empty($_REQUEST['stage'])) { - $conditions['Stage'] = $_REQUEST['stage']; + $conditions['Stage'] = [ + 'operator' => 'in', + 'values' => is_array($_REQUEST['stage']) ? $_REQUEST['stage'] : explode(',', $_REQUEST['stage']) + ]; } $responseData['projectsTotal'] = Project::getCount(); @@ -155,6 +158,31 @@ public static function handleModifyRoleRequest(Project $Project) public static function handleAddRoleApplicationRequest(Project $Project){ $GLOBALS['Session']->requireAuthentication(); + $Person = User::getByUsername($_POST['username']); + + $recordData = [ + 'ProjectID' => $Project->ID, + 'PersonID' => (!$Person)?null:$Person->ID, + 'Status' => 'Pending' + ]; + + $RoleApplication = RoleApplication::create($recordData); + + if (!empty($_POST['role'])) { + $RoleApplication->RoleID = $_POST['role']; + } + + if (!empty($_POST['application'])) { + $RoleApplication->Application = $_POST['application']; + } + + $RoleApplication->save(); + + return static::respond('roleAdded', [ + 'data' => $RoleApplication, + 'Project' => $Project, + 'Member' => $Person + ]); } public static function handleRemoveRoleRequest(Project $Project) @@ -174,7 +202,7 @@ public static function handleRemoveRoleRequest(Project $Project) return static::respond('confirm', [ 'question' => sprintf( _('Are you sure you want to remove %s from %s?'), - htmlspecialchars($Role->Role), + htmlspecialchars($ProjectRole->Role), htmlspecialchars($Project->Title) ) ]); diff --git a/site-root/js/pages/project.js b/site-root/js/pages/project.js index e5c1ff4c..141fa79b 100644 --- a/site-root/js/pages/project.js +++ b/site-root/js/pages/project.js @@ -36,6 +36,7 @@ $( "#open_role_table" ).on( "click", "a[title^='Apply']", function( event ) { $('#add-application').modal({show: 'true'}); + $("#add-application-title").text($( this ).attr( "data-role_name")); $("#inputRoleId").val($( this ).attr( "data-role_id")); });