fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [17653] property: fix edit location form; add validat


From: sigurdne
Subject: [Fmsystem-commits] [17653] property: fix edit location form; add validation for required
Date: Sat, 20 Jan 2018 07:26:46 -0500 (EST)

Revision: 17653
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17653
Author:   sigurdne
Date:     2018-01-20 07:26:46 -0500 (Sat, 20 Jan 2018)
Log Message:
-----------
property: fix edit location form; add validation for required

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.uilocation.inc.php
    trunk/property/setup/phpgw_no.lang
    trunk/property/templates/base/location.xsl

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2018-01-20 10:30:00 UTC (rev 
17652)
+++ trunk/property/inc/class.bocommon.inc.php   2018-01-20 12:26:46 UTC (rev 
17653)
@@ -189,7 +189,7 @@
                        {
                                foreach ($list as &$entry)
                                {
-                                       if ($entry['id'] === $selected)
+                                       if ((string)$entry['id'] === 
(string)$selected) // in case the value is '0'
                                        {
                                                $entry['selected'] = 1;
                                                break;

Modified: trunk/property/inc/class.uilocation.inc.php
===================================================================
--- trunk/property/inc/class.uilocation.inc.php 2018-01-20 10:30:00 UTC (rev 
17652)
+++ trunk/property/inc/class.uilocation.inc.php 2018-01-20 12:26:46 UTC (rev 
17653)
@@ -1802,7 +1802,7 @@
 
                        $type_id = $this->type_id;
 
-                       if ($location_code)
+                       if (!$type_id && $location_code)
                        {
                                $type_id = count($location);
                        }
@@ -1842,6 +1842,7 @@
                        if ($values['error_id'])
                        {
                                $error_id = $values['error_id'];
+                               unset($location_code);
                        }
 
                        if (!$error_id && $location_code)
@@ -1892,6 +1893,7 @@
                                (
                                'values' => $_values,
                                'type_id' => ($type_id - 1),
+                               'required_level' => ($type_id - 1),
                                'no_link' => ($type_id), // disable lookup 
links for location type less than type_id
                                'tenant' => false,
                                'lookup_type' => $lookup_type
@@ -1930,6 +1932,8 @@
                        $additional_fields[$j]['name'] = 'loc' . $type_id;
                        $additional_fields[$j]['value'] = 
isset($values[$additional_fields[$j]['input_name']]) ? 
$values[$additional_fields[$j]['input_name']] : '';
                        $additional_fields[$j]['class'] = 'th_text';
+                       $additional_fields[$j]['required'] = true;
+
                        $insert_record['extra'][] = 
$additional_fields[$j]['input_name'];
 
                        $j++;
@@ -1940,6 +1944,7 @@
                        $additional_fields[$j]['name'] = 'loc' . $type_id . 
'_name';
                        $additional_fields[$j]['value'] = 
isset($values[$additional_fields[$j]['input_name']]) ? 
$values[$additional_fields[$j]['input_name']] : '';
                        $additional_fields[$j]['size'] = 
$additional_fields[$j]['value'] ? strlen($additional_fields[$j]['value']) + 5 : 
30;
+                       $additional_fields[$j]['required'] = true;
                        $insert_record['extra'][] = 
$additional_fields[$j]['input_name'];
                        $j++;
 
@@ -2754,6 +2759,12 @@
                                                
phpgwapi_cache::message_set($e->getMessage(), 'error');
                                        }
                                }
+                               
$GLOBALS['phpgw']->session->appsession('insert_record', 'property', '');
+                               if ($location_code)
+                               {
+                                       self::message_set($this->receipt);
+                                       self::redirect(array('menuaction' => 
'property.uilocation.edit', 'location_code' => $location_code));
+                               }
                        }
                        else
                        {
@@ -2765,23 +2776,18 @@
                                        $values['attributes'] = 
$this->bo->find_attribute(".location.{$this->type_id}");
                                        $values = 
$this->bo->prepare_attribute($values, ".location.{$this->type_id}");
 
-                                       /* restore date from posting */
-                                       $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record', 'property');
-                                       if (isset($insert_record['extra']) && 
is_array($insert_record['extra']))
+                               }
+                               /* restore date from posting */
+                               $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record', 'property');
+                               if (isset($insert_record['extra']) && 
is_array($insert_record['extra']))
+                               {
+                                       for ($i = 0; $i < 
count($insert_record['extra']); $i++)
                                        {
-                                               for ($i = 0; $i < 
count($insert_record['extra']); $i++)
-                                               {
-                                                       
$values[$insert_record['extra'][$i]] = 
phpgw::get_var($insert_record['extra'][$i], 'string', 'POST');
-                                               }
+                                               
$values[$insert_record['extra'][$i]] = 
phpgw::get_var($insert_record['extra'][$i], 'string', 'POST');
                                        }
                                }
+                               $values['error_id'] = 
$result['values']['error_id'];
                        }
