details: https://code.openbravo.com/erp/devel/pi/rev/6b684b7d61d6
changeset: 20700:6b684b7d61d6
user: David Baz Fayos <david.baz <at> openbravo.com>
date: Thu Jul 04 00:10:53 2013 +0200
summary: Fixed issue 24197: Added capabilities to refresh the form
after add or remove a note
diffstat:
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
| 13 +
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
| 74 +++++++++-
2 files changed, 80 insertions(+), 7 deletions(-)
diffs (180 lines):
diff -r 8e9765fdae56 -r 6b684b7d61d6
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
---
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
Wed Jul 03 17:29:21 2013 +0530
+++
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
Thu Jul 04 00:10:53 2013 +0200
@@ -1613,6 +1613,19 @@
<!--F1608458F2A84B81812F0A5C8B3E8633-->
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--F1608458F2A84B81812F0A5C8B3E8633--></AD_MESSAGE>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--><AD_MESSAGE>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1-->
<AD_MESSAGE_ID><![CDATA[F6836B6ADBBD43EBB08126F0E1482CD1]]></AD_MESSAGE_ID>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1-->
<VALUE><![CDATA[OBUIAPP_SaveChangesBeforeAddRemoveNote]]></VALUE>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--> <MSGTEXT><![CDATA[There are changes
in the current record.
+Please save or discard them before add or remove a note.]]></MSGTEXT>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1-->
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1-->
<ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--F6836B6ADBBD43EBB08126F0E1482CD1--></AD_MESSAGE>
+
<!--FAF1675F98A248C39469E132D1B0E2DE--><AD_MESSAGE>
<!--FAF1675F98A248C39469E132D1B0E2DE-->
<AD_MESSAGE_ID><![CDATA[FAF1675F98A248C39469E132D1B0E2DE]]></AD_MESSAGE_ID>
<!--FAF1675F98A248C39469E132D1B0E2DE-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 8e9765fdae56 -r 6b684b7d61d6
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
Wed Jul 03 17:29:21 2013 +0530
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-notes.js
Thu Jul 04 00:10:53 2013 +0200
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
* All Rights Reserved.
* Contributor(s): Valery Lezhebokov.
************************************************************************
@@ -118,6 +118,8 @@
recordId: null,
+ view: null,
+ //Set in initWidget
layoutMargin: 0,
membersMargin: 10,
@@ -132,10 +134,57 @@
noteListGrid: null,
+ refreshFormWithEntities: [],
+ // * Entities that will force a refresh event when a new note be added or
removed
+ // * If the string 'all' is found in the array, it will refresh in all cases
+ // * Entities can be added to the list by third parties by doing:
isc.OBNoteLayout.getPrototype().refreshFormWithEntities.push(theEntityName);
+ // Where 'theEntityName' is the string with the name of the entity
+ shouldRefreshAfterAddOrRemove: function () {
+ var i;
+ for (i = 0; i < this.refreshFormWithEntities.length; i++) {
+ if (this.refreshFormWithEntities[i].toLowerCase() === 'all' ||
this.refreshFormWithEntities[i] === this.entity) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ addOrRemoveCancelLogic: function () {
+ if (this.shouldRefreshAfterAddOrRemove() && this.view &&
this.view.viewForm && this.view.viewGrid && //
+ (this.view.viewForm.hasChanged || (this.view.isEditingGrid &&
this.view.viewGrid.getEditForm().hasChanged))) { //
+ // If should refresh after save, and there is already changes made in
the form,
+ // notice it and cancel the note save action to avoid possible collisions
+ isc.warn(OB.I18N.getLabel('OBUIAPP_SaveChangesBeforeAddRemoveNote'),
function () {
+ return true;
+ }, {
+ icon: '[SKINIMG]Dialog/error.png',
+ title: OB.I18N.getLabel('OBUIAPP_Error')
+ });
+ return false;
+ } else {
+ return true;
+ }
+ },
+
+ addOrRemoveNoteCallback: function (dsResponse, data, dsRequest) {
+ if (this.shouldRefreshAfterAddOrRemove()) {
+ this.view.refresh();
+ }
+ },
+
/**
* Saves the note to the DB.
*/
saveNote: function () {
+ var me = this;
+ var addNoteCallback = function (dsResponse, data, dsRequest) {
+ me.addOrRemoveNoteCallback(dsResponse, data, dsRequest);
+ };
+
+ if (!this.addOrRemoveCancelLogic()) {
+ return false;
+ }
+
var note = this.noteDynamicForm.getField('noteOBTextAreaItem').getValue();
if (!note) {
@@ -154,7 +203,7 @@
'table': this.getForm().view.standardProperties.inpTableId,
'record': this.getForm().view.viewGrid.getSelectedRecord().id,
'note': note
- });
+ }, addNoteCallback);
// clean text area
this.noteDynamicForm.getItem('noteOBTextAreaItem').clearValue();
@@ -168,13 +217,22 @@
* Deletes the note from the DB.
*/
deleteNote: function ( /* note id to delete */ id) {
+ var me = this;
+ var removeNoteCallback = function (dsResponse, data, dsRequest) {
+ me.addOrRemoveNoteCallback(dsResponse, data, dsRequest);
+ };
+
+ if (!this.addOrRemoveCancelLogic()) {
+ return false;
+ }
+
var noteDS = this.getNoteDataSource();
var noteSection = this.parentElement.noteSection;
isc.confirm(OB.I18N.getLabel('OBUIAPP_ConfirmRemoveNote'), function
(clickedOK) {
if (clickedOK) {
noteDS.removeData({
'id': id
- });
+ }, removeNoteCallback);
noteSection.setNoteCount(noteSection.noteCount - 1);
}
}, {
@@ -195,6 +253,9 @@
initWidget: function () {
this.Super('initWidget', arguments);
+ var view = this.getForm().view;
+ this.view = view;
+
var hLayout = isc.HLayout.create({
width: '50%',
height: '100%',
@@ -224,7 +285,7 @@
},
isDisabled: function () {
this.Super('isDisabled', arguments);
- if (OB.PropertyStore.get("DisableNotesForReadOnlyTabs",
this.windowId) === 'Y' && this.layout.getForm().view.readOnly === true) {
+ if (OB.PropertyStore.get("DisableNotesForReadOnlyTabs",
this.windowId) === 'Y' && view.readOnly === true) {
this.readOnly = true;
this.canEdit = false;
}
@@ -310,7 +371,6 @@
criteria.criteria = [];
}
- var view = this.layout.getForm().view;
if (view && view.viewGrid.getSelectedRecord()) {
criteria.criteria.push({
fieldName: 'table',
@@ -340,7 +400,7 @@
// show delete link if the note was created by
// the current user
- if (record.createdBy === OB.User.id) {
+ if (record && record.createdBy === OB.User.id) {
value = value + ' <nobr><span class="OBNoteListGridDelete" ><a
class="OBNoteListGridDelete" href="#" onclick="' + this.layout.ID +
'.deleteNote(\'' + record.id + '\')">[ ' + OB.I18N.getLabel('OBUIAPP_delete') +
' ]</a></span></nobr>';
}
return value;
@@ -351,7 +411,7 @@
return this.baseStyle;
}
- if (record.createdBy === OB.User.id) {
+ if (record && record.createdBy === OB.User.id) {
return 'OBNoteListGridCurrentUserNoteCell';
} else {
return 'OBNoteListGridOtherUserNoteCell';
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits