How to generate Kanban with lists based on relationship between Item A, Item B and yet another sub-relationship with Item A? - google-app-maker

I am trying to create a Kanban view based on several relationships between datasources.
The case
I have:
- Tasks datasource
- Task_Stages datasource (e.g. To Do / Doing / Done)
- Tasks many-to-many relationship with Tasks as in Master Task / Sub-Tasks
The Issue
I am trying to use grid-layout and its grid-cells as the typical "List" in a Kanban. Where lists are representing the Stages
Within a grid-cell I am trying to set a List-layout widget to represent a typical Kanban item.
If I set the grid's datasource to Task_Stages, each grid-cell would represent a state, e.g. To do / doing / done. In this case, the list-layout widget would show absolutely all Task records.
I am struggling to set it to show only Tasks, which are related as Sub-Tasks to a selected Task.
What I tried
I've tried a large number of relationship combinations using several layers of panels, but all fail.
e.g. I set up a Main-Panel as Task:Sub-Tasks, then the grid as Sub-Task:Stages - in this case it shows only 1 grid cell that represents the stage of the first sub-task record.
This is how it looks with the above example:
*Only one Stage is shown, instead of showing all stages as different "lists"(grid-cells)
*The tasks visualized in the cell do not bear the relationship with the master task and are just tasks that have that stage type selected
Is there another way I can achieve this?

In order to get this working correctly you will probably need to do the following:
Set your main panel datasource to Stages.
In your Stages datasource make sure you don't apply any filters, so
that all stages will show as in 'To Do/Doing/Done'.
Still in your Stages datasource set a prefetch for Tasks, then use
the 'Advanced' option under prefetch settings to prefetch
Tasks.relations.Subtasks.
Back to your main panel, drag in a new Grid or make sure your
existing grid datasource is set to 'Inherited: Stages'.
For reference purposes drag in a label and set the binding to
#datasource.item.YourStagesName, so it will reflect your correct
stage in each panel. Drag in a list widget into the grid cell and
set the datasource to 'Stages: Tasks (relation)'.
Drag in a list widget into the list row and set the datasource to
'Tasks: SubTasks (relation)'.
Relatively speaking this should correct your issue but may require some additional testing. I did not test this setup myself but have successfully implemented something similar. The secret here is to prefetch all relations even if they are multiple levels deep by using the advanced prefetch option. Also keep in mind that the more tasks you have the more this process of prefetching multiple relations deep can slow down the performance of your app.

Related

How not to delete a row if it has children

I have a One to Many relation : One row in modelParent with Many row in modelChild
In a PanelList with the all modelParent rows, I want to hide the delete Icone on the row if the row has children link to this row.
What test should I do ?
Right way
Don't hide the delete button, but show confirmation dialog that would tell user how many related records would be deleted with the selected record. You can find code samples in Project Tracker, People Skills and lots of other templates.
Easy to implement way (worse performance)
Configure prefetch for your ParentModel's datasource to include records from ChildModel
Bind delete button's visibe property to this:
#datasource.item.<NameOfYourRelationField>.length === 0
Harder to implement way (better performance)
You can create calculated model with special flag that you can use on UI to show/hide the delete button. This approach will also require lots of extra scripting for CRUD operations.

filterAcceptRows() is being called for all the top level items in the tree

I have taken editable tree model example for my application and try to implement proxyModel on top of it.
I have re-implemented filterAcceptRows() function, when I apply filter this function is calling for all the top level items.
Is it possible to call this function only for the items which are visible currently in a view & then when I scroll down Apply same filter for newly brought items into view ?
Because I have lots of data from DB (more than 2 million top level items and child inside them), its taking much time to filter.
Or any suggestions while handling lots of data with filtering capability (I am doing lazy population too & I want my filter to be behave like this , so when I am actually iterating through all the parent and child items it is taking lots of time).

Select objects on a JavaFX Pane

I've created an application to draw objects on a JavaFX pane (rectangle, paths, custom controls etc..).
Now I want to be able to select those objects to move, copy or group them. The javafx Pane don't have a selectionModel by default and I somehow didn't find out how to implement such function.
If someone got an Idea on how to do this, I'll be grateful
You need to create your own selection model.
First you create a class SelectionModel. In that you put a Set. In order to put nodes into that set, you have to create a mouse handler that adds nodes to the model and removes them from the model depending on shift/ctrl pressed while you click on the nodes.
When you move the selection via mouse, you get the position of the currently clicked on node and instead of moving the single node in the event handler you move all nodes of the list in the SelectionModel.
In order to group them, you need to create a class/collection in which you can store the various nodes you selected. Usually the group is just a parent node. But that varies depending on your requirements.
Copy/Paste is a different matter. You need to create some kind of factory that creates and positions new nodes depending on the nodes in your selection model.
Here's an example with code for a start. It shows you how to select nodes.

Creating an expandable grid in MVC3 - data modelling

