fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [17423] API: allow tailored javascript per template s


From: sigurdne
Subject: [Fmsystem-commits] [17423] API: allow tailored javascript per template set
Date: Sun, 10 Dec 2017 07:18:12 -0500 (EST)

Revision: 17423
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17423
Author:   sigurdne
Date:     2017-12-10 07:18:12 -0500 (Sun, 10 Dec 2017)
Log Message:
-----------
API: allow tailored javascript per template set

Modified Paths:
--------------
    trunk/phpgwapi/inc/class.js.inc.php

Added Paths:
-----------
    trunk/bookingfrontend/js/aalesund/
    trunk/bookingfrontend/js/aalesund/application.js

Copied: trunk/bookingfrontend/js/aalesund/application.js (from rev 17422, 
trunk/bookingfrontend/js/base/application.js)
===================================================================
--- trunk/bookingfrontend/js/aalesund/application.js                            
(rev 0)
+++ trunk/bookingfrontend/js/aalesund/application.js    2017-12-10 12:18:12 UTC 
(rev 17423)
@@ -0,0 +1,337 @@
+var building_id_selection = "";
+var regulations_select_all = "";
+
+$(document).ready(function ()
+{
+       $("#start_date").change(function ()
+       {
+               $("#end_date").val($("#start_date").val());
+       });
+
+       JqueryPortico.autocompleteHelper(phpGWLink('bookingfrontend/', 
{menuaction: 'bookingfrontend.uibuilding.index'}, true), 'field_building_name', 
'field_building_id', 'building_container');
+
+       $("#field_activity").change(function ()
+       {
+               var building_id = $('#field_building_id').val();
+               if (building_id)
+               {
+                       populateTableChkResources(building_id, 
initialSelection);
+               }
+
+               var oArgs = {menuaction: 
'bookingfrontend.uiapplication.get_activity_data', activity_id: $(this).val()};
+               var requestUrl = phpGWLink('bookingfrontend/', oArgs, true);
+
+               $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function (data)
+                       {
+                               var html_agegroups = '';
+                               var html_audience = '';
+
+                               if (data != null)
+                               {
+                                       var agegroups = data.agegroups;
+                                       for (var i = 0; i < agegroups.length; 
++i)
+                                       {
+                                               html_agegroups += "<tr>";
+                                               html_agegroups += "<th>" + 
agegroups[i]['name'] + "</th>";
+                                               html_agegroups += "<td>";
+                                               html_agegroups += "<input 
class=\"input50\" type=\"text\" name='male[" + agegroups[i]['id'] + "]' 
value='0'></input>";
+                                               html_agegroups += "</td>";
+                                               html_agegroups += "<td>";
+                                               html_agegroups += "<input 
class=\"input50\" type=\"text\" name='female[" + agegroups[i]['id'] + "]' 
value='0'></input>";
+                                               html_agegroups += "</td>";
+                                               html_agegroups += "</tr>";
+                                       }
+                                       
$("#agegroup_tbody").html(html_agegroups);
+
+                                       var audience = data.audience;
+                                       var checked = '';
+                                       for (var i = 0; i < audience.length; 
++i)
+                                       {
+                                               checked = '';
+                                               if (initialAudience)
+                                               {
+                                                       for (var j = 0; j < 
initialAudience.length; ++j)
+                                                       {
+                                                               if 
(audience[i]['id'] == initialAudience[j])
+                                                               {
+                                                                       checked 
= " checked='checked'";
+                                                               }
+                                                       }
+                                               }
+                                               html_audience += "<li>";
+                                               html_audience += "<label>";
+                                               html_audience += "<input 
type=\"radio\" name=\"audience[]\" value='" + audience[i]['id'] + "'" + checked 
+ "></input>";
+                                               html_audience += 
audience[i]['name'];
+                                               html_audience += "</label>";
+                                               html_audience += "</li>";
+                                       }
+                                       $("#audience").html(html_audience);
+                               }
+                       }
+               });
+       });
+
+});
+
+$(window).on('load', function()
+{
+       building_id = $('#field_building_id').val();
+       regulations_select_all = initialAcceptAllTerms;
+       resources = initialSelection;
+       if (building_id)
+       {
+               populateTableChkResources(building_id, initialSelection);
+               populateTableChkRegulations(building_id, 
initialDocumentSelection, resources);
+               building_id_selection = building_id;
+       }
+       $("#field_building_name").on("autocompleteselect", function (event, ui)
+       {
+               var building_id = ui.item.value;
+               var selection = [];
+               var resources = [];
+               if (building_id != building_id_selection)
+               {
+                       populateTableChkResources(building_id, 
initialSelection);
+                       populateTableChkRegulations(building_id, selection, 
resources);
+                       building_id_selection = building_id;
+               }
+       });
+       $('#resources_container').on('change', '.chkRegulations', function ()
+       {
+               var resources = new Array();
+               $('#resources_container 
input.chkRegulations[name="resources[]"]:checked').each(function ()
+               {
+                       resources.push($(this).val());
+               });
+               var selection = [];
+               populateTableChkRegulations(building_id_selection, selection, 
resources);
+       });
+
+       if (!$.formUtils)
+       {
+               $('#application_form').submit(function (e)
+               {
+                       if (!validate_documents())
+                       {
+                               e.preventDefault();
+                               alert(lang['You must accept to follow all terms 
and conditions of lease first.']);
+                       }
+               });
+       }
+});
+
+if ($.formUtils)
+{
+       $.formUtils.addValidator({
+               name: 'regulations_documents',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       $('#regulation_documents 
input[name="accepted_documents[]"]').each(function ()
+                       {
+                               if (!$(this).is(':checked'))
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n == 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'You must accept to follow all terms and 
conditions of lease first.',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'target_audience',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       $('#audience input[name="audience[]"]').each(function ()
+                       {
+                               if ($(this).is(':checked'))
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Please choose at least 1 target audience',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'number_participants',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       $('#agegroup_tbody input').each(function ()
+                       {
+                               if ($(this).val() != "" && $(this).val() > 0)
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Number of participants is required',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'application_resources',
+               validatorFunction: function (value, $el, config, language, 
$form)
+               {
+                       var n = 0;
+                       $('#resources_container table 
input[name="resources[]"]').each(function ()
+                       {
+                               if ($(this).is(':checked'))
+                               {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Please choose at least 1 resource',
+               errorMessageKey: 'application_resources'
+       });
+
+       $.formUtils.addValidator({
+               name: 'customer_identifier',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var v = false;
+                       var customer_ssn = $('#field_customer_ssn').val();
+                       var customer_organization_number = 
$('#field_customer_organization_number').val();
+                       if (customer_ssn != "" || customer_organization_number 
!= "")
+                       {
+                               v = true;
+                       }
+                       return v;
+               },
+               errorMessage: 'Customer identifier type is required',
+               errorMessageKey: ''
+       });
+
+       $.formUtils.addValidator({
+               name: 'application_dates',
+               validatorFunction: function (value, $el, config, languaje, 
$form)
+               {
+                       var n = 0;
+                       if ($('input[name="from_[]"]').length == 0 || 
$('input[name="from_[]"]').length == 0)
+                       {
+                               return false;
+                       }
+                       $('input[name="from_[]"]').each(function ()
+                       {
+                               if ($(this).val() == "")
+                               {
+                                       
$($(this).addClass("error").css("border-color", "red"));
+                                       n++;
+                               }
+                               else
+                               {
+                                       
$($(this).removeClass("error").css("border-color", ""));
+                               }
+                       });
+                       $('input[name="to_[]"]').each(function ()
+                       {
+                               if ($(this).val() == "")
+                               {
+                                       
$($(this).addClass("error").css("border-color", "red"));
+                                       n++;
+                               }
+                               else
+                               {
+                                       
$($(this).removeClass("error").css("border-color", ""));
+                               }
+                       });
+                       var v = (n == 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Invalid date',
+               errorMessageKey: ''
+       });
+}
+else
+{
+       function validate_documents()
+       {
+               var n = 0;
+               $('#regulation_documents 
input[name="accepted_documents[]"]').each(function ()
+               {
+                       if (!$(this).is(':checked'))
+                       {
+                               n++;
+                       }
+               });
+               var v = (n == 0) ? true : false;
+               return v;
+       }
+}
+
+function populateTableChkResources(building_id, selection)
+{
+       var oArgs = {menuaction: 'bookingfrontend.uiresource.index_json', sort: 
'name', filter_building_id: building_id, sub_activity_id: 
$("#field_activity").val()};
+       var url = phpGWLink('bookingfrontend/', oArgs, true);
+       var container = 'resources_container';
+       var colDefsResources = [{label: '', object: [{type: 'input', attrs: [
+                                               {name: 'type', value: 
'checkbox'}, {name: 'name', value: 'resources[]'}, {name: 'class', value: 
'chkRegulations'}
+                                       ]}
+                       ], value: 'id', checked: selection}, {key: 'name', 
label: lang['Name']}, {key: 'type', label: lang['Resource Type']}
+       ];
+       populateTableResources(url, container, colDefsResources);
+}
+
+function populateTableChkRegulations(building_id, selection, resources)
+{
+    var url = phpGWLink('bookingfrontend/', {menuaction: 
'booking.uidocument_view.regulations', sort: 'name'}, true) + 
'&owner[]=building::' + building_id;
+       for (var r in resources)
+       {
+               url += '&owner[]=resource::' + resources[r];
+       }
+       var container = 'regulation_documents';
+       var colDefsRegulations = [{label: lang['Accepted'], object: [
+                               {type: 'input', attrs: [
+                                               {name: 'type', value: 
'checkbox'}, {name: 'name', value: 'accepted_documents[]'}
+                                       ]}
+                       ], value: 'id', checked: selection}, {key: 'name', 
label: lang['Document'], formatter: genericLink}
+       ];
+       if (regulations_select_all)
+       {
+               colDefsRegulations[0]['object'][0]['attrs'].push({name: 
'checked', value: 'checked'});
+       }
+       regulations_select_all = false;
+       populateTableRegulations(url, container, colDefsRegulations);
+}
+
+function populateTableResources(url, container, colDefs)
+{
+       if (typeof tableClass !== 'undefined')
+       {
+               createTable(container, url, colDefs, 'results', tableClass);
+       }
+       else
+       {
+               createTable(container, url, colDefs, 'results');
+       }
+}
+
+function populateTableRegulations(url, container, colDefs)
+{
+       if (typeof tableClass !== 'undefined')
+       {
+               createTable(container, url, colDefs, '', tableClass);
+       }
+       else
+       {
+               createTable(container, url, colDefs);
+       }
+
+}

Modified: trunk/phpgwapi/inc/class.js.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.js.inc.php 2017-12-10 12:05:50 UTC (rev 17422)
+++ trunk/phpgwapi/inc/class.js.inc.php 2017-12-10 12:18:12 UTC (rev 17423)
@@ -295,7 +295,7 @@
 
                        if(is_readable(PHPGW_INCLUDE_ROOT . 
"/$app/js/$template_set/$file.js"))
                        {
-                               $this->files[$app][$package][$file] = True;
+                               $this->files[$app][$template_set][$file] = True;
                                return True;
                        }
                        else if(is_readable(PHPGW_INCLUDE_ROOT . 
"/$app/js/$package/$file.js"))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]