-                       $GLOBALS['phpgw']->session->appsession('insert_record', 
'property', '');
-                       if ($location_code)
-                       {
-                               self::message_set($this->receipt);
-                               self::redirect(array('menuaction' => 
'property.uilocation.edit', 'location_code' => $location_code));
-                       }
                        $this->edit($values);
                }
 

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2018-01-20 10:30:00 UTC (rev 17652)
+++ trunk/property/setup/phpgw_no.lang  2018-01-20 12:26:46 UTC (rev 17653)
@@ -2393,4 +2393,5 @@
 pending action type    property        no      Handlingstyper
 comma separated email addresses to be notified about tenant claim      
property        no      Kommmaseparert liste over hvem som skal ha e-post om 
leietakerkrav
 record has been saved  property        no      Posten er lagret
-invoice remark property        no      Fakturanotat
\ No newline at end of file
+invoice remark property        no      Fakturanotat
+please select a part of town   property        no      Vennligst velg bydel
\ No newline at end of file

Modified: trunk/property/templates/base/location.xsl
===================================================================
--- trunk/property/templates/base/location.xsl  2018-01-20 10:30:00 UTC (rev 
17652)
+++ trunk/property/templates/base/location.xsl  2018-01-20 12:26:46 UTC (rev 
17653)
@@ -307,7 +307,13 @@
                                                                        
<xsl:variable name="lang_change_type_statustext">
                                                                                
<xsl:value-of select="lang_change_type_statustext"/>
                                                                        
</xsl:variable>
-                                                                       <select 
name="change_type" class="forms" 
onMouseover="window.status='{$lang_change_type_statustext}'; return true;" 
onMouseout="window.status='';return true;">
+                                                                       <select 
name="change_type" class="forms" title="{$lang_change_type_statustext}">
+                                                                               
<xsl:attribute name="data-validation">
+                                                                               
        <xsl:text>required</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:attribute name="data-validation-error-msg">
+                                                                               
        <xsl:value-of select="$lang_change_type_statustext"/>
+                                                                               
</xsl:attribute>
                                                                                
<option value="">
                                                                                
        <xsl:value-of select="lang_no_change_type"/>
                                                                                
</option>
@@ -331,21 +337,17 @@
                                                                </label>
                                                                <xsl:choose>
                                                                        
<xsl:when test="datatype ='text'">
-                                                                               
<textarea cols="60" rows="4" name="{input_name}" 
onMouseout="window.status='';return true;">
-                                                                               
        <xsl:attribute name="onMouseover">
-                                                                               
                <xsl:text>window.status='</xsl:text>
+                                                                               
<textarea cols="60" rows="4" name="{input_name}">
+                                                                               
        <xsl:attribute name="title">
                                                                                
                <xsl:value-of select="statustext"/>
-                                                                               
                <xsl:text>'; return true;</xsl:text>
                                                                                
        </xsl:attribute>
                                                                                
        <xsl:value-of select="value"/>
                                                                                
</textarea>
                                                                        
</xsl:when>
                                                                        
<xsl:when test="datatype ='date'">
-                                                                               
<input type="text" name="{input_name}" value="{value}" 
onFocus="{//dateformat_validate}" onKeyUp="{//onKeyUp}" onBlur="{//onBlur}" 
size="12" maxlength="10" onMouseout="window.status='';return true;">
-                                                                               
        <xsl:attribute name="onMouseover">
-                                                                               
                <xsl:text>window.status='</xsl:text>
+                                                                               
<input type="text" name="{input_name}" value="{value}" 
onFocus="{//dateformat_validate}" onKeyUp="{//onKeyUp}" onBlur="{//onBlur}" 
size="12" maxlength="10">
+                                                                               
        <xsl:attribute name="title">
                                                                                
                <xsl:value-of select="descr"/>
-                                                                               
                <xsl:text>'; return true;</xsl:text>
                                                                                
        </xsl:attribute>
                                                                                
</input>
                                                                                
<xsl:text>[</xsl:text>
@@ -353,10 +355,18 @@
                                                                                
<xsl:text>]</xsl:text>
                                                                        
</xsl:when>
                                                                        
<xsl:otherwise>
-                                                                               
<input type="text" name="{input_name}" value="{value}" size="{size}" 
onMouseout="window.status='';return true;">
+                                                                               
<input type="text" name="{input_name}" value="{value}" size="{size}">
                                                                                
        <xsl:attribute name="title">
                                                                                
                <xsl:value-of select="statustext"/>
                                                                                
        </xsl:attribute>
+                                                                               
        <xsl:if test="required = 1">
+                                                                               
                <xsl:attribute name="data-validation">
+                                                                               
                        <xsl:text>required</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
                <xsl:attribute name="data-validation-error-msg">
+                                                                               
                        <xsl:value-of select="input_text"/>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:if>
                                                                                