I am trying to create an expandable grid in MVC3. This is a follow up question to this .
Basically I have a complicated sql query that I need to use to populate a set of fields in a grid in MVC3. Also the grid elements must be expandable and on expansion should show additional data.
For example
I have two sql queries
Query A
select * from large tables joined
Query B
select data from selected row in query A
Query A represents my first query which I should use to populate the grid. On expansion of the grid I have to show the additional data by expanding the row from A with the query B.
I am creating a view model with all the fields I need in the first row of the grid that I can pass to the view.
Questions:
1.) How do I directly use sql to pass the data into the views instead of joining the models
2.) How do I make the grid expandable to show additional data?
3.) How do I model my sql, do I create one query for both and then selectively show data?
Caveat: MVC3 noob
Answers inline
Questions:
1.) How do I directly use sql to pass the data into the views instead of joining the models
This depends, either you pass in everything up front and write out hidden fields, or a hidden JSON object containing all the data and when the field is expanded, show it. so that is: Render all the data in your grid and hide each item until you need it, or dynamically load it from an array and show it when the user expands. You could also dynamically grab the required data when a user clicks on a row, but then you'd need to show a wait image while you grab the data by ajax (which would be fairly easy with mvc)
2.) How do I make the grid expandable to show additional data?
Plenty of expandable html grid results on the net :) Depend show you want to hide/show it.
3.) How do I model my sql, do I create one query for both and then selectively
This depends on the approach in 1 above. If you use ajax, you'd be returning one row at a time. In the other scenario you can have two queries you then merge into two view models or you join query A results with query b if theres a 1-1 mapping, assuming there isn't though so make two calls. Again, this is up to you. Do you want to pass all that data up front if the user will only expand two rows? not likely, in that case I like the ajax approach.

Qt: QSqlTableModel + QTableView sync with PostgreSQL

I'm writing a database access app for storing some data and want to ask a few questions about the model/view architecture.
(Using: Qt 4.7.4, own build; PostgreSQL 9.0; Targets: WinXP, Win7 (32/64 bit))
Let me first explain what I am trying to achieve and where I am currently.
I have two pages (subclassed QWidgets inserted in a QStackedWidget) with a QTableView bound to a model. Each view is bound to a table in the PostgreSQL server. You can add/edit/delete/sort/filter items.
Each page can be seen by only one type of users, lets call the roles Role1 and Role2.
The submit strategies of everything connected to the model are OnManualSubmit.
(Transaction isolation level = Serializable.) When two users want to edit(for example) the same row, I want to do a "SELECT ... FOR UPDATE" query - to make sure that when someone edits something, he will merge his changes with newer ones (if any, just like in SVN for example). But I see only a submitAll() method the QSqlTableModel.
Maybe catching the signals beforeUpdate(), beforeDelete(), beforeInsert() and performing manually "SELECT ... FOR UPDATE" is one option.
The other way I think is to subclass QSqlTableModel. What is the clean and nice way to achieve this?
I want to periodically update the QSqlTableView for each of the pages (one page is seen at most, Role1 users have access only to Page1 and the same for Role2 => Page2).
The first thing that came to my mind is to use a QTimer and manually call select() of the QSqlTableModel, but... not sure if this is the cool way.
I also want to periodically check if the connection to the database is ok, but I think that a QTimer + QSqlDatabase::isOpen () will do.
Now, the 2 tables have the same primary keys and some columns are the same. I want when a user with Role1 changes a row in Table1 to automatically change corresponding columns of Table2 and vice versa. Should I create a trigger in Postgres?
BTW, the database is small - each of the two tables is around 3-4000 rows with ~10 columns (varchars mostly, 1 text and 2 date colunms).
Thanks for reading and Happy New Year! :)
I think you should consider doing something of the following:
Instead of using QSqlTableModel as a model I'd implement my own model as a subclass of QAbstractTableModel. This will allow you a lot of control over what you can do in terms of data manipulation.
One thing that this will require is for certain fields in the table you would need to implement subclass of QAbstractItemDelegate that will allow for modification of data in the table as I am fairly sure you don't want to allow users updating any field in the table as for example primary key is likely have to be left alone.
For question 2 I would suggest implementing a field called transaction_counter for every row so you don't have to select every row in the table just the updated ones the transaction_counter will be updated on every row update and the new one will be inserted on the new row insert. One thing that will be required is that the counter is unique across the table. For example if initial state of the table is: row1 has counter = 0 and row2 has counter = 0. If row1 is updated counter set to 1. When row1 is then updated again counter on it is set to 2. When row2 is now updated counter on it is set to 3, etc. You can certainly do the data refreshes now using QTimer and this will be much more advantageous to for example checking the data as one user may be updating the same table as another user with the same Role.
For Question 3. I don't see any reason why not custom models and especially if you decide to separate data from the model you can manipulate data separately from it's display. Sort of Data->Model->View->Controller implementation. Each one can be maintained separately as long as you have a feedback mechanism for your delegates.
For Question 4. The answer is sure or you can implement the trigger in your application.
Hope this helps. Have a great New Year!

Resources