Page MenuHomePhorge

No OneTemporary

diff --git a/resources/sql/patches/086.formeraffil.sql b/resources/sql/patches/086.formeraffil.sql
new file mode 100644
index 0000000000..6b73157e24
--- /dev/null
+++ b/resources/sql/patches/086.formeraffil.sql
@@ -0,0 +1 @@
+ALTER TABLE phabricator_project.project_affiliation DROP status;
\ No newline at end of file
diff --git a/src/applications/project/controller/editaffiliation/PhabricatorProjectAffiliationEditController.php b/src/applications/project/controller/editaffiliation/PhabricatorProjectAffiliationEditController.php
index 9c53b63e35..59aa068c11 100644
--- a/src/applications/project/controller/editaffiliation/PhabricatorProjectAffiliationEditController.php
+++ b/src/applications/project/controller/editaffiliation/PhabricatorProjectAffiliationEditController.php
@@ -1,107 +1,95 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectAffiliationEditController
extends PhabricatorProjectController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
$affiliation = id(new PhabricatorProjectAffiliation())->loadOneWhere(
'projectPHID = %s AND userPHID = %s',
$project->getPHID(),
$user->getPHID());
if (!$affiliation) {
$affiliation = new PhabricatorProjectAffiliation();
$affiliation->setUserPHID($user->getPHID());
$affiliation->setProjectPHID($project->getPHID());
}
if ($request->isFormPost()) {
$affiliation->setRole($request->getStr('role'));
- $affiliation->setStatus($request->getStr('status'));
if (!strlen($affiliation->getRole())) {
if ($affiliation->getID()) {
if ($affiliation->getIsOwner()) {
$affiliation->setRole('Owner');
$affiliation->save();
} else {
$affiliation->delete();
}
}
} else {
$affiliation->save();
}
return id(new AphrontRedirectResponse())
->setURI('/project/view/'.$project->getID().'/');
}
- $status_options = array(
- '' => 'Current',
- 'former' => 'Former',
- );
-
$form = new AphrontFormView();
$form
->setUser($user)
->setAction('/project/affiliation/'.$project->getID().'/')
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Role')
->setName('role')
->setValue($affiliation->getRole()))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel('Status')
- ->setName('status')
- ->setOptions($status_options)
- ->setValue($affiliation->getStatus()))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/project/view/'.$project->getID().'/')
->setValue('Save'));
$panel = new AphrontPanelView();
$panel->setHeader('Edit Project Affiliation');
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->appendChild($form);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Edit Project Affiliation',
));
}
}
diff --git a/src/applications/project/controller/editaffiliation/__init__.php b/src/applications/project/controller/editaffiliation/__init__.php
index 8851946da8..a7f2f16f56 100644
--- a/src/applications/project/controller/editaffiliation/__init__.php
+++ b/src/applications/project/controller/editaffiliation/__init__.php
@@ -1,23 +1,22 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/project/controller/base');
phutil_require_module('phabricator', 'applications/project/storage/affiliation');
phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'view/form/base');
-phutil_require_module('phabricator', 'view/form/control/select');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorProjectAffiliationEditController.php');
diff --git a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
index 26d58687fe..7f70750460 100644
--- a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php
@@ -1,297 +1,291 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectProfileController
extends PhabricatorProjectController {
private $id;
private $page;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
$this->page = idx($data, 'page');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$uri = $request->getRequestURI();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
$profile = $project->loadProfile();
if (!$profile) {
$profile = new PhabricatorProjectProfile();
}
$src_phid = $profile->getProfileImagePHID();
if (!$src_phid) {
$src_phid = $user->getProfileImagePHID();
}
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
$pages = array(
/*
'<h2>Active Documents</h2>',
'tasks' => 'Maniphest Tasks',
'revisions' => 'Differential Revisions',
'<hr />',
'<h2>Workflow</h2>',
'goals' => 'Goals',
'statistics' => 'Statistics',
'<hr />', */
'<h2>Information</h2>',
'edit' => 'Edit Project',
'affiliation' => 'Edit Affiliation',
);
if (empty($pages[$this->page])) {
$this->page = 'action';
}
switch ($this->page) {
default:
$content = $this->renderBasicInformation($project, $profile);
break;
}
$profile = new PhabricatorProfileView();
$profile->setProfilePicture($picture);
$profile->setProfileNames($project->getName());
foreach ($pages as $page => $name) {
if (is_integer($page)) {
$profile->addProfileItem(
phutil_render_tag(
'span',
array(),
$name));
} else {
$uri->setPath('/project/'.$page.'/'.$project->getID().'/');
$profile->addProfileItem(
phutil_render_tag(
'a',
array(
'href' => $uri,
'class' => ($this->page == $page)
? 'phabricator-profile-item-selected'
: null,
),
phutil_escape_html($name)));
}
}
$profile->appendChild($content);
return $this->buildStandardPageResponse(
$profile,
array(
'title' => $project->getName(),
));
}
//----------------------------------------------------------------------------
// Helper functions
private function renderBasicInformation($project, $profile) {
$blurb = nonempty(
$profile->getBlurb(),
'//Nothing is known about this elusive project.//');
$engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$blurb = $engine->markupText($blurb);
$affiliations = $project->loadAffiliations();
$phids = array_merge(
array($project->getAuthorPHID()),
$project->getSubprojectPHIDs(),
mpull($affiliations, 'getUserPHID')
);
$phids = array_unique($phids);
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$affiliated = array();
foreach ($affiliations as $affiliation) {
$user = $handles[$affiliation->getUserPHID()]->renderLink();
$role = phutil_escape_html($affiliation->getRole());
-
- $status = null;
- if ($affiliation->getStatus() == 'former') {
- $role = '<em>Former '.$role.'</em>';
- }
-
- $affiliated[] = '<li>'.$user.' &mdash; '.$role.$status.'</li>';
+ $affiliated[] = '<li>'.$user.' &mdash; '.$role.'</li>';
}
if ($affiliated) {
$affiliated = '<ul>'.implode("\n", $affiliated).'</ul>';
} else {
$affiliated = '<p><em>No one is affiliated with this project.</em></p>';
}
if ($project->getSubprojectPHIDs()) {
$table = $this->renderSubprojectTable(
$handles,
$project->getSubprojectPHIDs());
$subproject_list = $table->render();
} else {
$subproject_list =
'<p><em>There are no projects attached for such specie.</em></p>';
}
$viewer = $this->getRequest()->getUser();
$timestamp = phabricator_datetime($project->getDateCreated(), $viewer);
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());
$content =
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Basic Information</h1>
<div class="phabricator-profile-info-pane">
<table class="phabricator-profile-info-table">
<tr>
<th>Creator</th>
<td>'.$handles[$project->getAuthorPHID()]->renderLink().'</td>
</tr>
<tr>
<th>Status</th>
<td><strong>'.phutil_escape_html($status).'</strong></td>
</tr>
<tr>
<th>Created</th>
<td>'.$timestamp.'</td>
</tr>
<tr>
<th>PHID</th>
<td>'.phutil_escape_html($project->getPHID()).'</td>
</tr>
<tr>
<th>Blurb</th>
<td>'.$blurb.'</td>
</tr>
</table>
</div>
</div>';
$content .=
'<div class="phabricator-profile-info-group">'.
'<h1 class="phabricator-profile-info-header">Resources</h1>'.
'<div class="phabricator-profile-info-pane">'.
$affiliated.
'</div>'.
'</div>';
$content .= '<div class="phabricator-profile-info-group">'.
'<h1 class="phabricator-profile-info-header">Subprojects</h1>'.
'<div class="phabricator-profile-info-pane">'.
$subproject_list.
'</div>'.
'</div>';
$query = id(new ManiphestTaskQuery())
->withProjects(array($project->getPHID()))
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->setLimit(10)
->setCalculateRows(true);
$tasks = $query->execute();
$count = $query->getRowCount();
$phids = mpull($tasks, 'getOwnerPHID');
$phids = array_filter($phids);
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$task_views = array();
foreach ($tasks as $task) {
$view = id(new ManiphestTaskSummaryView())
->setTask($task)
->setHandles($handles)
->setUser($this->getRequest()->getUser());
$task_views[] = $view->render();
}
if (empty($tasks)) {
$task_views = '<em>No open tasks.</em>';
} else {
$task_views = implode('', $task_views);
}
$open = number_format($count);
$more_link = phutil_render_tag(
'a',
array(
'href' => '/maniphest/view/all/?projects='.$project->getPHID(),
),
"View All Open Tasks \xC2\xBB");
$content .=
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">'.
"Open Tasks ({$open})".
'</h1>'.
'<div class="phabricator-profile-info-pane">'.
$task_views.
'<div class="phabricator-profile-info-pane-more-link">'.
$more_link.
'</div>'.
'</div>
</div>';
return $content;
}
private function renderSubprojectTable(
PhabricatorObjectHandleData $handles,
$subprojects_phids) {
$rows = array();
foreach ($subprojects_phids as $subproject_phid) {
$phid = $handles[$subproject_phid]->getPHID();
$rows[] = array(
phutil_escape_html($handles[$phid]->getFullName()),
phutil_render_tag(
'a',
array(
'class' => 'small grey button',
'href' => $handles[$phid]->getURI(),
),
'View Project Profile'),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Name',
'',
));
$table->setColumnClasses(
array(
'pri',
'action right',
));
return $table;
}
}
diff --git a/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php b/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php
index db0514a5fb..07f5c058a5 100644
--- a/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php
+++ b/src/applications/project/controller/profileedit/PhabricatorProjectProfileEditController.php
@@ -1,293 +1,290 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectProfileEditController
extends PhabricatorProjectController {
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
$profile = $project->loadProfile();
if (empty($profile)) {
$profile = new PhabricatorProjectProfile();
}
if ($project->getSubprojectPHIDs()) {
$phids = $project->getSubprojectPHIDs();
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$subprojects = mpull($handles, 'getFullName', 'getPHID');
} else {
$subprojects = array();
}
$options = PhabricatorProjectStatus::getStatusMap();
$affiliations = $project->loadAffiliations();
$affiliations = mpull($affiliations, null, 'getUserPHID');
$e_name = true;
$errors = array();
$state = null;
if ($request->isFormPost()) {
$project->setName($request->getStr('name'));
$project->setStatus($request->getStr('status'));
$project->setSubprojectPHIDs($request->getArr('set_subprojects'));
$profile->setBlurb($request->getStr('blurb'));
if (!strlen($project->getName())) {
$e_name = 'Required';
$errors[] = 'Project name is required.';
} else {
$e_name = null;
}
if (!empty($_FILES['image'])) {
$err = idx($_FILES['image'], 'error');
if ($err != UPLOAD_ERR_NO_FILE) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['image'],
array(
'authorPHID' => $user->getPHID(),
));
$okay = $file->isTransformableImage();
if ($okay) {
$xformer = new PhabricatorImageTransformer();
$xformed = $xformer->executeProfileTransform(
$file,
$width = 280,
$min_height = 140,
$max_height = 420);
$profile->setProfileImagePHID($xformed->getPHID());
} else {
$errors[] =
'Only valid image files (jpg, jpeg, png or gif) '.
'will be accepted.';
}
}
}
$resources = $request->getStr('resources');
$resources = json_decode($resources, true);
if (!is_array($resources)) {
throw new Exception(
"Project resource information was not correctly encoded in the ".
"request.");
}
$state = array();
foreach ($resources as $resource) {
$user_phid = $resource['phid'];
if (!$user_phid) {
continue;
}
if (isset($state[$user_phid])) {
// TODO: We should deal with this better -- the user has entered
// the same resource more than once.
}
$state[$user_phid] = array(
'phid' => $user_phid,
- 'status' => $resource['status'],
'role' => $resource['role'],
'owner' => $resource['owner'],
);
}
$all_phids = array_merge(array_keys($state), array_keys($affiliations));
$all_phids = array_unique($all_phids);
$delete_affiliations = array();
$save_affiliations = array();
foreach ($all_phids as $phid) {
$old = idx($affiliations, $phid);
$new = idx($state, $phid);
if ($old && !$new) {
$delete_affiliations[] = $affiliations[$phid];
continue;
}
if (!$old) {
$affil = new PhabricatorProjectAffiliation();
$affil->setUserPHID($phid);
} else {
$affil = $old;
}
$affil->setRole((string)$new['role']);
- $affil->setStatus((string)$new['status']);
$affil->setIsOwner((int)$new['owner']);
$save_affiliations[] = $affil;
}
if (!$errors) {
$project->save();
$profile->setProjectPHID($project->getPHID());
$profile->save();
foreach ($delete_affiliations as $affil) {
$affil->delete();
}
foreach ($save_affiliations as $save) {
$save->setProjectPHID($project->getPHID());
$save->save();
}
return id(new AphrontRedirectResponse())
->setURI('/project/view/'.$project->getID().'/');
} else {
$phids = array_keys($state);
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
foreach ($state as $phid => $info) {
$state[$phid]['name'] = $handles[$phid]->getFullName();
}
}
} else {
$phids = mpull($affiliations, 'getUserPHID');
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$state = array();
foreach ($affiliations as $affil) {
$user_phid = $affil->getUserPHID();
$state[] = array(
'phid' => $user_phid,
'name' => $handles[$user_phid]->getFullName(),
- 'status' => $affil->getStatus(),
'role' => $affil->getRole(),
'owner' => $affil->getIsOwner(),
);
}
}
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle('Form Errors');
$error_view->setErrors($errors);
}
$header_name = 'Edit Project';
$title = 'Edit Project';
$action = '/project/edit/'.$project->getID().'/';
require_celerity_resource('project-edit-css');
$form = new AphrontFormView();
$form
->setID('project-edit-form')
->setUser($user)
->setAction($action)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Name')
->setName('name')
->setValue($project->getName())
->setError($e_name))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel('Project Status')
->setName('status')
->setOptions($options)
->setValue($project->getStatus()))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Blurb')
->setName('blurb')
->setValue($profile->getBlurb()))
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/projects/')
->setLabel('Subprojects')
->setName('set_subprojects')
->setValue($subprojects))
->appendChild(
id(new AphrontFormFileControl())
->setLabel('Change Image')
->setName('image'))
->appendChild(
'<h1>Resources</h1>'.
'<input type="hidden" name="resources" id="resources" />'.
'<div class="aphront-form-inset">'.
'<div style="float: right;">'.
javelin_render_tag(
'a',
array(
'href' => '#',
'class' => 'button green',
'sigil' => 'add-resource',
'mustcapture' => true,
),
'Add New Resource').
'</div>'.
'<p></p>'.
'<div style="clear: both;"></div>'.
javelin_render_tag(
'table',
array(
'sigil' => 'resources',
'class' => 'project-resource-table',
),
'').
'</div>')
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/project/view/'.$project->getID().'/')
->setValue('Save'));
$template = new AphrontTokenizerTemplateView();
$template = $template->render();
Javelin::initBehavior(
'projects-resource-editor',
array(
'root' => 'project-edit-form',
'tokenizerTemplate' => $template,
'tokenizerSource' => '/typeahead/common/users/',
'input' => 'resources',
'state' => array_values($state),
));
$panel = new AphrontPanelView();
$panel->setHeader($header_name);
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
$panel->appendChild($form);
return $this->buildStandardPageResponse(
array(
$error_view,
$panel,
),
array(
'title' => $title,
));
}
}
diff --git a/src/applications/project/query/project/PhabricatorProjectQuery.php b/src/applications/project/query/project/PhabricatorProjectQuery.php
index cd49a2426e..2f25ccf7da 100644
--- a/src/applications/project/query/project/PhabricatorProjectQuery.php
+++ b/src/applications/project/query/project/PhabricatorProjectQuery.php
@@ -1,103 +1,103 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorProjectQuery {
private $owners;
private $members;
private $limit;
private $offset;
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function setOffset($offset) {
$this->offset = $offset;
return $this;
}
public function setOwners(array $owners) {
$this->owners = $owners;
return $this;
}
public function setMembers(array $members) {
$this->members = $members;
return $this;
}
public function execute() {
$table = id(new PhabricatorProject());
$conn_r = $table->establishConnection('r');
$joins = $this->buildJoinsClause($conn_r);
$limit = null;
if ($this->limit) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
$this->limit);
} else if ($this->offset) {
$limit = qsprintf(
$conn_r,
'LIMIT %d, %d',
$this->offset,
PHP_INT_MAX);
}
$data = queryfx_all(
$conn_r,
- 'SELECT * FROM %T p %Q %Q',
+ 'SELECT p.* FROM %T p %Q %Q',
$table->getTableName(),
$joins,
$limit);
return $table->loadAllFromArray($data);
}
private function buildJoinsClause($conn_r) {
$affil_table = new PhabricatorProjectAffiliation();
$joins = array();
if ($this->owners) {
$joins[] = qsprintf(
$conn_r,
'JOIN %T owner ON owner.projectPHID = p.phid AND owner.isOwner = 1
AND owner.userPHID in (%Ls)',
$affil_table->getTableName(),
$this->owners);
}
if ($this->members) {
$joins[] = qsprintf(
$conn_r,
'JOIN %T member ON member.projectPHID = p.phid
AND member.userPHID in (%Ls)',
$affil_table->getTableName(),
$this->members);
}
return implode(' ', $joins);
}
}
diff --git a/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php b/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
index 7dc819792b..a059682bbe 100644
--- a/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
+++ b/src/applications/project/storage/affiliation/PhabricatorProjectAffiliation.php
@@ -1,40 +1,39 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorProjectAffiliation extends PhabricatorProjectDAO {
protected $projectPHID;
protected $userPHID;
protected $role;
- protected $status = '';
protected $isOwner = 0;
public static function loadAllForProjectPHIDs($phids) {
if (!$phids) {
return array();
}
$default = array_fill_keys($phids, array());
$affiliations = id(new PhabricatorProjectAffiliation())->loadAllWhere(
- 'projectPHID IN (%Ls) ORDER BY IF(status = "former", 1, 0), dateCreated',
+ 'projectPHID IN (%Ls) ORDER BY dateCreated',
$phids);
return mgroup($affiliations, 'getProjectPHID') + $default;
}
}
diff --git a/webroot/rsrc/js/application/projects/projects-resource-editor.js b/webroot/rsrc/js/application/projects/projects-resource-editor.js
index 9a7e7d7611..31626b8cbc 100644
--- a/webroot/rsrc/js/application/projects/projects-resource-editor.js
+++ b/webroot/rsrc/js/application/projects/projects-resource-editor.js
@@ -1,122 +1,116 @@
/**
* @requires javelin-behavior
* phabricator-prefab
* multirow-row-manager
* javelin-tokenizer
* javelin-typeahead-preloaded-source
* javelin-typeahead
* javelin-dom
* javelin-json
* javelin-util
* @provides javelin-behavior-projects-resource-editor
* @javelin
*/
JX.behavior('projects-resource-editor', function(config) {
var root = JX.$(config.root);
var resources_table = JX.DOM.find(root, 'table', 'resources');
var manager = new JX.MultirowRowManager(resources_table);
var resource_rows = [];
for (var ii = 0; ii < config.state.length; ii++) {
addRow(config.state[ii]);
}
function renderRow(data) {
var template = JX.$N('div', JX.$H(config.tokenizerTemplate)).firstChild;
template.id = '';
var datasource = new JX.TypeaheadPreloadedSource(
config.tokenizerSource);
var typeahead = new JX.Typeahead(template);
typeahead.setDatasource(datasource);
var tokenizer = new JX.Tokenizer(template);
tokenizer.setTypeahead(typeahead);
tokenizer.setLimit(1);
tokenizer.start();
if (data.phid) {
tokenizer.addToken(data.phid, data.name);
}
- var status = JX.Prefab.renderSelect(
- {'' : 'Current', 'former' : 'Former'},
- data.status || '');
-
var role = JX.$N('input', {type: 'text', value : data.role || ''});
var ownership = JX.Prefab.renderSelect(
{0 : 'Nonowner', 1 : 'Owner'},
data.owner || 0);
var as_object = function() {
var tokens = tokenizer.getTokens();
return {
phid : JX.keys(tokens)[0] || null,
- status : status.value,
role : role.value,
owner : ownership.value
};
}
var r = [];
r.push([null, JX.$N('label', {}, 'User:')]);
r.push(['user-tokenizer', template]);
r.push(['role-label', JX.$N('label', {}, 'Role:')]);
- r.push([null, status]);
r.push(['role', role]);
r.push([null, ownership]);
for (var ii = 0; ii < r.length; ii++) {
r[ii] = JX.$N('td', {className : r[ii][0]}, r[ii][1]);
}
return {
nodes : r,
dataCallback : as_object
};
}
function onaddresource(e) {
e.kill();
addRow({});
}
function addRow(info) {
var data = renderRow(info);
var row = manager.addRow(data.nodes);
var id = manager.getRowID(row);
resource_rows[id] = data.dataCallback;
}
function onsubmit(e) {
var result = [];
for (var ii = 0; ii < resource_rows.length; ii++) {
if (resource_rows[ii]) {
var obj = resource_rows[ii]();
result.push(obj);
}
}
JX.$(config.input).value = JX.JSON.stringify(result);
}
JX.DOM.listen(
root,
'click',
'add-resource',
onaddresource);
JX.DOM.listen(
root,
'submit',
null,
onsubmit);
manager.listen(
'row-removed',
function(row_id) {
delete resource_rows[row_id];
});
});

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 19:22 (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127923
Default Alt Text
(31 KB)

Event Timeline