[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9690]
From: |
Torstein |
Subject: |
[Fmsystem-commits] [9690] |
Date: |
Thu, 28 Jun 2012 01:55:46 +0000 |
Revision: 9690
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9690
Author: vator
Date: 2012-06-28 01:55:46 +0000 (Thu, 28 Jun 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.socontrol_item.inc.php
trunk/controller/inc/class.uicontrol_item.inc.php
trunk/controller/js/controller/ajax.js
trunk/controller/templates/base/control_item/control_item.xsl
Modified: trunk/controller/inc/class.socontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item.inc.php 2012-06-27 22:34:25 UTC
(rev 9689)
+++ trunk/controller/inc/class.socontrol_item.inc.php 2012-06-28 01:55:46 UTC
(rev 9690)
@@ -83,8 +83,6 @@
if(isset($result)) {
// return the new control item ID
return
$this->db->get_last_insert_id('controller_control_item', 'id');
- // Forward this request to the update method
- //return $this->update($control_item);
}
else
{
@@ -116,7 +114,14 @@
//var_dump('UPDATE controller_control_item SET ' .
join(',', $values) . " WHERE id=$id");
$result = $this->db->query('UPDATE
controller_control_item SET ' . join(',', $values) . " WHERE id=$id",
__LINE__,__FILE__);
- return isset($result);
+ if(isset($result)) {
+ // return the new control item ID
+ return $id;
+ }
+ else
+ {
+ return 0;
+ }
}
/**
@@ -207,6 +212,12 @@
return $control_item->toArray();
}
}
+
+ function delete_option_values($control_item_id)
+ {
+ $sql = "delete from controller_control_item_option
where control_item_id=$control_item_id";
+ $this->db->query($sql);
+ }
function get_control_item_array($start = 0, $results = 1000,
$sort = null, $dir = '', $query = null, $search_option = null, $filters =
array())
{
Modified: trunk/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item.inc.php 2012-06-27 22:34:25 UTC
(rev 9689)
+++ trunk/controller/inc/class.uicontrol_item.inc.php 2012-06-28 01:55:46 UTC
(rev 9690)
@@ -198,8 +198,18 @@
public function edit()
{
$control_item_id = phpgw::get_var('id');
- $control_item = $this->so->get_single( $control_item_id
);
+ $control_item_array = array();
+ if($control_item_id > 0)
+ {
+ $control_item_array =
$this->so->get_single_with_options( $control_item_id , "return_array");
+ }
+ else
+ {
+ $control_item = new controller_control_item();
+ $control_item_array = $control_item->toArray();
+ }
+
// Sigurd: START as categories
$cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
$cats->supress_info = true;
@@ -210,11 +220,9 @@
$control_groups_array =
$this->so_control_group->get_control_group_array();
// Hack to fix display of char
- $control_item->set_what_to_do(str_replace(" ", "
",$control_item->get_what_to_do()));
- $control_item->set_how_to_do(str_replace(' ', ' ',
$control_item->get_how_to_do()));
+ $control_item_array['what_to_do'] =
str_replace(" ", " ",$control_item_array['what_to_do']);
+ $control_item_array['how_to_do'] =
str_replace(' ', ' ', $control_item_array['how_to_do']);
- $control_item_array = $control_item->toArray();
-
$data = array
(
'editable' => true,
@@ -264,16 +272,16 @@
$control_item->set_how_to_do($how_to_do_txt);
$saved_control_item_id =
$this->so->store($control_item);
+
+ $this->so->delete_option_values( $saved_control_item_id
);
+
+ if(($saved_control_item_id > 0) &
($control_item->get_type() == 'control_item_type_3' | $control_item->get_type()
== 'control_item_type_4'))
+ {
+ $option_values =
phpgw::get_var('option_values');
- if($saved_control_item_id > 0)
- {
- if($control_item->get_type() ==
'control_item_type_3' | $control_item->get_type() == 'control_item_type_4'){
- $option_values =
phpgw::get_var('option_values');
-
- foreach($option_values as
$option_value){
- $control_item_option = new
controller_control_item_option($option_value, $saved_control_item_id);
- $control_item_option_id =
$this->so_control_item_option->store( $control_item_option );
- }
+ foreach($option_values as $option_value){
+ $control_item_option = new
controller_control_item_option($option_value, $saved_control_item_id);
+ $control_item_option_id =
$this->so_control_item_option->store( $control_item_option );
}
}
Modified: trunk/controller/js/controller/ajax.js
===================================================================
--- trunk/controller/js/controller/ajax.js 2012-06-27 22:34:25 UTC (rev
9689)
+++ trunk/controller/js/controller/ajax.js 2012-06-28 01:55:46 UTC (rev
9690)
@@ -374,7 +374,7 @@
/* ========================= CONTROL OPTION
======================================== */
// Changes control type location level between building and property in
search location select box
- $(".control_item_type").click(function(){
+ $(".control_item_type").live("click", function(){
var thisBtn = $(this).find(".btn");
var thisRadio = $(this).find("input[type=radio]");
@@ -402,7 +402,7 @@
});
$("#control_item_options li .delete").live("click", function(e){
- $(this).closest("li").fadeOut();
+ $(this).closest("li").remove();
});
$("#add_control_item_list_value input[type=button]").live("click",
function(e){
Modified: trunk/controller/templates/base/control_item/control_item.xsl
===================================================================
--- trunk/controller/templates/base/control_item/control_item.xsl
2012-06-27 22:34:25 UTC (rev 9689)
+++ trunk/controller/templates/base/control_item/control_item.xsl
2012-06-28 01:55:46 UTC (rev 9690)
@@ -64,7 +64,6 @@
<xsl:variable
name="control_item_type"><xsl:value-of select="control_item/type"
/></xsl:variable>
<xsl:choose>
<xsl:when test="view">
-
<xsl:variable
name="lang_type"><xsl:value-of select="control_item/type" /></xsl:variable>
<xsl:value-of
select="php:function('lang', $lang_type)" />
@@ -80,48 +79,124 @@
<xsl:when
test="editable">
<!--
============== RADIOBUTTONS FOR CHOOSING CONTROL ITEM TYPE ============== -->
- <xsl:for-each
select="control_item/control_item_types">
-
-
<xsl:variable name="classes">
+ <xsl:choose>
+ <xsl:when
test="control_item/type = ''">
+
<xsl:for-each select="control_item/control_item_types">
+
<xsl:variable name="classes">
+
<xsl:choose>
+
<xsl:when test="position() = 1">
+
btn active
+
</xsl:when>
+
<xsl:otherwise>
+
btn
+
</xsl:otherwise>
+
</xsl:choose>
+
</xsl:variable>
+
+
<div class="control_item_type">
+
<xsl:variable name="lang_type"><xsl:value-of select="."
/></xsl:variable>
+
<xsl:variable name="current_control_item_type"><xsl:value-of select="."
/></xsl:variable>
+
+
<input class="{$classes}" type="button" value="Velg" />
+
<input type="radio" name="control_item_type"
value="{$current_control_item_type}" />
+
<xsl:value-of select="php:function('lang', $lang_type)" />
+
</div>
+
</xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+
<xsl:for-each select="control_item/control_item_types">
+
<xsl:variable name="current_type"><xsl:value-of select="."
/></xsl:variable>
+
+
<xsl:choose>
+
<xsl:when test="//control_item/type = $current_type">
+
<div class="control_item_type">
+
<xsl:variable
name="lang_type"><xsl:value-of select="." /></xsl:variable>
+
<xsl:variable
name="current_control_item_type"><xsl:value-of select="." /></xsl:variable>
+
+
<input class="btn active" type="button"
value="Velg" />
+
<input type="radio"
name="control_item_type" value="{$current_control_item_type}"
checked="checked"/>
+
<xsl:value-of
select="php:function('lang', $lang_type)" />
+
</div>
+
</xsl:when>
+
<xsl:otherwise>
+
<div class="control_item_type">
+
<xsl:variable
name="lang_type"><xsl:value-of select="." /></xsl:variable>
+
<xsl:variable
name="current_control_item_type"><xsl:value-of select="." /></xsl:variable>
+
+
<input class="btn" type="button"
value="Velg" />
+
<input type="radio"
name="control_item_type" value="{$current_control_item_type}" />
+
<xsl:value-of
select="php:function('lang', $lang_type)" />
+
</div>
+
</xsl:otherwise>
+
</xsl:choose>
+
+
</xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+ <!--
============== FORM FOR SAVING OPTION VALUES FOR LIST ============= -->
+ <xsl:choose>
+ <xsl:when
test="control_item/options_array/child::node()">
+ <div
id="add_control_item_option_panel" style="display:block;">
+
<hr />
+
<xsl:choose>
-
<xsl:when test="position() = 1">
-
btn active
+
<xsl:when test="//control_item/type = 'control_item_type_3'">
+
<h2 class="type">Nedtrekksliste</h2>
</xsl:when>
<xsl:otherwise>
-
btn
+
<h2 class="type">Radioknapper</h2>
</xsl:otherwise>
</xsl:choose>
-
</xsl:variable>
-
- <div
class="control_item_type">
-
<xsl:variable name="lang_type"><xsl:value-of select="." /></xsl:variable>
-
<xsl:variable name="current_control_item_type"><xsl:value-of select="."
/></xsl:variable>
-
<input class="{$classes}" type="button" value="Velg" />
-
<input type="radio" name="control_item_type"
value="{$current_control_item_type}" />
-
<xsl:value-of select="php:function('lang', $lang_type)" />
+
<h3>Legg til verdier som listen skal inneholde</h3>
+
+
<input type="hidden" name="control_item_id">
+
<xsl:attribute name="value"><xsl:value-of
select="control_item/id"/></xsl:attribute>
+
</input>
+
+
<ul id="control_item_options">
+
+
<xsl:for-each select="control_item/options_array">
+
<li>
+
<label>Listeverdi<span class="order_nr"><xsl:number
/></span></label>
+
<xsl:variable name="option_value"><xsl:value-of
select="option_value" /></xsl:variable>
+
<input type="text" name="option_values[]"
value="{$option_value}" />
+
<span class="btn delete">Slett</span>
+
</li>
+
</xsl:for-each>
+
</ul>
+
+
<div id="add_control_item_list_value" class="row">
+
<label>Ny listeverdi</label>
+
<input type="text" name="option_value" />
+
<input class="btn" type="button" value="Legg til" />
+
</div>
</div>
- </xsl:for-each>
-
- <!--
============== FORM FOR SAVING OPTION VALUES FOR LIST ============= -->
- <div
id="add_control_item_option_panel">
- <hr />
-
- <h2
class="type"></h2>
-
<h3>Legg til verdier som listen skal inneholde</h3>
-
- <input
type="hidden" name="control_item_id">
-
<xsl:attribute name="value"><xsl:value-of
select="control_item/id"/></xsl:attribute>
- </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <div
id="add_control_item_option_panel">
+
<hr />
- <ul
id="control_item_options"></ul>
+
<h2 class="type"></h2>
+
<h3>Legg til verdier som listen skal inneholde</h3>
+
+
<input type="hidden" name="control_item_id">
+
<xsl:attribute name="value"><xsl:value-of
select="control_item/id"/></xsl:attribute>
+
</input>
+
+
<ul id="control_item_options"></ul>
+
+
<div id="add_control_item_list_value" class="row">
+
<label>Ny listeverdi</label>
+
<input type="text" name="option_value" />
+
<input class="btn" type="button" value="Legg til" />
+
</div>
+ </div>
+ </xsl:otherwise>
+ </xsl:choose>
- <div
id="add_control_item_list_value" class="row">
-
<label>Ny listeverdi</label>
-
<input type="text" name="option_value" />
-
<input class="btn" type="button" value="Legg til" />
- </div>
- </div>
</xsl:when>
<xsl:otherwise>
<xsl:variable
name="lang_type"><xsl:value-of select="control_item/type" /></xsl:variable>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9690],
Torstein <=