Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Roles #198

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.emergence
.data
261 changes: 257 additions & 4 deletions html-templates/projects/project.tpl

Large diffs are not rendered by default.

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
12 changes: 12 additions & 0 deletions html-templates/projects/roleAdded.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{extends designs/site.tpl}

{block title}{_ "Roles"} &mdash; {$dwoo.parent}{/block}

{block content}
{capture assign=project}{projectLink $Project}{/capture}

<div class="page-header">
<h1>Role Added</h1>
</div>
<p class="lead">{sprintf(_("%s has been added to %s"), $data->Role, $project)}</p>
{/block}
12 changes: 12 additions & 0 deletions html-templates/projects/roleApplicationAdded.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{extends designs/site.tpl}

{block title}{_ "Roles"} &mdash; {$dwoo.parent}{/block}

{block content}
{capture assign=project}{projectLink $Project}{/capture}

<div class="page-header">
<h1>Application Added</h1>
</div>
<p class="lead">{sprintf(_(Your application for "%s has been added to %s"), $data->Role, $project)}</p>
{/block}
12 changes: 12 additions & 0 deletions html-templates/projects/roleModified.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{extends designs/site.tpl}

{block title}{_ "Roles"} &mdash; {$dwoo.parent}{/block}

{block content}
{capture assign=project}{projectLink $Project}{/capture}

<div class="page-header">
<h1>Role Modified</h1>
</div>
<p class="lead">{sprintf(_("%s has been modified for %s"), $data->Role, $project)}</p>
{/block}
14 changes: 14 additions & 0 deletions html-templates/projects/roleRemoved.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{extends designs/site.tpl}

{block title}Roles &mdash; {$dwoo.parent}{/block}

{block content}
<div class="row">
<div class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="page-header">
<h1>Role Removed</h1>
</div>
<p>{if $data && $data->Role}({$data->Role|escape}){/if} has been removed from {projectLink $Project}</p>
</div>
</div>
{/block}
26 changes: 24 additions & 2 deletions php-classes/Laddr/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ class Project extends \VersionedRecord
'linkForeign' => 'MemberID',
'indexField' => 'ID'
],
'Roles' => [
'type' => 'one-many',
'class' => ProjectRole::class,
'foreign' => 'ProjectID'
],
'OpenRoles' => [
'type' => 'one-many',
'class' => ProjectRole::class,
'foreign' => 'ProjectID',
'conditions' => [
'PersonID IS NULL'
]
],
'FilledRoles' => [
'type' => 'one-many',
'class' => ProjectRole::class,
'foreign' => 'ProjectID',
'conditions' => [
'PersonID IS NOT NULL'
]
],
'Memberships' => [
'type' => 'one-many',
'class' => ProjectMember::class,
Expand Down Expand Up @@ -143,6 +164,7 @@ class Project extends \VersionedRecord
public static $dynamicFields = [
'Maintainer',
'Members',
'Roles',
'Memberships',
'Tags',
'TopicTags',
Expand Down Expand Up @@ -193,9 +215,9 @@ public function save($deep = true)
parent::save($deep);

if (!$this->Members) {
ProjectMember::create([
ProjectRole::create([
'ProjectID' => $this->ID,
'MemberID' => $this->Maintainer->ID,
'PersonID' => $this->Maintainer->ID,
'Role' => 'Founder' // _("Founder") -- placeholder to make this string translatable, actual translation is done during rendering though
], true);
}
Expand Down
46 changes: 46 additions & 0 deletions php-classes/Laddr/ProjectRole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Laddr;

use Emergence\People\Person;


class ProjectRole extends \ActiveRecord
{
// ActiveRecord configuration
public static $tableName = 'project_roles'; // the name of this model's table

// controllers will use these values to figure out what templates to use
public static $singularNoun = 'project role'; // a singular noun for this model's object
public static $pluralNoun = 'project roles'; // a plural noun for this model's object

// gets combined with all the extended layers
public static $fields = [
'ProjectID' => 'uint',
'PersonID' => [
'type' =>'uint',
'default'=>null
],
'Role' => 'string',
'Description' => [
'type' =>'string',
'default'=>null
]
];

public static $relationships = [
'Project' => [
'type' => 'one-one',
'class' => Project::class
],
'Person' => [
'type' => 'one-one',
'class' => Person::class
]
];

public static $dynamicFields = [
'Project',
'Person'
];
}
Loading