</input>
                                                                        
</xsl:otherwise>
                                                                </xsl:choose>
@@ -374,7 +384,21 @@
                                                                        <label>
                                                                                
<xsl:value-of select="lang_part_of_town"/>
                                                                        </label>
-                                                                       
<xsl:call-template name="select_part_of_town"/>
+                                                                       
<xsl:variable name="lang_town_statustext">
+                                                                               
<xsl:value-of select="lang_town_statustext"/>
+                                                                       
</xsl:variable>
+                                                                       <select 
name="part_of_town_id" title="{$lang_town_statustext}">
+                                                                               
<xsl:attribute name="data-validation">
+                                                                               
        <xsl:text>required</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:attribute name="data-validation-error-msg">
+                                                                               
        <xsl:value-of select="lang_no_part_of_town"/>
+                                                                               
</xsl:attribute>
+                                                                               
<option value="">
+                                                                               
        <xsl:value-of select="lang_no_part_of_town"/>
+                                                                               
</option>
+                                                                               
<xsl:apply-templates select="part_of_town_list"/>
+                                                                       
</select>
                                                                </div>
                                                        </xsl:when>
                                                </xsl:choose>
@@ -387,7 +411,13 @@
                                                                        
<xsl:variable name="lang_owner_statustext">
                                                                                
<xsl:value-of select="lang_owner_statustext"/>
                                                                        
</xsl:variable>
-                                                                       <select 
name="owner_id" class="forms" 
onMouseover="window.status='{$lang_owner_statustext}'; return true;" 
onMouseout="window.status='';return true;">
+                                                                       <select 
name="owner_id" class="forms" title="{$lang_owner_statustext}">
+                                                                               
<xsl:attribute name="data-validation">
+                                                                               
        <xsl:text>required</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:attribute name="data-validation-error-msg">
+                                                                               
        <xsl:value-of select="$lang_owner_statustext"/>
+                                                                               
</xsl:attribute>
                                                                                
<option value="">
                                                                                
        <xsl:value-of select="lang_select_owner"/>
                                                                                
</option>
@@ -400,23 +430,19 @@
                                                        <xsl:when 
test="edit_street = 1">
                                                                <div 
class="pure-control-group">
                                                                        <label>
-                                                                               
<a href="javascript:street_lookup()" 
onMouseover="window.status='{lang_select_street_help}';return true;" 
onMouseout="window.status='';return true;">
+                                                                               
<a href="javascript:street_lookup()" title="{lang_select_street_help}">
                                                                                
        <xsl:value-of select="lang_street"/>
                                                                                
</a>
                                                                        </label>
                                                                        <input 
type="hidden" name="street_id" value="{value_street_id}"/>
                                                                        <input 
size="30" type="text" name="street_name" value="{value_street_name}" 
onClick="street_lookup();" readonly="readonly">
-                                                                               
<xsl:attribute name="onMouseover">
-                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
<xsl:attribute name="title">
                                                                                
        <xsl:value-of select="lang_select_street_help"/>
-                                                                               
        <xsl:text>'; return true;</xsl:text>
                                                                                
</xsl:attribute>
                                                                        </input>
                                                                        <input 
size="4" type="text" name="street_number" value="{value_street_number}">
-                                                                               
<xsl:attribute name="onMouseover">
-                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
<xsl:attribute name="title">
                                                                                
        <xsl:value-of select="lang_street_num_statustext"/>
-                                                                               
        <xsl:text>'; return true;</xsl:text>
                                                                                
</xsl:attribute>
                                                                        </input>
                                                                </div>
@@ -426,16 +452,14 @@
                                                        <xsl:when 
test="edit_tenant = 1">
                                                                <div 
class="pure-control-group">
                                                                        <label>
-                                                                               
<a href="javascript:tenant_lookup()" 
onMouseover="window.status='{lang_tenant_statustext}';return true;" 
onMouseout="window.status='';return true;">
+                                                                               
<a href="javascript:tenant_lookup()" title="{lang_tenant_statustext}">
                                                                                
        <xsl:value-of select="lang_tenant"/>
                                                                                
</a>
                                                                        </label>
                                                                        <input 
type="hidden" name="tenant_id" value="{value_tenant_id}"/>
                                                                        <input 
size="{size_last_name}" type="text" name="last_name" value="{value_last_name}" 
onClick="tenant_lookup();" readonly="readonly">
-                                                                               
<xsl:attribute name="onMouseover">
-                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
<xsl:attribute name="title">
                                                                                
        <xsl:value-of select="lang_tenant_statustext"/>
-                                                                               
        <xsl:text>'; return true;</xsl:text>
                                                                                
</xsl:attribute>
                                                                        </input>
                                                                        <input 
size="{size_first_name}" type="text" name="first_name" 
value="{value_first_name}" onClick="tenant_lookup();" readonly="readonly">




reply via email to

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