diff --git a/Asset/css/workspaceorg.css b/Asset/css/workspaceorg.css index 25b3c88..0cb0eb1 100644 --- a/Asset/css/workspaceorg.css +++ b/Asset/css/workspaceorg.css @@ -38,12 +38,40 @@ font-style: italic; } -.wso-table td { - vertical-align: middle; +/* One project row: id (+ config dropdown) / title / owner on the left, move control on the right, + separated by a light horizontal line. */ +.wso-row { + display: flex; + align-items: center; + justify-content: space-between; + padding: 6px 2px; + border-bottom: 1px solid #eee; +} + +.wso-row-main { + display: flex; + align-items: baseline; + flex-wrap: wrap; +} + +.wso-id { + margin-right: 8px; + color: #777; +} + +.wso-title { + margin-right: 12px; + font-weight: bold; +} + +.wso-owner { + color: #999; + font-size: 0.9em; } .wso-move { - width: 220px; + flex: 0 0 auto; + margin-left: 12px; text-align: right; } diff --git a/Asset/js/workspaceorg.js b/Asset/js/workspaceorg.js new file mode 100644 index 0000000..d9d6598 --- /dev/null +++ b/Asset/js/workspaceorg.js @@ -0,0 +1,26 @@ +/* + * WorkspaceOrg -- submit the per-project "move to workspace" form when its dropdown changes. + * + * Kanboard's default CSP is `default-src 'self'` (no 'unsafe-inline' for scripts), so an inline + * onchange="" attribute is blocked and does nothing. The change handler must live in an external + * script served from 'self', which is what this file is. + */ +(function () { + "use strict"; + + function init() { + var selects = document.querySelectorAll(".wso-move-form select"); + + for (var i = 0; i < selects.length; i++) { + selects[i].addEventListener("change", function () { + this.form.submit(); + }); + } + } + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", init); + } else { + init(); + } +})(); diff --git a/Helper/WorkspaceOrgHelper.php b/Helper/WorkspaceOrgHelper.php index 2626c46..e2676c2 100644 --- a/Helper/WorkspaceOrgHelper.php +++ b/Helper/WorkspaceOrgHelper.php @@ -124,8 +124,13 @@ class WorkspaceOrgHelper extends Base $groups[self::DEFAULT_WORKSPACE] = array(); - foreach ($this->projectUserRoleModel->getActiveProjectsByUser($this->uid()) as $project_id => $project_name) { - $groups[$this->workspaceOf($project_id)][] = array('id' => (int) $project_id, 'name' => $project_name); + // Full project rows (id, name, owner_name, is_active, ...) for the user's active projects, + // the same data source the native "My projects" dashboard uses. + $ids = $this->projectPermissionModel->getActiveProjectIds($this->uid()); + $projects = empty($ids) ? array() : $this->projectModel->getQueryColumnStats($ids)->findAll(); + + foreach ($projects as $project) { + $groups[$this->workspaceOf($project['id'])][] = $project; } foreach ($groups as &$list) { diff --git a/Plugin.php b/Plugin.php index 1365ed9..d3b506f 100644 --- a/Plugin.php +++ b/Plugin.php @@ -27,6 +27,12 @@ class Plugin extends Base $this->hook->on('template:layout:css', array( 'template' => 'plugins/WorkspaceOrg/Asset/css/workspaceorg.css', )); + + // Submits the inline "move to workspace" select on change. Must be an external script: + // Kanboard's CSP (default-src 'self') blocks inline onchange handlers. + $this->hook->on('template:layout:js', array( + 'template' => 'plugins/WorkspaceOrg/Asset/js/workspaceorg.js', + )); } public function getHelpers() @@ -53,7 +59,7 @@ class Plugin extends Base public function getPluginVersion() { - return '0.1.0'; + return '0.2.0'; } public function getPluginHomepage() diff --git a/README.md b/README.md index 4e03fc6..4248d10 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ Two people can file the same shared project differently, and neither sees the ot - Adds a **My workspaces** entry to the dashboard sidebar (next to Overview / My projects / My tasks / My subtasks). Visible to every logged-in user -- no admin rights needed. -- That page lists your projects **grouped by workspace**, and lets you: +- That page lists your projects **grouped by workspace** (each heading shows the project count, + e.g. `POLI/UPE (3)`), with each row showing the project **id**, **title** and **owner**, plus a + small id dropdown with a "Configure this project" shortcut. From it you can: - **add / rename / remove** workspaces (each via a small modal, like Kanboard's Tags page); - **move a project** to another workspace with an inline dropdown on its row. - Shows a **`[Workspace]`** badge before the project title on the dashboard overview, the diff --git a/Template/workspace/index.php b/Template/workspace/index.php index f7e63ab..b271a92 100644 --- a/Template/workspace/index.php +++ b/Template/workspace/index.php @@ -10,7 +10,7 @@ $projects): ?>
= t('(no projects yet)') ?>
-|
+
+
+
+ user->hasProjectAccess('ProjectViewController', 'show', $project['id'])): ?>
+
+ #= (int) $project['id'] ?>
+
|
- - - | -