Dataform conditional open views

Dataform conditional open views

by Caballero Boro -
Number of replies: 6

Hi there, 

I am using a DataForm 2.6.4 in Moodle 2.6.1+

 I am working in a Dataform activity that contains 3 views a list, another planning and other memory.

The entries contain a status field that has three possible forms approved, planned and completed.

I have also added a button (entry pattern)  that points me in the list view to the other views in the selected entry.

I need to do the following:  That depending on the value of the status field the button send me to a form or another.


So it should be a conditional clause that makes the button change the tag view according to the field state. 

Another possible way is to change the button icon apparence (I could use one for a view planning and the other for  the view memory) or add some text to it. 

I don't know if Is possible in Dataform Insert conditional rules or change the apparence of the entry pattern icons.

Please help me.

Thank you.

Average of ratings: -
In reply to Caballero Boro

Re: Dataform conditional open views

by Itamar Tzadok -

There is no standard feature for conditional opening a view based on entry content.

If you want to prevent opening an entry in a certain view according to entry content, you can force a filter on the view. For example, you can create a filter with search criterion that matches entries with status 'approved'. Then, you assign this filter to the planning view in the Views index. Then if you go to the planning view it will show all and only entries in status 'approved'.

Now, here is a possible approach for navigation from the main List view:



All views are accessible but will show only entries in the designated status. So, Student 1 can click on the Planning icon or the Summary icon in her entry and will go to the respective view but will see nothing there. Student 2 can click on these icons in his entry but only the Planning view will show the entry content. Student 3 can click on these icon in her entry but only the Summary view will show the entry content.

The highlighting of the effective entry link based on the status is a simple css trick. Assuming the status field is called Status and it's base pattern returns the status name.

In the css tab:

                .approved-Approved,
                .completed-Completed {
                    background-color: #69F !important;
                }

The Planning and Summary columns In the List view entry template:

<td style="text-align: center;" class="approved-[[!Status] ]">[[EAC:edit:Planning] ]</td>
<td style="text-align: center;" class="completed-[[!Status] ]">[[EAC:more:Summary] ]</td>

The css class name of the cell will match one of the defined classes in the css tab and highlight the cell depending on the value in the status field of the entry. The entry action pattern specifies the target view. So when entry status is Approved, the cell with the link to edit the entry in the Planning view will be highlighted (Student 2). When the entry status is Completed, the cell with the link to view the entry in the Summary view will be highlighted.

hth smile

In reply to Itamar Tzadok

Re: Dataform conditional open views

by Caballero Boro -

Hello Itamar, 

First of all, thank you very much for your help. 

I tried your solution, 

Introducing de css Text (after modify) in the css tab

introducing the final html code in the template entry as follows:

[[Estat] ] 

[[ID] ] 

[[TItle] ] 

<td style = "text-align: center;" class = "aprobado- [[Estat]! ]"> [[EAC: edit: planning] ] </ td>

<td style = "text-align: center;" class = "planificado - [[Estat]! ]"> [[EAC: more: summary] ] </ td> 


I've also tried removing the space between semicolons, but always edit and more iconsdisappear in the columns . 

In the Aligned view, I don't know how to see the html code in the template because the editor does not appear. 

Anyway I need to edit in both views. And  would know if I can change the icon edit patterns apparence (a sheet instead the gear )


Thanks.

Boro


In reply to Caballero Boro

Re: Dataform conditional open views

by Caballero Boro -

Hi Itamar, 

I found that using the tabular view. The html code appears. I entered your css code in the CSS tab in the css box. I have also introduced the html code in the template entry as follows: 


====================================================

<table class="generaltable" align="center">

<thead>

<tr><th class="header c2" style="text-align: left;" scope="col">ID</th><th class="header c3" style="text-align: left;" scope="col">Titul en valencià</th><th class="header c7" style="text-align: left;" scope="col">Estat</th><th class="header c12 lastcol" style="text-align: center;" scope="col">Planificar</th><th class="header c12 lastcol" style="text-align: center;" scope="col">Memoria</th></tr>

</thead>

<tbody>

<tr class="r0 lastrow">

<td class="cell c2" style="text-align: left;">[[ID] ]</td>

<td class="cell c3" style="text-align: left;">[[Titul en valencià] ]</td>

<td class="cell c7" style="text-align: left;">[[Estat] ]</td>

<td style="text-align: center;" class="aprovada-[[!Estat] ]">[[EAC:edit:Grid_1] ] </td>

<td style="text-align: center;" class="planificada-[[!Estat] ]">[[EAC:edit:Grid_2] ]</td>

</tr>

</tbody>

</table>

===================================

* the space between semicolon is only for this message

I am still interested in knowing if you can changte the appearance of icons.


Best Regards

Boro

In reply to Caballero Boro

Re: Dataform conditional open views

by Itamar Tzadok -

With css you can hide the inner img and set the background image to some other image. Inspect to see the exact dom structure of the link, wrap it in the termplate with a container element if needed and then add the css.

With javascript you can change the img src.

hth smile

In reply to Itamar Tzadok

Re: Dataform conditional open views

by Caballero Boro -

Thanks Itamar.

I try it.

Another problem is that when I create a filter  and push the save button  reappears the page "new filter", and don't save it. I've tried changing the fields to sort, search, ... 

There are some required field?

What's the problem?


Best regards. Thank you for your patience.


Boro

In reply to Caballero Boro

Re: Dataform conditional open views

by Itamar Tzadok -

I need to reproduce the problem in order to investigate but there is not enough info here on what is there and what happens exactly. Please open a tracker issue in the Set: Dataform tracker and post there a detailed description of how you try to use the filter and what doesn't work. smile