Skip to content

Commit

Permalink
commit lingering roles edits from laddr-v2-dev instance
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Feb 6, 2019
1 parent 5a77a8a commit 7f97e29
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 64 deletions.
64 changes: 32 additions & 32 deletions html-templates/projects/project.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
106 changes: 76 additions & 30 deletions html-templates/projects/projects.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
32 changes: 30 additions & 2 deletions php-classes/Laddr/ProjectsRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand All @@ -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)
)
]);
Expand Down
1 change: 1 addition & 0 deletions site-root/js/pages/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});

Expand Down

0 comments on commit 7f97e29

Please sign in to comment.