From b72efe96f3af8de74ab3b16c446029a1f0d51373 Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Thu, 17 Sep 2020 16:12:46 +0200 Subject: [PATCH] Member_entity for District Responsibles: Reenable insert, edit, delete [Projekt: Entwicklung - Neon][TicketNr.: 1065331][Fehlende Aktionen bei der Tabelle Projektteam im Vertriebsprojekt] --- .../recordcontainers/db/conditionProcess.js | 6 +++-- entity/Member_entity/Member_entity.aod | 24 ++++++++++++++++++- entity/Member_entity/documentation.adoc | 13 +++++++++- .../recordtype/documentation.adoc | 1 + entity/Member_entity/grantCreateProcess.js | 0 entity/Member_entity/grantDeleteProcess.js | 5 ++++ entity/Member_entity/grantUpdateProcess.js | 5 ++++ .../recordtype.value/expression.js | 4 ++++ .../recordcontainers/jdito/contentProcess.js | 22 ++++++++++------- .../recordcontainers/jdito/onDelete.js | 16 +++++++++++++ .../recordcontainers/jdito/onInsert.js | 1 + .../recordcontainers/jdito/onUpdate.js | 1 + .../Salesproject_entity.aod | 24 +------------------ neonContext/Member/Member.aod | 7 ++++++ .../MemberFilter_view/MemberFilter_view.aod | 4 ++-- 15 files changed, 95 insertions(+), 38 deletions(-) create mode 100644 entity/Member_entity/entityfields/recordtype/documentation.adoc create mode 100644 entity/Member_entity/grantCreateProcess.js create mode 100644 entity/Member_entity/grantDeleteProcess.js create mode 100644 entity/Member_entity/grantUpdateProcess.js create mode 100644 entity/Member_entity/recordcontainers/db/recordfieldmappings/recordtype.value/expression.js create mode 100644 entity/Member_entity/recordcontainers/jdito/onDelete.js create mode 100644 entity/Member_entity/recordcontainers/jdito/onInsert.js create mode 100644 entity/Member_entity/recordcontainers/jdito/onUpdate.js diff --git a/entity/DistrictResponsible_entity/recordcontainers/db/conditionProcess.js b/entity/DistrictResponsible_entity/recordcontainers/db/conditionProcess.js index 1942674d0c..d611896490 100644 --- a/entity/DistrictResponsible_entity/recordcontainers/db/conditionProcess.js +++ b/entity/DistrictResponsible_entity/recordcontainers/db/conditionProcess.js @@ -14,9 +14,11 @@ if (districtId) else if(orgUid) { var orgDistrictIds = vars.get("$param.CollectedDistrictIds_param"); - if (orgDistrictIds){ + if (orgDistrictIds) + { orgDistrictIds = JSON.parse(orgDistrictIds); - cond.and("DISTRICTRESPONSIBLE.DISTRICT_ID", orgDistrictIds, SqlBuilder.IN()); + if (orgDistrictIds.length > 0) + cond.and("DISTRICTRESPONSIBLE.DISTRICT_ID", orgDistrictIds, SqlBuilder.IN()); } } diff --git a/entity/Member_entity/Member_entity.aod b/entity/Member_entity/Member_entity.aod index 328d826225..807190e5ff 100644 --- a/entity/Member_entity/Member_entity.aod +++ b/entity/Member_entity/Member_entity.aod @@ -4,6 +4,9 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/Member_entity/documentation.adoc</documentation> <title>${SALESPROJECT_MEMBER}</title> + <grantCreateProcess>%aditoprj%/entity/Member_entity/grantCreateProcess.js</grantCreateProcess> + <grantUpdateProcess>%aditoprj%/entity/Member_entity/grantUpdateProcess.js</grantUpdateProcess> + <grantDeleteProcess>%aditoprj%/entity/Member_entity/grantDeleteProcess.js</grantDeleteProcess> <iconId>VAADIN:FILE_SOUND</iconId> <titlePlural>${SALESPROJECT_MEMBER}</titlePlural> <recordContainer>db</recordContainer> @@ -39,7 +42,6 @@ <entityField> <name>ORGANISATION_NAME</name> <title>Company</title> - <state>READONLY</state> </entityField> <entityField> <name>ORG_ORGID</name> @@ -213,6 +215,9 @@ <name>UID</name> <documentation>%aditoprj%/entity/Member_entity/entityfields/uid/documentation.adoc</documentation> </entityField> + <entityField> + <name>recordType</name> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -333,12 +338,20 @@ <isFilterable v="true" /> <isLookupFilter v="true" /> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>recordType.value</name> + <expression>%aditoprj%/entity/Member_entity/recordcontainers/db/recordfieldmappings/recordtype.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> <jDitoRecordContainer> <name>jdito</name> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> + <isFilterable v="true" /> <contentProcess>%aditoprj%/entity/Member_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <onInsert>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onInsert.js</onInsert> + <onUpdate>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onUpdate.js</onUpdate> + <onDelete>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onDelete.js</onDelete> <recordFieldMappings> <jDitoRecordFieldMapping> <name>UID.value</name> @@ -349,6 +362,9 @@ <jDitoRecordFieldMapping> <name>CONTACT_ID.value</name> </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>CONTACT_ID.displayValue</name> + </jDitoRecordFieldMapping> <jDitoRecordFieldMapping> <name>CONTACTROLE.value</name> </jDitoRecordFieldMapping> @@ -364,6 +380,9 @@ <jDitoRecordFieldMapping> <name>MEMBERROLE.value</name> </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>MEMBERROLE.displayValue</name> + </jDitoRecordFieldMapping> <jDitoRecordFieldMapping> <name>OBJECT_ROWID.value</name> </jDitoRecordFieldMapping> @@ -400,6 +419,9 @@ <jDitoRecordFieldMapping> <name>TARGETCONTEXT.value</name> </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>recordType.value</name> + </jDitoRecordFieldMapping> </recordFieldMappings> </jDitoRecordContainer> </recordContainers> diff --git a/entity/Member_entity/documentation.adoc b/entity/Member_entity/documentation.adoc index 575b84d329..3ad972dcc8 100644 --- a/entity/Member_entity/documentation.adoc +++ b/entity/Member_entity/documentation.adoc @@ -1,3 +1,14 @@ = Member_entity -Manages the project team in the sales project and in the campaign \ No newline at end of file +Manages the project team in the sales project and in the campaign + +This entity has two recordContainers: + +* db +* jdito + +While for the must purposes the `db`-recordContainer is perfectly fine to use there is one case necessary for the `jdito`-recordContainer: + +Salesproject memebers are loaded via the ``-provider and therefor use the `jdito`-recodContainer. This recordContainer first collects the data from +the `db`-rc and then loads additional memebers of the salesprojects district. The additional members are not modifyable, while those from the +`db`-rc are. \ No newline at end of file diff --git a/entity/Member_entity/entityfields/recordtype/documentation.adoc b/entity/Member_entity/entityfields/recordtype/documentation.adoc new file mode 100644 index 0000000000..3120dc65c2 --- /dev/null +++ b/entity/Member_entity/entityfields/recordtype/documentation.adoc @@ -0,0 +1 @@ +Field to differ between records from the OBJECTMEMBER-table and additional added district-members (only in the jdito-RecordContainer) \ No newline at end of file diff --git a/entity/Member_entity/grantCreateProcess.js b/entity/Member_entity/grantCreateProcess.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/entity/Member_entity/grantDeleteProcess.js b/entity/Member_entity/grantDeleteProcess.js new file mode 100644 index 0000000000..a494c8292d --- /dev/null +++ b/entity/Member_entity/grantDeleteProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); + +var res = vars.get("$field.recordType") != "DistrictResponsible"; +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/grantUpdateProcess.js b/entity/Member_entity/grantUpdateProcess.js new file mode 100644 index 0000000000..a494c8292d --- /dev/null +++ b/entity/Member_entity/grantUpdateProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); + +var res = vars.get("$field.recordType") != "DistrictResponsible"; +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/recordcontainers/db/recordfieldmappings/recordtype.value/expression.js b/entity/Member_entity/recordcontainers/db/recordfieldmappings/recordtype.value/expression.js new file mode 100644 index 0000000000..ecce98df0c --- /dev/null +++ b/entity/Member_entity/recordcontainers/db/recordfieldmappings/recordtype.value/expression.js @@ -0,0 +1,4 @@ +import("system.result"); + +//this value only differs in the jdito recordContainer +result.string("'ObjectMember'"); \ No newline at end of file diff --git a/entity/Member_entity/recordcontainers/jdito/contentProcess.js b/entity/Member_entity/recordcontainers/jdito/contentProcess.js index b678a96f2f..e4d4225eeb 100644 --- a/entity/Member_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Member_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.translate"); import("system.result"); import("system.vars"); import("system.entities"); @@ -11,9 +12,11 @@ var memberLoadingConfig = entities.createConfigForLoadingRows() .provider("Links") .addParameter("ObjectRowId_param", vars.get("$param.ObjectRowId_param")) .addParameter("ObjectType_param", vars.get("$param.ObjectType_param")) - .fields(["#UID", "CONTACT_ID", "CONTACTROLE", "DEPARTMENT", "ICON", "IMAGE", "MEMBERROLE", "OBJECT_ROWID", "OBJECT_TYPE", + .fields(["#UID", "CONTACT_ID", "CONTACT_ID.displayValue", "CONTACTROLE", "DEPARTMENT", "ICON", "IMAGE", + "MEMBERROLE", "MEMBERROLE.displayValue", "OBJECT_ROWID", "OBJECT_TYPE", "OBJECTMEMBERID", "ORG_ORGID", "ORGANISATION_NAME", "PERSON_FIRSTNAME", "PERSON_FULL_NAME", - "PERSON_LASTNAME", "PERSON_PERSID", "PERSON_SALUTATION", "PERSON_TITLE", "POSITION", "TARGETCONTEXT"]); + "PERSON_LASTNAME", "PERSON_PERSID", "PERSON_SALUTATION", "PERSON_TITLE", "POSITION", "TARGETCONTEXT", + "recordType"]); if (idValues) { @@ -55,10 +58,11 @@ if (vars.get("$param.ObjectType_param") == "Salesproject" && vars.get("$param.Ob memberRows = memberRows.map(function(row) { - return [row["#UID"], row["OBJECTMEMBERID"], row["CONTACT_ID"], row["CONTACTROLE"], row["DEPARTMENT"], row["ICON"], row["IMAGE"], row["MEMBERROLE"], row["OBJECT_ROWID"], + return [row["#UID"], row["OBJECTMEMBERID"], row["CONTACT_ID"], row["CONTACT_ID.displayValue"], row["CONTACTROLE"], row["DEPARTMENT"], row["ICON"], + row["IMAGE"], row["MEMBERROLE"], row["MEMBERROLE.displayValue"], row["OBJECT_ROWID"], row["OBJECT_TYPE"], row["ORG_ORGID"], row["ORGANISATION_NAME"], row["PERSON_FIRSTNAME"], row["PERSON_FULL_NAME"], row["PERSON_LASTNAME"], row["PERSON_PERSID"], row["PERSON_SALUTATION"], row["PERSON_TITLE"], - row["POSITION"], row["TARGETCONTEXT"]]; + row["POSITION"], row["TARGETCONTEXT"], row["recordType"]]; }); var responsibleUids = []; @@ -74,7 +78,6 @@ var loadingConfPers = entities.createConfigForLoadingRows() "FIRSTNAME", "LASTNAME", "SALUTATION", "TITLE"]); var persRows = entities.getRows(loadingConfPers); -var counter = 0; persRows = persRows.map(function(row){ return [row["SALUTATION"], row["TITLE"], row["FIRSTNAME"], row["LASTNAME"], @@ -83,17 +86,19 @@ persRows = persRows.map(function(row){ }); -districtRows.forEach(function(row){ +districtRows.forEach(function(row, counter){ memberRows.push( [row[0], null, row[3], + row[4], persRows[counter][6], row[7], "VAADIN:GLOBE", "TEXT:" + row[4].substring(row[4].indexOf(" ", 0)+1, row[4].length), "MEMBERROLEDISTRICTRESPONSIBLE", + translate.text("District Responsible"), vars.get("$param.ObjectRowId_param"), vars.get("$param.ObjectType_param"), persRows[counter][5], @@ -105,10 +110,9 @@ districtRows.forEach(function(row){ persRows[counter][0], persRows[counter][1], persRows[counter][7], - null + null, + "DistrictResponsible" ]); - - counter++; }); result.object(memberRows); \ No newline at end of file diff --git a/entity/Member_entity/recordcontainers/jdito/onDelete.js b/entity/Member_entity/recordcontainers/jdito/onDelete.js new file mode 100644 index 0000000000..91caa64d3c --- /dev/null +++ b/entity/Member_entity/recordcontainers/jdito/onDelete.js @@ -0,0 +1,16 @@ +import("system.vars"); +import("system.entities"); + +//While there is no need to implement the insert or update process the delete process needs to be specified because the +//contexts viewmodeProvider for the editView only affect insert and update (delete has no view associated) +//let's do the db-record container the job to remove the record (additional district records can never be removed): +var rowData = vars.get("$local.rowdata"); +var memberId = rowData["OBJECTMEMBERID.value"]; +if (memberId) +{ + var config = entities.createConfigForDeletingRows().entity("Member_entity").uid(memberId); + entities.deleteRow(config); +} +else + throw new Error("Member_entity: Could not delete member entity because the given OBJECTMEMBERID was empty."); + diff --git a/entity/Member_entity/recordcontainers/jdito/onInsert.js b/entity/Member_entity/recordcontainers/jdito/onInsert.js new file mode 100644 index 0000000000..d86d21c988 --- /dev/null +++ b/entity/Member_entity/recordcontainers/jdito/onInsert.js @@ -0,0 +1 @@ +//No insert code, because it is done in via the contexts viewmodeProvider for the editView \ No newline at end of file diff --git a/entity/Member_entity/recordcontainers/jdito/onUpdate.js b/entity/Member_entity/recordcontainers/jdito/onUpdate.js new file mode 100644 index 0000000000..1e04d32962 --- /dev/null +++ b/entity/Member_entity/recordcontainers/jdito/onUpdate.js @@ -0,0 +1 @@ +//No update code, because it is done in via the contexts viewmodeProvider for the editView \ No newline at end of file diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index d80df356a7..d9710bbf19 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -257,7 +257,7 @@ <dependency> <name>dependency</name> <entityName>Member_entity</entityName> - <fieldName>Links</fieldName> + <fieldName>WithDistrictResponsibles</fieldName> </dependency> <children> <entityParameter> @@ -672,28 +672,6 @@ </entityParameter> </children> </entityConsumer> - <entityConsumer> - <name>ClassificationGroups</name> - <dependency> - <name>dependency</name> - <entityName>ClassificationGroupAnalyses_entity</entityName> - <fieldName>GroupAnalyses</fieldName> - </dependency> - <children> - <entityParameter> - <name>ClassificationType_param</name> - <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/classificationgroups/children/classificationtype_param/valueProcess.js</valueProcess> - </entityParameter> - <entityParameter> - <name>ObjectRowid_param</name> - <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/classificationgroups/children/objectrowid_param/valueProcess.js</valueProcess> - </entityParameter> - <entityParameter> - <name>ObjectType_param</name> - <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/classificationgroups/children/objecttype_param/valueProcess.js</valueProcess> - </entityParameter> - </children> - </entityConsumer> <entityField> <name>PHASEINFO</name> <title>phase information</title> diff --git a/neonContext/Member/Member.aod b/neonContext/Member/Member.aod index f1747c11e2..35fc63e302 100644 --- a/neonContext/Member/Member.aod +++ b/neonContext/Member/Member.aod @@ -19,4 +19,11 @@ <view>MemberDrawer_view</view> </neonViewReference> </references> + <viewmodeProvider> + <staticContentEntry> + <name>editView</name> + <key>editView</key> + <value>Links</value> + </staticContentEntry> + </viewmodeProvider> </neonContext> diff --git a/neonView/MemberFilter_view/MemberFilter_view.aod b/neonView/MemberFilter_view/MemberFilter_view.aod index c432d26441..1d4faccbdb 100644 --- a/neonView/MemberFilter_view/MemberFilter_view.aod +++ b/neonView/MemberFilter_view/MemberFilter_view.aod @@ -23,7 +23,7 @@ </neonTableColumn> <neonTableColumn> <name>59e6aea1-9752-48b5-9d91-43edd0c1d670</name> - <entityField>PERSON_FULL_NAME</entityField> + <entityField>CONTACT_ID</entityField> </neonTableColumn> <neonTableColumn> <name>27e658bc-c134-4fef-a3a5-b172852d606e</name> @@ -57,7 +57,7 @@ </neonTreeTableColumn> <neonTreeTableColumn> <name>d84b10a1-593a-4c2f-ba35-4fb80c362850</name> - <entityField>PERSON_FULL_NAME</entityField> + <entityField>CONTACT_ID</entityField> </neonTreeTableColumn> <neonTreeTableColumn> <name>22eb0efc-61b3-48fe-989d-2dd4e70ea780</name> -- GitLab