Author Topic: (resolved - sorta) Preset task filter queary  (Read 12405 times)

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
(resolved - sorta) Preset task filter queary
« on: June 29, 2010, 06:10:37 pm »
I'm trying to get this to work if anyone has any ideas or point me in the right direction that would be great.

I would like another dropdown list in the task module called presets.
When any of the options on this list is selected, all the filters change to match it.
ie,
"My todo list" would show tasks assigned to: me status:pending order by: duedate.
"Tasks for grabs" would show tasks assigned to: unassigned status:pending group by: workspace
you get the point...

These presets could be hardcoded for now but ideally the functionality of  allowing the user to create their own presets would be added.


« Last Edit: July 13, 2010, 04:34:43 pm by fernandog »

cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: Preset task filter queary
« Reply #1 on: June 30, 2010, 01:21:51 pm »
Nice idea !

Most javascript for Tasks is found in public/assets/javascript/og/tasks

You might want to modify TasksBottomToolbar.js to add a new combo for your preset filters.  I would copy the code of one of the existing combos as base for the new one.


damendieta

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Preset task filter queary
« Reply #2 on: June 30, 2010, 07:22:24 pm »
Grate idea.

If you do it, tell me how, please.

And, FO Team,  please try to include it in the next release.

Daniel.

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Preset task filter queary
« Reply #3 on: July 06, 2010, 03:05:51 pm »
Hi There!

Thanks for the suggestion Cabeza... I had figured out that much :)

I think im close to get this done. I coded the following:

Code: [Select]
   
this.add('-');
    this.add(new Ext.Action({
text: lang('tasks for grabs'),
            tooltip: lang('tasks for grabs'),
            iconCls: 'TasksForGrabs',

handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('-1:-1');
var toolbar = Ext.getCmp('tasksPanelTopToolbarObject');
        toolbar.load();


},
scope: this
}));

(paste anywhere in TasksTopToolbar.js under "//Add Stuff to the Toolbar")

This basically adds a button named "tasks for grabs" and it shows all tasks assigned to: unassigned, status: pending.
For a "My Todo list" preset (assigned to: me, status: pending), simply use this.filterNamesCompaniesCombo.setValue('1:1');

I am yet to figure out how to set the options on both the top (tasktoptoolbar.js) and the bottom of the toolbat (tasksbottomtoolbar.js) with the same button.

Any pointers would be great!!! Cabeza? Anyone?

thanks!!

« Last Edit: July 06, 2010, 03:12:36 pm by fernandog »

cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: Preset task filter queary
« Reply #4 on: July 08, 2010, 11:10:11 am »
To access the objects try calling

og.TasksBottomToolbar

and

og.TasksTopToolbar

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Preset task filter queary
« Reply #5 on: July 08, 2010, 03:59:17 pm »
Hi Cabeza,

Thanks for the help. Do you think you can be a bit more specific?

Im guessing it'll be something like:

og.TasksBottomToolbar.groupcombo.setValue('workspace');

and this would go somewhere inside the "handler: function() {"
is that right? So far its not working.

Cheers.

cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: Preset task filter queary
« Reply #6 on: July 08, 2010, 05:45:22 pm »
We put the code you sent with one little fix in the bottom toolbar and it worked as expected.

We only replaced:
Code: [Select]
var toolbar = Ext.getCmp('tasksPanelTopToolbarObject');
toolbar.load();
with
Code: [Select]
this.load();


Complete code:
Code: [Select]
this.add('-');
    this.add(new Ext.Action({
text: lang('tasks for grabs'),
            tooltip: lang('tasks for grabs'),
            iconCls: 'TasksForGrabs',

handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('-1:-1');
        this.load();


},
scope: this
}));

We tested it in Firefox. What browser are you using?

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Preset task filter queary
« Reply #7 on: July 09, 2010, 09:44:04 am »
Hello!

I use IE8.

The code was working fine changing the "filter" and "status". What I havent done is se tthe "group by" and "order by" (from the bottom)

I managed to set value to the dropdown list for "group by"  with this code:
Code: [Select]
this.add(new Ext.Action({
text: lang('my todo list'),
            tooltip: lang('my todo list tooltip'),
            handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('1:1');


Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
this.groupcombo.setValue('workspace');
return {
group_by : this.groupcombo.getValue()
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);



var toolbar = Ext.getCmp('tasksPanelTopToolbarObject');
        toolbar.load();
},
scope: this
}));
but the change is not applied to the tasks. I think I'm getting closer so I'll keep trying...

Thanks again for your help




cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: Preset task filter queary
« Reply #8 on: July 09, 2010, 10:57:46 am »
Great, let us know.  Keep in mind that the code we sent refreshed the task list AND set the combos in Firefox.
Didn't try it in IE8.

Best

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Preset task filter queary
« Reply #9 on: July 09, 2010, 03:16:24 pm »

Sigh...

I got it to work with this code:

Code: [Select]
    this.add(new Ext.Action({
text: lang('my todo list'),
            tooltip: lang('my todo list tooltip'),
            handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('1:1');


Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
return {
group_by : this.groupcombo.setValue('workspace'),
order_by : this.ordercombo.setValue('due_date')
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);

this.load();
},
scope: this
}));


This adds a button ('my todo list') which sets the filters to "assigned to: me, status: pending, group by: workspace, order by: duedate".

The problem is, after clicking on this button, the "group by" and "order by" boxes no longer work (no matter what I select, they stay at "workspace" and "duedate")

A little closer, but not quite there :)



fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Preset task filter queary
« Reply #10 on: July 13, 2010, 03:44:38 pm »
Ok, this is as far as I go. "Good enough" for me :)

This code will add four presets on the task list:
"My To-do List" |  Assigned to: Me, Status: Pending, Group by: Workspace, Order by: Due date
"Tasks for Grabs" | Assigned to: Nobody, Status: Pending, Group by: Workspace, Order by: Due Date
"All Pending Tasks" | Assigned to: Everyone, Status: Pendings, Group by: Nothing, Order by: Due Date
"My Completed Tasks" | Assigned to: Me, Status: Complete, Group by: Nothing, Order by: Completed on


Code: [Select]
this.add(new Ext.Action({
text: 'My To-Do List',
            tooltip: 'Assigned to: Me | Status: Pending | Group by: Worskpace| Order by: Due Date',
            handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');

    var mycurrentUser = '';
var usersArray = Ext.util.JSON.decode(document.getElementById(config.usersHfId).value);
var companiesArray = Ext.util.JSON.decode(document.getElementById(config.companiesHfId).value);
for (i in usersArray){
if (usersArray[i].isCurrent)
mycurrentUser = usersArray[i].cid + ':' + usersArray[i].id;
}
this.filterNamesCompaniesCombo.setValue(mycurrentUser);


Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
return {
group_by : this.groupcombo.setValue('workspace'),
order_by : this.ordercombo.setValue('due_date')
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);

this.load();
},
scope: this
}));




   this.add(new Ext.Action({
text: 'Tasks for Grabs',
            tooltip: 'Assigned to: Nobody| Status: Pending | Group by: Workspace | Order by: Due Date',
            handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('-1:-1');


Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
this.groupcombo.setValue('workspace');
this.ordercombo.setValue('due_date');
return {
group_by : this.groupcombo.getValue(),
order_by : this.ordercombo.getValue()
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);


this.load();
},
scope: this
}));
   this.add(new Ext.Action({
text: 'All Pending Tasks',
            tooltip: 'Assigned to: Everyone | Status: Pending | Group by: Nothing | Order by: Due Date',
            handler: function() {
this.statusCombo.setValue(0);
this.filtercombo.setValue('assigned_to');
this.filterNamesCompaniesCombo.setValue('0:0');

Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
this.groupcombo.setValue('nothing');
this.ordercombo.setValue('due_date');
return {
group_by : this.groupcombo.getValue(),
order_by : this.ordercombo.getValue()
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);


this.load();
},
scope: this
}));

   this.add(new Ext.Action({
text: 'My Completed Tasks',
            tooltip: 'Assigned to: Me | Status: Complete | Group by: Nothing | Order by: Completed on',
            handler: function() {
this.statusCombo.setValue(1);
this.filtercombo.setValue('assigned_to');

    var mycurrentUser = '';
var usersArray = Ext.util.JSON.decode(document.getElementById(config.usersHfId).value);
var companiesArray = Ext.util.JSON.decode(document.getElementById(config.companiesHfId).value);
for (i in usersArray){
if (usersArray[i].isCurrent)
mycurrentUser = usersArray[i].cid + ':' + usersArray[i].id;
}
this.filterNamesCompaniesCombo.setValue(mycurrentUser);

Ext.extend(og.TasksBottomToolbar, Ext.Toolbar, {
getDisplayCriteria : function(){
this.groupcombo.setValue('nothing');
this.ordercombo.setValue('completed_on');
return {
group_by : this.groupcombo.getValue(),
order_by : this.ordercombo.getValue()
}
},
getDrawOptions : function(){
return {
show_workspaces : this.items.item('btnShowWorkspaces').pressed,
show_time : this.items.item('btnShowTime').pressed,
show_tags : this.items.item('btnShowTags').pressed,
show_dates : this.items.item('btnShowDates').pressed
}
}
});
Ext.reg("TasksBottomToolbar", og.TasksBottomToolbar);


this.load();
},
scope: this
}));


(enter anywhere after "//Add stuff to the toolbar" on TasksTopToolbar.js)

See the screenshot attached.

Note; With this hack I ran into a little issue and I have not found a fix for it yet. Once you click on any of these presets, the bottom filters (group by and order by) cannot be changed until the page is refreshed or another preset is selected. If anyone cares to fix it, please share. Me and my team will use the presets solely so its not an issue for us.

Tested in IE and Firefox.

Have fun!

« Last Edit: July 14, 2010, 05:34:46 pm by fernandog »

cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: (resolved - sorta) Preset task filter queary
« Reply #11 on: July 13, 2010, 06:37:12 pm »
Thanks for sharing fernandog!

Murz

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: (resolved - sorta) Preset task filter queary
« Reply #12 on: July 14, 2010, 04:55:14 pm »
Where is the screenshot? :) Want to look what this code doing...

fernandog

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: (resolved - sorta) Preset task filter queary
« Reply #13 on: July 14, 2010, 05:31:08 pm »
Here it is  ;D
They are basically "one-click presets". You can modify it easily enough to fit your needs. Good luck.
« Last Edit: July 14, 2010, 05:36:00 pm by fernandog »

Murz

  • Full Member
  • ***
  • Posts: 147
    • View Profile
Re: (resolved - sorta) Preset task filter queary
« Reply #14 on: July 15, 2010, 01:48:14 am »
Thank's, this will be very useful for our company!
I have added all JS code from post #10, it succesfully add buttons  to the toolbar.

But this buttons don't do anything when clicked. I think that this must be any ajax code for reloading tasks list with new filter rules, not only scripts to add buttons.
Where I can get it?

Can you post the patch file for easily applying?