Skip to content

Commit

Permalink
Initial implementation of Ajax InPlaceEditor for form widget Display …
Browse files Browse the repository at this point in the history
…field. Mridul, Thanks for your effort.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@675688 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Anil Patel committed Jul 10, 2008
1 parent 281dff1 commit bd48966
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 2 deletions.
8 changes: 8 additions & 0 deletions applications/party/webapp/partymgr/WEB-INF/controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,14 @@ under the License.
<event type="service" invoke="deleteEmploymentApp"/>
<response name="success" type="request" value="EditEmploymentApps"/>
</request-map>

<!-- Ajax Requests -->
<request-map uri="ajaxUpdatePartyGroup">
<security https="true" auth="true"/>
<event type="jsonservice" path="" invoke="updatePartyGroup"/>
<response name="success" type="none"/>
<response name="error" type="none"/>
</request-map>

<!-- Lookup request mappings -->
<request-map uri="LookupPartyName"><security https="true" auth="true"/><response name="success" type="view" value="LookupPartyName"/></request-map>
Expand Down
10 changes: 9 additions & 1 deletion applications/party/webapp/partymgr/party/PartyForms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ under the License.
<form name="ViewPartyGroup" type="single" default-map-name="lookupGroup">
<auto-fields-entity entity-name="PartyGroup" default-field-type="display"/>
<field name="partyTypeId"><ignored/></field>
<field name="groupName" id-name="groupName" widget-style="label">
<display>
<in-place-editor url="/partymgr/control/ajaxUpdatePartyGroup" cancel-control="button" saving-text="Updating..." text-between-controls=" ">
<simple-editor/>
<field-map field-name="partyId" env-name="lookupGroup.partyId"/>
</in-place-editor>
</display>
</field>
<field name="comments"><ignored/></field>
<field name="logoImageUrl"><ignored/></field>
<field name="description" title="${uiLabelMap.CommonDescription}"><display/></field>
Expand Down Expand Up @@ -631,4 +639,4 @@ under the License.
</field>
<field name="fromDate"><display/></field>
</form>
</forms>
</forms>
9 changes: 8 additions & 1 deletion framework/images/webapp/images/prototypejs/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ Ajax.InPlaceEditor = Class.create({
this.element = element = $(element);
this.prepareOptions();
this._controls = { };
this._paramValue = '';
arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
Object.extend(this.options, options || { });
if (!this.options.formId && this.element.id) {
Expand All @@ -539,6 +540,7 @@ Ajax.InPlaceEditor = Class.create({
this._boundFailureHandler = this.handleAJAXFailure.bind(this);
this._boundSubmitHandler = this.handleFormSubmission.bind(this);
this._boundWrapperHandler = this.wrapUp.bind(this);
this._boundSuccessHandler = this.updateElement.bind(this);
this.registerListeners();
},
checkForEscapeOrReturn: function(e) {
Expand Down Expand Up @@ -659,6 +661,7 @@ Ajax.InPlaceEditor = Class.create({
handleFormSubmission: function(e) {
var form = this._form;
var value = $F(this._controls.editor);
this._paramValue = value;
this.prepareSubmission();
var params = this.options.callback(form, value) || '';
if (Object.isString(params))
Expand All @@ -677,12 +680,16 @@ Ajax.InPlaceEditor = Class.create({
Object.extend(options, {
parameters: params,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
onFailure: this._boundFailureHandler,
onSuccess: this._boundSuccessHandler
});
new Ajax.Request(this.url, options);
}
if (e) Event.stop(e);
},
updateElement: function() {
$(this.element).update(this._paramValue);
},
leaveEditMode: function() {
this.element.removeClassName(this.options.savingClassName);
this.removeForm();
Expand Down
10 changes: 10 additions & 0 deletions framework/images/webapp/images/selectall.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ function toggleScreenlet(link, areaId, expandTxt, collapseTxt){
});
}

/** In Place Editor for display elements
* @param element The id of the display field
* @param url The request to be called to update the display field
* @param options Options to be passed to Ajax.InPlaceEditor
*/

function ajaxInPlaceEditDisplayField(element, url, options) {
options.htmlResponse = false;
new Ajax.InPlaceEditor($(element), url, options);
}
// ===== End of Ajax Functions ===== //

function replaceQueryParam(queryString, currentParam, newParam) {
Expand Down
88 changes: 88 additions & 0 deletions framework/widget/dtd/widget-form.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ under the License.
</xs:attributeGroup>
<xs:element name="display" substitutionGroup="AllFields">
<xs:complexType>
<xs:sequence>
<xs:element ref="in-place-editor" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attributeGroup ref="attlist.display"/>
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -1130,6 +1133,82 @@ under the License.
<xs:attributeGroup name="attlist.entity-order-by">
<xs:attribute type="xs:string" name="field-name" use="required"/>
</xs:attributeGroup>
<xs:element name="in-place-editor">
<xs:annotation>
<xs:documentation>Enables in place editon for the display field.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element ref="simple-editor"/>
</xs:choice>
<xs:element ref="field-map" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="attlist.in-place-editor"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.in-place-editor">
<xs:attribute name="url" type="xs:string" use="required"/>
<xs:attribute name="cancel-control">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="link"/>
<xs:enumeration value="button"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="cancel-text" type="xs:string"/>
<xs:attribute name="click-to-edit-text" type="xs:string"/>
<xs:attribute name="field-post-creation">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="activate"/>
<xs:enumeration value="focus"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="form-class-name" type="xs:string"/>
<xs:attribute name="form-id" type="xs:string"/>
<xs:attribute name="highlight-color" type="xs:string"/>
<xs:attribute name="highlight-end-color" type="xs:string"/>
<xs:attribute name="hover-class-name" type="xs:string"/>
<xs:attribute name="html-response">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="false"/>
<xs:enumeration value="true"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="loading-class-name" type="xs:string"/>
<xs:attribute name="loading-text" type="xs:string"/>
<xs:attribute name="ok-control">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="link"/>
<xs:enumeration value="button"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ok-text" type="xs:string"/>
<xs:attribute name="param-name" type="xs:string"/>
<xs:attribute name="saving-class-name" type="xs:string"/>
<xs:attribute name="saving-text" type="xs:string"/>
<xs:attribute name="submit-on-blur">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="false"/>
<xs:enumeration value="true"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="text-after-controls" type="xs:string"/>
<xs:attribute name="text-before-controls" type="xs:string"/>
<xs:attribute name="text-between-controls" type="xs:string"/>
</xs:attributeGroup>
<xs:element name="list-options">
<xs:annotation>
<xs:documentation>list-options will create options based on data in a list</xs:documentation>
Expand Down Expand Up @@ -1178,6 +1257,15 @@ under the License.
<xs:annotation><xs:documentation>What the user will see in the widget; defaults to the value of the key attribute.</xs:documentation></xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:element name="simple-editor">
<xs:complexType>
<xs:attributeGroup ref="attlist.simple-editor"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.simple-editor">
<xs:attribute name="rows" type="xs:positiveInteger" default="1"/>
<xs:attribute name="cols" type="xs:positiveInteger" default="40"/>
</xs:attributeGroup>
<xs:element name="sub-hyperlink">
<xs:complexType>
<xs:attributeGroup ref="attlist.sub-hyperlink"/>
Expand Down
Loading

0 comments on commit bd48966

Please sign in to comment.