EASOL / easol

EASOL - A New Way to Open Learning with Ed-Tech
http://easol.org
GNU Affero General Public License v3.0
1 stars 4 forks source link

Flex Reports - Cross Linking #247

Closed regiscamimura closed 8 years ago

regiscamimura commented 8 years ago

Cross-Linking - Some table reports would contain links in columns. Each link would need to be added manually for every report. Let’s say we have a query “SELECT ID, FirstName, LastSurname from Students” (let’s assume it’s a table). Then, we create a new “link” item (a different section for them, the same as for filters) and we define the following variables there: a) Column # (a column which should be tappable) b) URL Template (URL where the user should be moved template) c) Value Column # (Value of the row which should be used for the URL redirection). In our situation we would have these variables a) Column 3 b) /student/profile/$variable c) Column 1

regiscamimura commented 8 years ago

@tarlles10 Please work on this task. First of, there's a new branch called "247". In this branch, there's a SQL file named "247-report-link-table.sql", please use it to create the table as needed.

What happens is that the reports have the dataTable, and some cells in those tables can be links to other pages. We need to allow the creation of such links, so the first step is to add those links to add/edit forms for the flex reports. We must specify on which column (by column number, not column name) the link will be, and from which column we're going to retrieve dynamic values for the link, and what's going to be the "template" or "structure" of the link.

What I want you to do is:

  1. Create the Models to insert, update, and read from the new table, i.e., do all the CRUD
  2. In Flex Reports add/edit form, please create a new section for "Links", that should be very similar to the "Filters" section, and it should use the same mechanisms to allow the creation/deletion of filters. The fields for each link are described above.

Don't need to worry about actually implement the links in the flex reports presentation at that point, but go ahead if you have time. Note that we'll need to replace the $variable in the template URL with some actual dynamic value from which column number (defined in the field "ValueColumnNo")

tarlles10 commented 8 years ago

@regiscamimura I got the task 1. and 2. completed. The next step is implement the links in the flex reports presentation

regiscamimura commented 8 years ago

Great. Please resume work on this, but with the following change:

  1. Remove the ValueColumnNo from the database, models and the interface
  2. For the URL template, we're going to accept formats like "student/profile/$StudentUSI"
  3. When we implement the link in the flex reports presentation, we're going to grab the URL template and replace anything that starts with "$" with the respective dynamic value.

So, in the example above, the URL is "student/profile/$StudentUSI". A Flex Report with such link must have, in the CommandText query, a column for "StudentUSI" in the result, so we're going to use it to replace the variable.

You're going need to use some preg_replace expression in order to do that. Ideally, we would use a regular expression that would match any word starting with "$" and ending with anything that is not a letter or a number. But if the regex is causing too much trouble, you can consider that the variable must be between brackets, i.e., the URL template would need to be something like /student/profile/[StudentUSI], so we would replace anything between brackets. That's probably an easier regex to do, and you can do that if the other format using "$" is too much trouble.

tarlles10 commented 8 years ago

I've removed only the ValueColumnNo from the database, models and the interface.

edgarf commented 8 years ago

@regiscamimura, what if we'd have edfi.Student.StudentUSI in the command text? Would we also need to have this full variable name in the cross linking part?

regiscamimura commented 8 years ago

@edgarf Actually, is the opposite. You can't put the variable name in the URL as, for example, /student/profile/$edfi.Student.StudentUSI, it must be /student/profile/$StudentUSI instead. That's because when you use the full classified name in a query, that prevents colisions and such, but the database will return a result set where the column names are directly from the table, and won't contain the full classified name. In PHP side, the variables available there won't have the prefixes and such, just the plain column name. Makes sense?

tarlles10 commented 8 years ago

@regiscamimura follow the regular expression for match $StudentUSI /([$][I-S])\D+/g