Skip to content

Commit

Permalink
[jan] Support task assignees.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jan 27, 2014
1 parent 2d04673 commit d8156b6
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 15 deletions.
1 change: 1 addition & 0 deletions kronolith/docs/CHANGES
Expand Up @@ -2,6 +2,7 @@
v4.2.0-git
----------

[jan] Support task assignees.
[jan] Support parent tasks in dynamic view.
[jan] Indent sub tasks.
[jan] Make shares table compatible with Oracle.
Expand Down
26 changes: 24 additions & 2 deletions kronolith/js/kronolith.js
Expand Up @@ -2613,6 +2613,7 @@ KronolithCore = {
if (id) {
RedBox.loading();
this.updateTaskParentDropDown(tasklist);
this.updateTaskAssigneeDropDown(tasklist);
HordeCore.doAction('getTask', {
list: tasklist,
id: id
Expand All @@ -2625,7 +2626,9 @@ KronolithCore = {
$('kronolithTaskOldList').clear();
$('kronolithTaskList').setValue(Kronolith.conf.tasks.default_tasklist);
this.updateTaskParentDropDown(Kronolith.conf.tasks.default_tasklist);
this.updateTaskAssigneeDropDown(Kronolith.conf.tasks.default_tasklist);
$('kronolithTaskParent').setValue('');
$('kronolithTaskAssignee').setValue('');
//$('kronolithTaskLocation').setValue('http://');
HordeCore.doAction('listTopTags', {}, {
callback: this.topTagsCallback.curry('kronolithTaskTopTags', 'kronolithTaskTag')
Expand Down Expand Up @@ -2665,6 +2668,7 @@ KronolithCore = {
$('kronolithTaskList').setValue(task.l);
$('kronolithTaskTitle').setValue(task.n);
$('kronolithTaskParent').setValue(task.p);
$('kronolithTaskAssignee').setValue(task.as);
//$('kronolithTaskLocation').setValue(task.l);
if (task.dd) {
$('kronolithTaskDueDate').setValue(task.dd);
Expand Down Expand Up @@ -2784,6 +2788,22 @@ KronolithCore = {
});
},

/**
* Propagates a SELECT drop down list with the users of a task list.
*
* @param string list A task list ID.
*/
updateTaskAssigneeDropDown: function(list)
{
var assignee = $('kronolithTaskAssignee');
assignee.update(new Element('option', { value: '' })
.update(Kronolith.text.no_assignee));
$H(Kronolith.conf.calendars.tasklists['tasks/' + list].users).each(function(user) {
assignee.insert(new Element('option', { value: user.key })
.update(user.value.escapeHTML()));
});
},

/**
* Sets the default due date and time for tasks.
*/
Expand Down Expand Up @@ -2927,7 +2947,6 @@ KronolithCore = {
Object.isUndefined(Kronolith.conf.calendars[type][cal])) &&
(type == 'internal' || type == 'tasklists')) {
HordeCore.doAction('getCalendar', {
type: type,
cal: cal
}, {
callback: function(r) {
Expand Down Expand Up @@ -6779,7 +6798,10 @@ KronolithCore = {

if (Kronolith.conf.has_tasks) {
$('kronolithTaskDueDate', 'kronolithTaskDueTime').compact().invoke('observe', 'focus', this.setDefaultDue.bind(this));
$('kronolithTaskList').observe('change', function() { this.updateTaskParentDropDown($F('kronolithTaskList')); }.bind(this));
$('kronolithTaskList').observe('change', function() {
this.updateTaskParentDropDown($F('kronolithTaskList'));
this.updateTaskAssigneeDropDown($F('kronolithTaskList'));
}.bind(this));
}

document.observe('keydown', KronolithCore.keydownHandler.bindAsEventListener(KronolithCore));
Expand Down
1 change: 1 addition & 0 deletions kronolith/lib/Ajax.php
Expand Up @@ -139,6 +139,7 @@ protected function _addBaseVars()
'hidelog' => _("Hide Notifications"),
'import_warning' => _("Importing calendar data. This may take a while..."),
'more' => _("more..."),
'no_assignee' => _("None"),
'no_calendar_title' => _("The calendar title must not be empty."),
'no_parent' => _("No parent task"),
'no_tasklist_title' => _("The task list title must not be empty."),
Expand Down
1 change: 1 addition & 0 deletions kronolith/lib/Calendar.php
Expand Up @@ -130,6 +130,7 @@ public function toHash()
'name' => $this->name(),
'desc' => $this->description(),
'owner' => true,
'users' => array(),
'fg' => $this->foreground(),
'bg' => $this->background(),
);
Expand Down
3 changes: 2 additions & 1 deletion kronolith/lib/Calendar/External/Tasks.php
Expand Up @@ -47,8 +47,9 @@ public function toHash()

$hash = parent::toHash();
$hash['name'] = Kronolith::getLabel($this->_share);
$hash['desc'] = (string)$this->_share->get('desc');
$hash['desc'] = (string)$this->_share->get('desc');
$hash['owner'] = $owner;
$hash['users'] = Kronolith::listShareUsers($this->_share);
$hash['fg'] = Kronolith::foregroundColor($this->_share);
$hash['bg'] = Kronolith::backgroundColor($this->_share);
$hash['show'] = in_array('tasks/' . $this->_share->getName(), $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS));
Expand Down
1 change: 1 addition & 0 deletions kronolith/lib/Calendar/Internal.php
Expand Up @@ -135,6 +135,7 @@ public function toHash()
$hash = parent::toHash();
$hash['name'] = $this->name();
$hash['owner'] = $owner;
$hash['users'] = Kronolith::listShareUsers($this->_share);
$hash['show'] = in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
$hash['edit'] = $this->hasPermission(Horde_Perms::EDIT);
try {
Expand Down
33 changes: 33 additions & 0 deletions kronolith/lib/Kronolith.php
Expand Up @@ -1338,6 +1338,39 @@ static public function deleteShare($calendar)
}
}

/**
* Returns a list of user with read access to a share.
*
* @param Horde_Share_Object $share A share object.
*
* @return array A hash of share users.
*/
public function listShareUsers($share)
{
global $injector;

$users = $share->listUsers(Horde_Perms::READ);
$groups = $share->listGroups(Horde_Perms::READ);
if (count($groups)) {
$horde_group = $injector->getInstance('Horde_Group');
foreach ($groups as $group) {
$users = array_merge(
$users,
$horde_group->listUsers($group)
);
}
}

$users = array_flip($users);
$factory = $injector->getInstance('Horde_Core_Factory_Identity');
foreach (array_keys($users) as $user) {
$fullname = $factory->create($user)->getValue('fullname');
$users[$user] = strlen($fullname) ? $fullname : $user;
}

return $users;
}

/**
* Reads a submitted permissions form and updates the share permissions.
*
Expand Down
2 changes: 2 additions & 0 deletions kronolith/package.xml
Expand Up @@ -33,6 +33,7 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [jan] Support task assignees.
* [jan] Support parent tasks in dynamic view.
* [jan] Indent sub tasks.
* [jan] Make shares table compatible with Oracle.
Expand Down Expand Up @@ -2247,6 +2248,7 @@
<date>2013-09-24</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
* [jan] Support task assignees.
* [jan] Support parent tasks in dynamic view.
* [jan] Indent sub tasks.
* [jan] Make shares table compatible with Oracle.
Expand Down
33 changes: 21 additions & 12 deletions kronolith/templates/dynamic/task.inc
Expand Up @@ -15,38 +15,47 @@
<?php echo Horde::img('picker.png', _("Set due date"), 'id="kronolithTaskDuePicker" class="kronolithDatePicker"') ?>
</label>
<label>
<?php echo _("at") ?>
<?php echo _("at") ?>:
<input type="text" name="task[due_time]" id="kronolithTaskDueTime" size="8" tabindex="3" />
</label>
</div>

<div>
<label>
<?php echo _("Add to") ?>:
<select name="task[tasklist]" id="kronolithTaskList" tabindex="4">
</select>
</label>
<span class="kronolithSeparator">|</span>
<label>
<?php echo _("Priority") ?>:
<select name="task[priority]" id="kronolithTaskPriority" tabindex="4">
<select name="task[priority]" id="kronolithTaskPriority" tabindex="5">
<?php foreach (array(1 => _("Highest"), 2 => _("High"), 3 => _("Normal"), 4 => _("Low"), 5 => _("Lowest")) as $prio => $label): ?>
<option value="<?php echo $prio ?>"><?php echo $label ?></option>
<?php endforeach; ?>
</select>
</label>
<span class="kronolithSeparator">|</span>
</div>

<div>
<label>
<?php echo _("Add to") ?>
<select name="task[tasklist]" id="kronolithTaskList" tabindex="5">
<?php echo _("Parent task") ?>:
<select name="task[parent]" id="kronolithTaskParent" tabindex="6">
<option value=""><?php echo _("No parent task") ?></option>
</select>
</label>
<span class="kronolithSeparator">|</span>
<label>
<?php echo _("Parent task") ?>:
<select name="task[parent]" id="kronolithTaskParent" tabindex="6">
<option value=""><?php echo _("No parent task") ?></option>
<?php echo _("Assignee") ?>:
<select name="task[assignee]" id="kronolithTaskAssignee" tabindex="7">
<option value=""><?php echo _("None") ?></option>
</select>
</label>
</div>

<div>
<?php echo _("Mark task as") ?>
<input type="checkbox" name="task[completed]" id="kronolithTaskCompleted" value="1" tabindex="7" />
<input type="checkbox" name="task[completed]" id="kronolithTaskCompleted" value="1" tabindex="8" />
<label for="kronolithTaskCompleted"><?php echo _("completed") ?></label>
</div>

Expand All @@ -61,7 +70,7 @@
<br class="clear" />

<div id="kronolithTaskTabDescription" class="kronolithTabsOption">
<textarea name="task[desc]" id="kronolithTaskDescription" rows="5" cols="40" class="kronolithLongField" tabindex="8"></textarea>
<textarea name="task[desc]" id="kronolithTaskDescription" rows="5" cols="40" class="kronolithLongField" tabindex="9"></textarea>
</div>

<div id="kronolithTaskTabReminder" class="kronolithTabsOption" style="display:none">
Expand Down Expand Up @@ -152,8 +161,8 @@
</div>

<div class="kronolithFormActions">
<input id="kronolithTaskSave" type="button" value="<?php echo _("Save") ?>" class="horde-default" tabindex="9" />
<input id="kronolithTaskDelete" type="button" value="<?php echo _("Delete") ?>" class="horde-delete" tabindex="10" />
<input id="kronolithTaskSave" type="button" value="<?php echo _("Save") ?>" class="horde-default" tabindex="10" />
<input id="kronolithTaskDelete" type="button" value="<?php echo _("Delete") ?>" class="horde-delete" tabindex="11" />
<span class="kronolithSeparator"><?php echo _("or") ?></span> <a class="horde-cancel"><?php echo _("Cancel") ?></a>
</div>

Expand Down

0 comments on commit d8156b6

Please sign in to comment.