summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortof <>2007-10-18 09:22:46 +0000
committertof <>2007-10-18 09:22:46 +0000
commit8bebf49fbfb92f039f56cb22b759d8e84ef19799 (patch)
tree6be47ae5ac609d31989eb1dad739e7823fd08ae2
parent56615eb9b1cef2e707f1163c74aaecc7e94ae549 (diff)
Fixed #722 - Add Read only capabilities to TInPlaceTextBox
-rw-r--r--.gitattributes1
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js14
-rw-r--r--framework/Web/UI/ActiveControls/TInPlaceTextBox.php24
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket722.page6
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket722.php30
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket722TestCase.php29
7 files changed, 101 insertions, 4 deletions
diff --git a/.gitattributes b/.gitattributes
index 71cab846..e4e7fdb3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2981,6 +2981,7 @@ tests/FunctionalTests/tickets/protected/pages/Ticket708.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket719.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket72.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket72.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket722.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket93.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket93.php -text
tests/FunctionalTests/tickets/protected/pages/ToggleTest.page -text
diff --git a/HISTORY b/HISTORY
index 8f6507cc..29982ffc 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3,6 +3,7 @@ Version 3.1.2 To be released
BUG: Ticket#719 - TAutoCompleter should not trigger Validation if CausesValidation=False (Christophe)
CHG: Changed TConditional so that the controls in its template behave like they are in its parent (Qiang)
CHG: Active Record many-to-many relationship change from self::HAS_MANY to self::MANY_TO_MANY (Wei)
+ENH: Ticket#722 - Add Read Only capabilities to TInPlaceTextBox (Christophe)
ENH: Active Record supports multiple foreign references of the same table (Wei)
ENH: Added TDbCommand.queryColumn() (Qiang)
ENH: Active Record now supports implicitly declared related properties (Qiang)
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
index f8b8b412..8f480d3d 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
@@ -6,6 +6,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
this.isSaving = false;
this.isEditing = false;
this.editField = null;
+ this.readOnly = options.ReadOnly;
this.options = Object.extend(
{
@@ -36,7 +37,7 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
*/
enterEditMode : function(evt)
{
- if (this.isSaving || this.isEditing) return;
+ if (this.isSaving || this.isEditing || this.readOnly) return;
this.isEditing = true;
this.onEnterEditMode();
this.createEditorInput();
@@ -281,5 +282,14 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
textbox.exitEditMode(null);
}
}
- }
+ },
+
+ setReadOnly : function(id, value)
+ {
+ var textbox = Prado.WebUI.TInPlaceTextBox.textboxes[id];
+ if (textbox)
+ {
+ textbox.readOnly=value;
+ }
+ },
}); \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
index 4c75aa2b..4bc70149 100644
--- a/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
+++ b/framework/Web/UI/ActiveControls/TInPlaceTextBox.php
@@ -35,7 +35,10 @@ Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
* After the callback request returns sucessfully, the textbox is enabled.
* If the {@link setAutoHideTextBox AutoHideTextBox} property is true, then
* the textbox will be hidden and the label is then shown.
- *
+ *
+ * Since 3.1.2, you can set the {@link setReadOnly ReadOnly} property to make
+ * the control not editable. This property can be also changed on callback
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.ActiveControls
@@ -141,6 +144,21 @@ class TInPlaceTextBox extends TActiveTextBox
$client->update($this->getLabelClientID(), $value);
$client->setValue($this, $value);
}
+ }
+
+ /**
+ * Update ClientSide Readonly property
+ * @param boolean value
+ * @since 3.1.2
+ */
+ public function setReadOnly ($value)
+ {
+ $value=TPropertyValue::ensureBoolean($value);
+ TTextBox::setReadOnly($value);
+ if ($this->getActiveControl()->canUpdateClientSide())
+ {
+ $this->callClientFunction('setReadOnly', $value);
+ }
}
/**
@@ -213,7 +231,9 @@ class TInPlaceTextBox extends TActiveTextBox
}
if($this->hasEventHandler('OnLoadingText'))
- $options['LoadTextOnEdit'] = true;
+ $options['LoadTextOnEdit'] = true;
+
+ $options['ReadOnly']=$this->getReadOnly();
return $options;
}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket722.page b/tests/FunctionalTests/tickets/protected/pages/Ticket722.page
new file mode 100644
index 00000000..6acd9f24
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket722.page
@@ -0,0 +1,6 @@
+<com:TContent ID="Content">
+<span id="label">Click to edit ==></span>
+<com:TInPlaceTextBox id="InPlaceTextBox" Text="Editable Text" ReadOnly="false" onTextChanged="onTextChanged"/>
+<com:TActiveButton Text="Change to Read Only" OnClick="ChangeState"/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket722.php b/tests/FunctionalTests/tickets/protected/pages/Ticket722.php
new file mode 100644
index 00000000..91759fb0
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket722.php
@@ -0,0 +1,30 @@
+<?php
+
+prado::using ('System.Web.UI.ActiveControls.*');
+
+class Ticket722 extends TPage
+{
+ public function changeState ($sender, $param)
+ {
+ $state=$this->InPlaceTextBox->getReadOnly();
+ $this->InPlaceTextBox->setReadOnly(!$state);
+ $sender->setText($state?"Change to Read Only":"Change to Editable");
+ $this->InPlaceTextBox->setText($state?$this->getText():$this->getText().' [Read Only]');
+ }
+
+ public function onTextChanged ($sender, $param)
+ {
+ $this->setText($sender->getText());
+ }
+
+ public function setText ($value)
+ {
+ $this->setViewState('text', $value, "Editable Text");
+ }
+
+ public function getText ()
+ {
+ return $this->getViewState('text', "Editable Text");
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket722TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket722TestCase.php
new file mode 100644
index 00000000..68a0282c
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket722TestCase.php
@@ -0,0 +1,29 @@
+<?php
+class Ticket722TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base = 'ctl0_Content_';
+ $this->open('tickets/index.php?page=Ticket722');
+ $this->assertTitle("Verifying Ticket 722");
+
+ $this->assertText($base.'InPlaceTextBox__label', 'Editable Text');
+ $this->click($base.'InPlaceTextBox__label');
+ $this->pause(800);
+ $this->assertVisible($base.'InPlaceTextBox');
+ $this->type($base.'InPlaceTextBox',"Prado");
+ $this->fireEvent($base.'InPlaceTextBox', 'blur'); // Release textbox
+ $this->pause(800);
+ $this->assertNotVisible($base.'InPlaceTextBox');
+ $this->assertText($base.'InPlaceTextBox__label', 'Prado');
+ $this->click($base.'ctl0');
+ $this->pause(800);
+ $this->assertText($base.'InPlaceTextBox__label', 'Prado [Read Only]');
+ $this->click($base.'InPlaceTextBox__label');
+ $this->pause(800);
+ $this->assertNotVisible($base.'InPlaceTextBox');
+
+ }
+
+}
+?> \ No newline at end of file