@universis/accommodation 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/config/models/AccommodationInscriptionModeTag.json +2 -2
  2. package/dist/config/models/{Accommodation.json → AccommodationPlace.json} +55 -8
  3. package/dist/config/models/AccommodationPlaceLocale.json +86 -0
  4. package/dist/config/models/AccommodationRequestEffectiveStatusType.json +3 -3
  5. package/dist/config/models/AccommodationRoom.json +43 -4
  6. package/dist/config/models/AccommodationRoomLocale.json +86 -0
  7. package/dist/config/scope.access.js +0 -10
  8. package/dist/config/scope.access.js.map +1 -1
  9. package/dist/listeners/OnActionCompleteListener.js +2 -2
  10. package/dist/listeners/OnActionCompleteListener.js.map +1 -1
  11. package/dist/listeners/SendEmailAfterCardStatusChangeListener.js +8 -8
  12. package/dist/listeners/SendEmailAfterCardStatusChangeListener.js.map +1 -1
  13. package/dist/listeners/ValidateActionListener.js +4 -4
  14. package/dist/listeners/ValidateActionListener.js.map +1 -1
  15. package/dist/locales/el.json +3 -0
  16. package/dist/locales/en.json +3 -0
  17. package/dist/models/{Accommodation.js → AccommodationPlace.js} +1 -1
  18. package/dist/models/AccommodationPlace.js.map +1 -0
  19. package/package.json +1 -1
  20. package/src/config/models/AccommodationInscriptionModeTag.json +2 -2
  21. package/src/config/models/{Accommodation.json → AccommodationPlace.json} +55 -8
  22. package/src/config/models/AccommodationPlaceLocale.json +86 -0
  23. package/src/config/models/AccommodationRequestEffectiveStatusType.json +3 -3
  24. package/src/config/models/AccommodationRoom.json +43 -4
  25. package/src/config/models/AccommodationRoomLocale.json +86 -0
  26. package/src/config/scope.access.js +0 -10
  27. package/src/listeners/OnActionCompleteListener.js +2 -2
  28. package/src/listeners/SendEmailAfterCardStatusChangeListener.js +8 -8
  29. package/src/listeners/ValidateActionListener.js +4 -4
  30. package/src/locales/el.json +3 -0
  31. package/src/locales/en.json +3 -0
  32. package/dist/models/Accommodation.js.map +0 -1
  33. /package/dist/templates/{mail-after-dining-request-status-change → mail-after-accommodation-request-status-change}/html.ejs +0 -0
  34. /package/src/models/{Accommodation.js → AccommodationPlace.js} +0 -0
  35. /package/src/templates/{mail-after-dining-request-status-change → mail-after-accommodation-request-status-change}/html.ejs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ValidateActionListener.js","names":["_common","require","_errors","_data","beforeSaveAsync","event","runAllRules","user","model","context","target","convert","studentId","student","action","eventHasConsent","Object","prototype","hasOwnProperty","call","actionID","id","where","equal","select","getItem","DataError","isMe","is","isActive","HttpForbiddenError","accommodationRequestEvent","silent","value","state","translateService","application","getStrategy","TranslateService","translate","studentConsent","category","__","actionStatus","removeAllInformationExceptStatus","alternateName","previous","agent","militaryActive","applyRulesForPrerequisites","militarySchool","studentHouseResident","sameDegreeHolder","foreignScholarStudent","foreignStudentOrChildOfGreekExpatriate","applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate","studentReceivesUnemploymentBenefit","institutionOrClubLocationSameAsStudentPermanentResidence","studentSubmitsTaxReportInGreece","nullifyFamilyInformation","nullifyGuardianFinancialInformation","nullifySpouseFinancialInformation","nullifyStudentFinancialInformation","maritalStatus","noOfChildren","guardianType","institutionOrClubLocationSameAsGuardianPermanentResidence","guardianNoOfChildren","numberOfStudyingSiblings","nullifyPersonalInformation","studentAfm","studentDisabledPerson","studentOrphan","institutionOrClubLocationSameAsGuadianPermanentResidence","studentGuardianTotalIncome","studentGuardianAfm","studentGuardianReceivesUnemploymentBenefit","studentGuardianSubmitsTaxReportInGreece","studentSpouseTotalIncome","studentSpouseAfm","studentSpouseReceivesUnemploymentBenefit","studentTotalIncome","lessThan25yrs","allInformationSubmittedIsTrueConfirmation","afterSaveAsync","beforeRemoveAsync","afterRemoveAsync","beforeSave","callback","then","catch","err","afterSave","afterRemove","beforeRemove"],"sources":["../../src/listeners/ValidateActionListener.js"],"sourcesContent":["import {DataError} from \"@themost/common\";\nimport { HttpForbiddenError } from '@themost/common/errors';\nimport { DataObjectState, DataModel } from \"@themost/data\";\n// eslint-disable-next-line no-unused-vars\nasync function beforeSaveAsync(event) {\n\n let runAllRules = false;\n const user = event.model.context.user;\n const target = event.model.convert(event.target);\n const context = event.model.context;\n\n let studentId = target.student;\n let action;\n let eventHasConsent;\n\n if (!Object.prototype.hasOwnProperty.call(target,'student')) {\n const actionID = event.target || event.target.id;\n action = await context.model('AccommodationRequestAction')\n .where('id')\n .equal(actionID)\n .select('student','accommodationRequestEvent/hasConsent as hasConsent','studentConsent')\n .getItem();\n studentId = action.student;\n }\n if (!studentId) {\n throw new DataError('E_STUDENT', 'The student cannot be empty at this context.');\n }\n\n const student = event.model.context.model('Student').convert(studentId);\n \n const isMe = await student.is(':me');\n if (isMe) {\n const isActive = await student.is(':active');\n if (!isActive) {\n throw new HttpForbiddenError();\n }\n\n const accommodationRequestEvent = target.accommodationRequestEvent || target.accommodationRequestEvent.id;\n eventHasConsent = await context.model('AccommodationRequestEvent')\n .where('id')\n .equal(accommodationRequestEvent)\n .select('hasConsent')\n .silent()\n .value();\n }\n\n if (event.state === 2) {\n if (isMe === true) {\n //check studentConsent\n if (event.target && eventHasConsent === true && Object.prototype.hasOwnProperty.call(target, 'studentConsent') === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The application cannot be saved without consent about personal data.'), null, 'AccommodationRequestAction', 'studentConsent');\n } else if (event.target && eventHasConsent === true && Object.prototype.hasOwnProperty.call(target, 'studentConsent') === true && target.studentConsent === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The application cannot be saved without consent about personal data.'), null, 'AccommodationRequestAction', 'studentConsent');\n }\n //check category\n if (target && (Object.prototype.hasOwnProperty.call(target, 'category') && (target.category == null))) {\n throw new HttpForbiddenError(\n context.__(\n 'The accommodation request creation failed because no request category has been set.'\n )\n );\n }\n\n }\n\n //UPDATE\n //Load current status\n const actionStatus = await event.model.where('id').equal(event.target.id).select('actionStatus/alternateName').value();\n \n //Action is not submitted yet. Run again all rules\n if (actionStatus === 'PotentialActionStatus') {\n runAllRules = true;\n }\n else if (actionStatus === 'ActiveActionStatus' || actionStatus === 'CompletedActionStatus'){\n //accommodation request already submitted. Do not allow to update any property \n removeAllInformationExceptStatus(event.target);\n }\n else if (actionStatus === 'CancelledActionStatus' && event.target.actionStatus && event.target.actionStatus.alternateName !== actionStatus && event.target.actionStatus.alternateName != 'ActiveActionStatus') {\n //accommodation request already cancelled. \n throw new DataError('E_VALUE', 'Cannot update cancelled action.', null, 'AccommodationRequestAction', 'actionStatus');\n }\n // allow agent to change request's status when target request status = 'ActiveActionStatus' example: to reconsider a cancelled request\n else if (actionStatus === 'CancelledActionStatus' && event.target.actionStatus && event.target.actionStatus.alternateName !== actionStatus && event.target.actionStatus.alternateName === 'ActiveActionStatus') {\n let model = event.target;\n // set loggedIn user as request's agent\n if (event.previous.agent != user.id) {\n model.agent = user.id;\n }\n }\n }\n\n else if (event.state === 1) {\n // check studentConsent\n if (isMe === true && eventHasConsent === true) {\n if (Object.prototype.hasOwnProperty.call(target, 'studentConsent') === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The application cannot be saved without consent about personal data.'), null, 'AccommodationRequestAction', 'studentConsent');\n } else if (eventHasConsent === true && target.studentConsent === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The application cannot be saved without consent about personal data.'), null, 'AccommodationRequestAction', 'studentConsent');\n }\n }\n\n if (target && (Object.prototype.hasOwnProperty.call(target, 'category') === false || (target.category == null))) {\n throw new HttpForbiddenError(\n context.__(\n 'The accommodation request creation failed because no request category has been set.'\n )\n );\n }\n\n runAllRules = true;\n }\n \n \n\n if (runAllRules){\n // set nullable fields to null when they don't need to have a value\n let model = event.target;\n \n if (Object.prototype.hasOwnProperty.call(model, 'militaryActive')) {\n if (model.militaryActive == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'militarySchool')) {\n if (model.militarySchool == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n \n if (Object.prototype.hasOwnProperty.call(model, 'studentHouseResident')) {\n if (model.studentHouseResident == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n \n if (Object.prototype.hasOwnProperty.call(model, 'sameDegreeHolder')) {\n if (model.sameDegreeHolder == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'foreignScholarStudent')) {\n if (model.foreignScholarStudent == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n\n if (Object.prototype.hasOwnProperty.call(model, 'foreignStudentOrChildOfGreekExpatriate')) {\n if (model.foreignStudentOrChildOfGreekExpatriate == true) { \n applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'studentReceivesUnemploymentBenefit')) {\n if (model.studentReceivesUnemploymentBenefit == true){\n model.institutionOrClubLocationSameAsStudentPermanentResidence = null;\n model.studentSubmitsTaxReportInGreece = null;\n nullifyFamilyInformation(model);\n nullifyGuardianFinancialInformation(model);\n nullifySpouseFinancialInformation(model);\n nullifyStudentFinancialInformation(model);\n return;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'maritalStatus')) {\n if (model.maritalStatus && model.maritalStatus.alternateName == 'single') {\n model.noOfChildren = null;\n nullifySpouseFinancialInformation(model);\n if (model.guardianType.alternateName == 'nobody') {\n model.institutionOrClubLocationSameAsGuardianPermanentResidence = null;\n model.guardianNoOfChildren = null;\n model.numberOfStudyingSiblings = null;\n nullifyGuardianFinancialInformation(model);\n }\n }\n else {\n model.guardianType = null;\n model.institutionOrClubLocationSameAsGuardianPermanentResidence = null;\n model.guardianNoOfChildren = null;\n model.numberOfStudyingSiblings = null;\n nullifyGuardianFinancialInformation(model);\n if (model.maritalStatus && model.maritalStatus.alternateName != 'married') {\n nullifySpouseFinancialInformation(model);\n }\n }\n }\n }\n \n\n} \n\nfunction applyRulesForPrerequisites(model) {\n //nullify all other properties except foreignScholarStudent, inscriptionModeTag, lessThan25yrs and allInformationSubmittedIsTrueConfirmation\n nullifyPersonalInformation(model);\n nullifyFamilyInformation(model);\n nullifyGuardianFinancialInformation(model); \n nullifySpouseFinancialInformation(model);\n nullifyStudentFinancialInformation(model); \n}\n\nfunction applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate(model) {\n model.studentAfm = null;\n}\n\nfunction nullifyPersonalInformation(model){\n model.foreignStudentOrChildOfGreekExpatriate = null;\n model.studentDisabledPerson = null;\n model.studentOrphan = null;\n model.studentReceivesUnemploymentBenefit = null;\n model.studentSubmitsTaxReportInGreece = null;\n model.institutionOrClubLocationSameAsStudentPermanentResidence = null;\n}\n\nfunction nullifyFamilyInformation(model){\n model.noOfChildren = null;\n model.maritalStatus = null;\n model.numberOfStudyingSiblings = null;\n model.guardianNoOfChildren = null;\n model.guardianType = null;\n model.institutionOrClubLocationSameAsGuadianPermanentResidence = null;\n}\n\nfunction nullifyGuardianFinancialInformation(model){\n model.studentGuardianTotalIncome = null;\n model.studentGuardianAfm = null;\n model.studentGuardianReceivesUnemploymentBenefit = null;\n model.studentGuardianSubmitsTaxReportInGreece = null;\n}\n\nfunction nullifySpouseFinancialInformation(model){\n model.studentSpouseTotalIncome = null;\n model.studentSpouseAfm = null;\n model.studentSpouseReceivesUnemploymentBenefit = null;\n}\n\nfunction nullifyStudentFinancialInformation(model){\n model.studentTotalIncome = null;\n model.studentAfm = null;\n}\n\nfunction removeAllInformationExceptStatus(model){\n delete model.militaryActive;\n delete model.militarySchool;\n delete model.studentHouseResident;\n delete model.sameDegreeHolder;\n delete model.foreignScholarStudent;\n delete model.lessThan25yrs;\n delete model.institutionOrClubLocationSameAsStudentPermanentResidence;\n delete model.studentDisabledPerson;\n delete model.studentOrphan;\n delete model.numberOfStudyingSiblings ;\n delete model.maritalStatus;\n delete model.noOfChildren;\n delete model.guardianType;\n delete model.institutionOrClubLocationSameAsGuadianPermanentResidence;\n delete model.guardianNoOfChildren;\n delete model.studentReceivesUnemploymentBenefit;\n delete model.studentSubmitsTaxReportInGreece;\n delete model.studentGuardianSubmitsTaxReportInGreece;\n delete model.studentAfm;\n delete model.studentTotalIncome;\n delete model.studentSpouseReceivesUnemploymentBenefit;\n delete model.studentSpouseAfm;\n delete model.studentSpouseTotalIncome;\n delete model.studentGuardianReceivesUnemploymentBenefit ;\n delete model.foreignStudentOrChildOfGreekExpatriate;\n delete model.studentGuardianAfm;\n delete model.studentGuardianTotalIncome;\n delete model.allInformationSubmittedIsTrueConfirmation;\n}\n\nasync function afterSaveAsync(event) {\n // on insert\n\n}\n\nasync function beforeRemoveAsync(event) {\n \n}\n\nasync function afterRemoveAsync(event) {\n const context = event.model.context;\n // try to find if a preference exists for that event\n\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function beforeSave(event, callback) {\n return beforeSaveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function afterSave(event, callback) {\n return afterSaveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function afterRemove(event, callback) {\n return afterRemoveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function beforeRemove(event, callback) {\n return beforeRemoveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n"],"mappings":"+MAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA;AACA,e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,EAAE;EACrB,CAAC,CAAC,CAACE,KAAK,CAAC,CAACC,GAAG,KAAK;IACd,OAAOH,QAAQ,CAACG,GAAG,CAAC;EACxB,CAAC,CAAC;AACN;;;AAGA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAACzF,KAAK,EAAEmF,QAAQ,EAAE;EAC1C,OAAOH,iBAAiB,CAAChF,KAAK,CAAC,CAACoF,IAAI,CAAC,MAAM;IACvC,OAAOD,QAAQ,EAAE;EACrB,CAAC,CAAC,CAACE,KAAK,CAAC,CAACC,GAAG,KAAK;IACd,OAAOH,QAAQ,CAACG,GAAG,CAAC;EACxB,CAAC,CAAC;AACN"}
1
+ {"version":3,"file":"ValidateActionListener.js","names":["_common","require","_errors","_data","beforeSaveAsync","event","runAllRules","user","model","context","target","convert","studentId","student","action","eventHasConsent","Object","prototype","hasOwnProperty","call","actionID","id","where","equal","select","getItem","DataError","isMe","is","isActive","HttpForbiddenError","accommodationRequestEvent","silent","value","state","translateService","application","getStrategy","TranslateService","translate","studentConsent","category","__","actionStatus","removeAllInformationExceptStatus","alternateName","previous","agent","militaryActive","applyRulesForPrerequisites","militarySchool","studentHouseResident","sameDegreeHolder","foreignScholarStudent","foreignStudentOrChildOfGreekExpatriate","applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate","studentReceivesUnemploymentBenefit","institutionOrClubLocationSameAsStudentPermanentResidence","studentSubmitsTaxReportInGreece","nullifyFamilyInformation","nullifyGuardianFinancialInformation","nullifySpouseFinancialInformation","nullifyStudentFinancialInformation","maritalStatus","noOfChildren","guardianType","institutionOrClubLocationSameAsGuardianPermanentResidence","guardianNoOfChildren","numberOfStudyingSiblings","nullifyPersonalInformation","studentAfm","studentDisabledPerson","studentOrphan","institutionOrClubLocationSameAsGuadianPermanentResidence","studentGuardianTotalIncome","studentGuardianAfm","studentGuardianReceivesUnemploymentBenefit","studentGuardianSubmitsTaxReportInGreece","studentSpouseTotalIncome","studentSpouseAfm","studentSpouseReceivesUnemploymentBenefit","studentTotalIncome","lessThan25yrs","allInformationSubmittedIsTrueConfirmation","afterSaveAsync","beforeRemoveAsync","afterRemoveAsync","beforeSave","callback","then","catch","err","afterSave","afterRemove","beforeRemove"],"sources":["../../src/listeners/ValidateActionListener.js"],"sourcesContent":["import {DataError} from \"@themost/common\";\nimport { HttpForbiddenError } from '@themost/common/errors';\nimport { DataObjectState, DataModel } from \"@themost/data\";\n// eslint-disable-next-line no-unused-vars\nasync function beforeSaveAsync(event) {\n\n let runAllRules = false;\n const user = event.model.context.user;\n const target = event.model.convert(event.target);\n const context = event.model.context;\n\n let studentId = target.student;\n let action;\n let eventHasConsent;\n\n if (!Object.prototype.hasOwnProperty.call(target,'student')) {\n const actionID = event.target || event.target.id;\n action = await context.model('AccommodationRequestAction')\n .where('id')\n .equal(actionID)\n .select('student','accommodationRequestEvent/hasConsent as hasConsent','studentConsent')\n .getItem();\n studentId = action.student;\n }\n if (!studentId) {\n throw new DataError('E_STUDENT', 'The student cannot be empty at this context.');\n }\n\n const student = event.model.context.model('Student').convert(studentId);\n \n const isMe = await student.is(':me');\n if (isMe) {\n const isActive = await student.is(':active');\n if (!isActive) {\n throw new HttpForbiddenError();\n }\n\n const accommodationRequestEvent = target.accommodationRequestEvent || target.accommodationRequestEvent.id;\n eventHasConsent = await context.model('AccommodationRequestEvent')\n .where('id')\n .equal(accommodationRequestEvent)\n .select('hasConsent')\n .silent()\n .value();\n }\n\n if (event.state === 2) {\n if (isMe === true) {\n //check studentConsent\n if (event.target && eventHasConsent === true && Object.prototype.hasOwnProperty.call(target, 'studentConsent') === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The request cannot be submitted unless the student confirms that they have read and understood the Privacy and Personal Data Protection Policy.'), null, 'AccommodationRequestAction', 'studentConsent');\n } else if (event.target && eventHasConsent === true && Object.prototype.hasOwnProperty.call(target, 'studentConsent') === true && target.studentConsent === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The request cannot be submitted unless the student confirms that they have read and understood the Privacy and Personal Data Protection Policy.'), null, 'AccommodationRequestAction', 'studentConsent');\n }\n //check category\n if (target && (Object.prototype.hasOwnProperty.call(target, 'category') && (target.category == null))) {\n throw new HttpForbiddenError(\n context.__(\n 'The accommodation request creation failed because no request category has been set.'\n )\n );\n }\n\n }\n\n //UPDATE\n //Load current status\n const actionStatus = await event.model.where('id').equal(event.target.id).select('actionStatus/alternateName').value();\n \n //Action is not submitted yet. Run again all rules\n if (actionStatus === 'PotentialActionStatus') {\n runAllRules = true;\n }\n else if (actionStatus === 'ActiveActionStatus' || actionStatus === 'CompletedActionStatus'){\n //accommodation request already submitted. Do not allow to update any property \n removeAllInformationExceptStatus(event.target);\n }\n else if (actionStatus === 'CancelledActionStatus' && event.target.actionStatus && event.target.actionStatus.alternateName !== actionStatus && event.target.actionStatus.alternateName != 'ActiveActionStatus') {\n //accommodation request already cancelled. \n throw new DataError('E_VALUE', 'Cannot update cancelled action.', null, 'AccommodationRequestAction', 'actionStatus');\n }\n // allow agent to change request's status when target request status = 'ActiveActionStatus' example: to reconsider a cancelled request\n else if (actionStatus === 'CancelledActionStatus' && event.target.actionStatus && event.target.actionStatus.alternateName !== actionStatus && event.target.actionStatus.alternateName === 'ActiveActionStatus') {\n let model = event.target;\n // set loggedIn user as request's agent\n if (event.previous.agent != user.id) {\n model.agent = user.id;\n }\n }\n }\n\n else if (event.state === 1) {\n // check studentConsent\n if (isMe === true && eventHasConsent === true) {\n if (Object.prototype.hasOwnProperty.call(target, 'studentConsent') === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The request cannot be submitted unless the student confirms that they have read and understood the Privacy and Personal Data Protection Policy.'), null, 'AccommodationRequestAction', 'studentConsent');\n } else if (eventHasConsent === true && target.studentConsent === false) {\n const translateService = context.application.getStrategy(function TranslateService() { });\n throw new DataError('E_STUDENT_CONSENT', translateService.translate('The request cannot be submitted unless the student confirms that they have read and understood the Privacy and Personal Data Protection Policy.'), null, 'AccommodationRequestAction', 'studentConsent');\n }\n }\n\n if (target && (Object.prototype.hasOwnProperty.call(target, 'category') === false || (target.category == null))) {\n throw new HttpForbiddenError(\n context.__(\n 'The accommodation request creation failed because no request category has been set.'\n )\n );\n }\n\n runAllRules = true;\n }\n \n \n\n if (runAllRules){\n // set nullable fields to null when they don't need to have a value\n let model = event.target;\n \n if (Object.prototype.hasOwnProperty.call(model, 'militaryActive')) {\n if (model.militaryActive == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'militarySchool')) {\n if (model.militarySchool == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n \n if (Object.prototype.hasOwnProperty.call(model, 'studentHouseResident')) {\n if (model.studentHouseResident == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n \n if (Object.prototype.hasOwnProperty.call(model, 'sameDegreeHolder')) {\n if (model.sameDegreeHolder == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'foreignScholarStudent')) {\n if (model.foreignScholarStudent == true) {\n applyRulesForPrerequisites(model);\n return;\n } \n }\n\n\n if (Object.prototype.hasOwnProperty.call(model, 'foreignStudentOrChildOfGreekExpatriate')) {\n if (model.foreignStudentOrChildOfGreekExpatriate == true) { \n applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate(model);\n return;\n } \n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'studentReceivesUnemploymentBenefit')) {\n if (model.studentReceivesUnemploymentBenefit == true){\n model.institutionOrClubLocationSameAsStudentPermanentResidence = null;\n model.studentSubmitsTaxReportInGreece = null;\n nullifyFamilyInformation(model);\n nullifyGuardianFinancialInformation(model);\n nullifySpouseFinancialInformation(model);\n nullifyStudentFinancialInformation(model);\n return;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(model, 'maritalStatus')) {\n if (model.maritalStatus && model.maritalStatus.alternateName == 'single') {\n model.noOfChildren = null;\n nullifySpouseFinancialInformation(model);\n if (model.guardianType.alternateName == 'nobody') {\n model.institutionOrClubLocationSameAsGuardianPermanentResidence = null;\n model.guardianNoOfChildren = null;\n model.numberOfStudyingSiblings = null;\n nullifyGuardianFinancialInformation(model);\n }\n }\n else {\n model.guardianType = null;\n model.institutionOrClubLocationSameAsGuardianPermanentResidence = null;\n model.guardianNoOfChildren = null;\n model.numberOfStudyingSiblings = null;\n nullifyGuardianFinancialInformation(model);\n if (model.maritalStatus && model.maritalStatus.alternateName != 'married') {\n nullifySpouseFinancialInformation(model);\n }\n }\n }\n }\n \n\n} \n\nfunction applyRulesForPrerequisites(model) {\n //nullify all other properties except foreignScholarStudent, inscriptionModeTag, lessThan25yrs and allInformationSubmittedIsTrueConfirmation\n nullifyPersonalInformation(model);\n nullifyFamilyInformation(model);\n nullifyGuardianFinancialInformation(model); \n nullifySpouseFinancialInformation(model);\n nullifyStudentFinancialInformation(model); \n}\n\nfunction applyRulesForCyprusStudentOrForeignStudentOrChildOfGreekExpatriate(model) {\n model.studentAfm = null;\n}\n\nfunction nullifyPersonalInformation(model){\n model.foreignStudentOrChildOfGreekExpatriate = null;\n model.studentDisabledPerson = null;\n model.studentOrphan = null;\n model.studentReceivesUnemploymentBenefit = null;\n model.studentSubmitsTaxReportInGreece = null;\n model.institutionOrClubLocationSameAsStudentPermanentResidence = null;\n}\n\nfunction nullifyFamilyInformation(model){\n model.noOfChildren = null;\n model.maritalStatus = null;\n model.numberOfStudyingSiblings = null;\n model.guardianNoOfChildren = null;\n model.guardianType = null;\n model.institutionOrClubLocationSameAsGuadianPermanentResidence = null;\n}\n\nfunction nullifyGuardianFinancialInformation(model){\n model.studentGuardianTotalIncome = null;\n model.studentGuardianAfm = null;\n model.studentGuardianReceivesUnemploymentBenefit = null;\n model.studentGuardianSubmitsTaxReportInGreece = null;\n}\n\nfunction nullifySpouseFinancialInformation(model){\n model.studentSpouseTotalIncome = null;\n model.studentSpouseAfm = null;\n model.studentSpouseReceivesUnemploymentBenefit = null;\n}\n\nfunction nullifyStudentFinancialInformation(model){\n model.studentTotalIncome = null;\n model.studentAfm = null;\n}\n\nfunction removeAllInformationExceptStatus(model){\n delete model.militaryActive;\n delete model.militarySchool;\n delete model.studentHouseResident;\n delete model.sameDegreeHolder;\n delete model.foreignScholarStudent;\n delete model.lessThan25yrs;\n delete model.institutionOrClubLocationSameAsStudentPermanentResidence;\n delete model.studentDisabledPerson;\n delete model.studentOrphan;\n delete model.numberOfStudyingSiblings ;\n delete model.maritalStatus;\n delete model.noOfChildren;\n delete model.guardianType;\n delete model.institutionOrClubLocationSameAsGuadianPermanentResidence;\n delete model.guardianNoOfChildren;\n delete model.studentReceivesUnemploymentBenefit;\n delete model.studentSubmitsTaxReportInGreece;\n delete model.studentGuardianSubmitsTaxReportInGreece;\n delete model.studentAfm;\n delete model.studentTotalIncome;\n delete model.studentSpouseReceivesUnemploymentBenefit;\n delete model.studentSpouseAfm;\n delete model.studentSpouseTotalIncome;\n delete model.studentGuardianReceivesUnemploymentBenefit ;\n delete model.foreignStudentOrChildOfGreekExpatriate;\n delete model.studentGuardianAfm;\n delete model.studentGuardianTotalIncome;\n delete model.allInformationSubmittedIsTrueConfirmation;\n}\n\nasync function afterSaveAsync(event) {\n // on insert\n\n}\n\nasync function beforeRemoveAsync(event) {\n \n}\n\nasync function afterRemoveAsync(event) {\n const context = event.model.context;\n // try to find if a preference exists for that event\n\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function beforeSave(event, callback) {\n return beforeSaveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function afterSave(event, callback) {\n return afterSaveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function afterRemove(event, callback) {\n return afterRemoveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n\n\n/**\n * @param {DataEventArgs} event\n * @param {Function} callback\n */\nexport function beforeRemove(event, callback) {\n return beforeRemoveAsync(event).then(() => {\n return callback();\n }).catch((err) => {\n return callback(err);\n });\n}\n"],"mappings":"+MAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA;AACA,eAAeG,eAAeA,CAACC,KAAK,EAAE;;EAElC,IAAIC,WAAW,GAAG,KAAK;EACvB,MAAMC,IAAI,GAAGF,KAAK,CAACG,KAAK,CAACC,OAAO,CAACF,IAAI;EACrC,MAAMG,MAAM,GAAGL,KAAK,CAACG,KAAK,CAACG,OAAO,CAACN,KAAK,CAACK,MAAM,CAAC;EAChD,MAAMD,OAAO,GAAGJ,KAAK,CAACG,KAAK,CAACC,OAAO;;EAEnC,IAAIG,SAAS,GAAGF,MAAM,CAACG,OAAO;EAC9B,IAAIC,MAAM;EACV,IAAIC,eAAe;;EAEnB,IAAI,CAACC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,MAAM,EAAC,SAAS,CAAC,EAAE;IACzD,MAAMU,QAAQ,GAAGf,KAAK,CAACK,MAAM,IAAIL,KAAK,CAACK,MAAM,CAACW,EAAE;IAChDP,MAAM,GAAG,MAAML,OAAO,CAACD,KAAK,CAAC,4BAA4B,CAAC;IACrDc,KAAK,CAAC,IAAI,CAAC;IACXC,KAAK,CAACH,QAAQ,CAAC;IACfI,MAAM,CAAC,SAAS,EAAC,oDAAoD,EAAC,gBAAgB,CAAC;IACvFC,OAAO,EAAE;IACdb,SAAS,GAAGE,MAAM,CAACD,OAAO;EAC9B;EACA,IAAI,CAACD,SAAS,EAAE;IACZ,MAAM,IAAIc,iBAAS,CAAC,WAAW,EAAE,8CAA8C,CAAC;EACpF;;EAEA,MAAMb,OAAO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AAC,CAACoF,IAAI,CAAC,MAAM;IACpC,OAAOD,QAAQ,EAAE;EACrB,CAAC,CAAC,CAACE,KAAK,CAAC,CAACC,GAAG,KAAK;IACd,OAAOH,QAAQ,CAACG,GAAG,CAAC;EACxB,CAAC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACO,SAASE,WAAWA,CAACxF,KAAK,EAAEmF,QAAQ,EAAE;EACzC,OAAOF,gBAAgB,CAACjF,KAAK,CAAC,CAACoF,IAAI,CAAC,MAAM;IACtC,OAAOD,QAAQ,EAAE;EACrB,CAAC,CAAC,CAACE,KAAK,CAAC,CAACC,GAAG,KAAK;IACd,OAAOH,QAAQ,CAACG,GAAG,CAAC;EACxB,CAAC,CAAC;AACN;;;AAGA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAACzF,KAAK,EAAEmF,QAAQ,EAAE;EAC1C,OAAOH,iBAAiB,CAAChF,KAAK,CAAC,CAACoF,IAAI,CAAC,MAAM;IACvC,OAAOD,QAAQ,EAAE;EACrB,CAAC,CAAC,CAACE,KAAK,CAAC,CAACC,GAAG,KAAK;IACd,OAAOH,QAAQ,CAACG,GAAG,CAAC;EACxB,CAAC,CAAC;AACN"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "The request cannot be submitted unless the student confirms that they have read and understood the Privacy and Personal Data Protection Policy.": "Η αίτηση δεν μπορεί να αποθηκευτεί χωρίς ο φοιτητής να δηλώσει ότι έχει λάβει γνώση της Πολιτικής Προστασίας της Ιδιωτικότητας και των Προσωπικών Δεδομένων."
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+
3
+ }
@@ -50,4 +50,4 @@ _data.EdmMapping.action('remove', 'Accommodation'), _dec(_class = (_class2 = cla
50
50
  }, (_applyDecoratedDescriptor(_class2.prototype, "remove", [_dec2, _dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "remove"), _class2.prototype)), _class2)) || _class);
51
51
 
52
52
  module.exports = AccommodationRequestEvent;
53
- //# sourceMappingURL=Accommodation.js.map
53
+ //# sourceMappingURL=AccommodationPlace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccommodationPlace.js","names":["_common","require","_data","_dec","_dec2","_dec3","_class","_class2","_applyDecoratedDescriptor","target","property","decorators","descriptor","context","desc","Object","keys","forEach","key","enumerable","configurable","initializer","writable","slice","reverse","reduce","decorator","value","call","undefined","defineProperty","AccommodationRequestEvent","EdmMapping","entityType","param","action","DataObject","constructor","remove","data","model","getModel","item","where","equal","getId","getItem","translateService","application","getStrategy","TranslateService","DataError","translate","hasRooms","id","count","silent","prototype","getOwnPropertyDescriptor","module","exports"],"sources":["../../src/models/AccommodationPlace.js"],"sourcesContent":["/* eslint-disable no-unused-vars */\nimport { DataError } from \"@themost/common\";\nimport { DataObject, EdmMapping } from \"@themost/data\";\n\n\n@EdmMapping.entityType('Accommodation')\nclass AccommodationRequestEvent extends DataObject {\n /**\n * @constructor\n */\n constructor() {\n super();\n }\n\n /**\n * POST AccommodationRequestEvents/:id/Remove\n */\n\n //remove accommodation request event\n @EdmMapping.param('data', 'Object', false, true)\n @EdmMapping.action('remove', 'Accommodation')\n async remove(data) {\n /**\n * @type {import('@themost/data').DataModel}\n */\n\n const model = this.getModel();\n\n const item = await model.where('id')\n .equal(this.getId())\n .getItem();\n const translateService = this.context.application.getStrategy(function TranslateService() { });\n\n if (item == null) {\n throw new DataError('E_ACCOMMODATION', translateService.translate('The specified Accommodation cannot be found or is inaccessible.'));\n }\n\n const hasRooms = await this.context.model('AccommodationRooms')\n .where('containedInPlace').equal(item.id).count();\n\n if (hasRooms) {\n throw new DataError('E_ACCOMMODATION_ROOM', translateService.translate('Cannot remove accommodation. Accommodation is related to rooms.'), null, 'Accommodation');\n }\n\n return model.silent().remove(item);\n }\n\n\n \n}\n\nmodule.exports = AccommodationRequestEvent;\n"],"mappings":";AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA,kBAAuD,IAAAE,IAAA,EAAAC,KAAA,EAAA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A,MAAAD,MAAA;;AAEDqD,MAAM,CAACC,OAAO,GAAG7B,yBAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universis/accommodation",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Universis api library template",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  {
48
48
  "mask": 15,
49
49
  "type": "global",
50
- "account": "DiningAdministrators"
50
+ "account": "AccommodationAdministrators"
51
51
  },
52
52
  {
53
53
  "mask": 15,
@@ -76,7 +76,7 @@
76
76
  {
77
77
  "mask": 15,
78
78
  "type": "global",
79
- "account": "DiningAdministrators"
79
+ "account": "AccommodationAdministrators"
80
80
  }
81
81
  ],
82
82
  "constraints": [
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://themost-framework.github.io/themost/models/2018/2/schema.json",
3
- "@id": "http://schema.org/Accommodation",
4
- "name": "Accommodation",
3
+ "@id": "http://schema.org/AccommodationPlace",
4
+ "name": "AccommodationPlace",
5
5
  "description": "An accommodation is a place that can accommodate human beings, e.g. a hotel room, a camping pitch, or a meeting room.",
6
- "title": "Accommodation",
6
+ "title": "AccommodationPlace",
7
7
  "abstract": false,
8
8
  "sealed": false,
9
9
  "implements": "Place",
10
- "classPath": "./models/Accommodation",
11
- "version": "1.5",
10
+ "classPath": "./models/AccommodationPlace",
11
+ "version": "1.0",
12
12
  "fields": [
13
13
  {
14
14
  "@id": "http://schema.org/identifier",
@@ -56,8 +56,15 @@
56
56
  "name": "address",
57
57
  "title": "address",
58
58
  "description": "Physical address of the item.",
59
- "type": "Json",
60
- "additionalType": "PostalAddress"
59
+ "type": "PostalAddress",
60
+ "mapping": {
61
+ "parentModel": "AccommodationPlace",
62
+ "childModel": "PostalAddress",
63
+ "parentField": "identifier",
64
+ "childField": "identifier",
65
+ "cascade": "delete",
66
+ "associationType": "association"
67
+ }
61
68
  },
62
69
  {
63
70
  "@id": "http://schema.org/geo",
@@ -66,9 +73,49 @@
66
73
  "description": "The geo coordinates of the accommodation.",
67
74
  "type": "Json",
68
75
  "additionalType": "GeoCoordinates"
76
+ },
77
+ {
78
+ "name": "locales",
79
+ "type": "AccommodationPlaceLocale",
80
+ "mapping": {
81
+ "associationType": "association",
82
+ "cascade": "delete",
83
+ "parentModel": "AccommodationPlace",
84
+ "parentField": "id",
85
+ "childModel": "AccommodationPlaceLocale",
86
+ "childField": "object"
87
+ }
88
+ },
89
+ {
90
+ "name": "locale",
91
+ "type": "AccommodationPlaceLocale",
92
+ "readonly": true,
93
+ "editable": false,
94
+ "many": true,
95
+ "expandable": true,
96
+ "multiplicity": "ZeroOrOne",
97
+ "mapping": {
98
+ "associationType": "association",
99
+ "cascade": "delete",
100
+ "parentModel": "AccommodationPlace",
101
+ "parentField": "id",
102
+ "childModel": "AccommodationPlaceLocale",
103
+ "childField": "object",
104
+ "options": {
105
+ "$filter": "inLanguage eq lang()",
106
+ "$first": true
107
+ }
108
+ }
69
109
  }
70
110
  ],
71
- "eventListeners": [],
111
+ "eventListeners": [
112
+ {
113
+ "type": "@themost/data/previous-state-listener"
114
+ },
115
+ {
116
+ "type": "./listeners/data-localization"
117
+ }
118
+ ],
72
119
  "constraints": [
73
120
  {
74
121
  "type": "unique",
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "https://themost-framework.github.io/themost/models/2018/2/schema.json",
3
+ "@id": "https://universis.io/entities/AccommodationLocale",
4
+ "name": "AccommodationPlaceLocale",
5
+ "description": "Contains a collection of extra field required for accommodation.",
6
+ "title": "AccommodationPlaceLocale",
7
+ "abstract": false,
8
+ "contains": "AccommodationPlace",
9
+ "hidden": true,
10
+ "sealed": false,
11
+ "version": "1.0",
12
+ "fields": [
13
+ {
14
+ "@id": "https://themost.io/schemas/id",
15
+ "name": "id",
16
+ "title": "ID",
17
+ "description": "The identifier of the item.",
18
+ "type": "Counter",
19
+ "primary": true,
20
+ "nullable": false
21
+ },
22
+ {
23
+ "@id": "https://themost.io/schemas/object",
24
+ "name": "object",
25
+ "title": "object",
26
+ "description": "The parent item.",
27
+ "type": "Accommodation"
28
+ },
29
+ {
30
+ "@id": "http://schema.org/inLanguage",
31
+ "name": "inLanguage",
32
+ "title": "inLanguage",
33
+ "description": "The language of this item.",
34
+ "type": "Text",
35
+ "size": 5
36
+ },
37
+ {
38
+ "name": "name",
39
+ "title": "Ονομασία",
40
+ "description": "Η ονομασία του αντικειμένου",
41
+ "type": "Text",
42
+ "nullable": true,
43
+ "size": 100
44
+ },
45
+ {
46
+ "name": "description",
47
+ "title": "Περιγραφή",
48
+ "description": "Περιγραφή του τύπου εργασίας",
49
+ "type": "Text",
50
+ "nullable": true,
51
+ "size": 80
52
+ },
53
+ {
54
+ "name": "displayCode",
55
+ "title": "Display code",
56
+ "description": "The display code of the place",
57
+ "type": "Text",
58
+ "size": 15
59
+ }
60
+ ],
61
+ "constraints": [
62
+ {
63
+ "type": "unique",
64
+ "fields": [
65
+ "object",
66
+ "inLanguage"
67
+ ]
68
+ }
69
+ ],
70
+ "privileges": [
71
+ {
72
+ "mask": 1,
73
+ "type": "global",
74
+ "account": "*"
75
+ },
76
+ {
77
+ "mask": 15,
78
+ "type": "global"
79
+ },
80
+ {
81
+ "mask": 15,
82
+ "type": "global",
83
+ "account": "Administrators"
84
+ }
85
+ ]
86
+ }
@@ -196,15 +196,15 @@
196
196
  ]
197
197
  },
198
198
  {
199
- "alternateName": "RejectionUniversityHousingEffectiveStatus",
199
+ "alternateName": "RejectionUniversityAccommodationEffectiveStatus",
200
200
  "activatesAccommodationCard": false,
201
201
  "name": "Απόρριψη λόγω Στέγασης σε Εστία",
202
202
  "description": "Απόρριψη λόγω Στέγασης σε Εστία",
203
203
  "locales": [
204
204
  {
205
205
  "inLanguage": "en",
206
- "name": "Rejection due to University Housing",
207
- "description": "Rejection due to University Housing"
206
+ "name": "Rejection due to University Accommodation",
207
+ "description": "Rejection due to University Accommodation"
208
208
  }
209
209
  ]
210
210
  }
@@ -6,8 +6,8 @@
6
6
  "title": "AccommodationRoom",
7
7
  "abstract": false,
8
8
  "sealed": false,
9
- "implements": "Accommodation",
10
- "version": "1.9.9",
9
+ "implements": "AccommodationPlace",
10
+ "version": "2.0.1",
11
11
  "fields": [
12
12
  {
13
13
  "name": "bed",
@@ -15,7 +15,7 @@
15
15
  "size": 500
16
16
  },
17
17
  {
18
- "name": "floorLavel",
18
+ "name": "floor",
19
19
  "type": "Text",
20
20
  "size": 500
21
21
  },
@@ -112,7 +112,7 @@
112
112
  {
113
113
  "name": "containedInPlace",
114
114
  "description": "Το κτήριο στο οποίο βρίσκεται το δωμάτιο",
115
- "type": "Accommodation"
115
+ "type": "AccommodationPlace"
116
116
  },
117
117
  {
118
118
  "name": "accessibleForDisabled",
@@ -128,9 +128,48 @@
128
128
  "name": "reasonOutOfService",
129
129
  "type": "Text",
130
130
  "size": 500
131
+ },
132
+ {
133
+ "name": "locales",
134
+ "type": "AccommodationRoomLocale",
135
+ "mapping": {
136
+ "associationType": "association",
137
+ "cascade": "delete",
138
+ "parentModel": "AccommodationRoom",
139
+ "parentField": "id",
140
+ "childModel": "AccommodationRoomLocale",
141
+ "childField": "object"
142
+ }
143
+ },
144
+ {
145
+ "name": "locale",
146
+ "type": "AccommodationRoomLocale",
147
+ "readonly": true,
148
+ "editable": false,
149
+ "many": true,
150
+ "expandable": true,
151
+ "multiplicity": "ZeroOrOne",
152
+ "mapping": {
153
+ "associationType": "association",
154
+ "cascade": "delete",
155
+ "parentModel": "AccommodationRoom",
156
+ "parentField": "id",
157
+ "childModel": "AccommodationRoomLocale",
158
+ "childField": "object",
159
+ "options": {
160
+ "$filter": "inLanguage eq lang()",
161
+ "$first": true
162
+ }
163
+ }
131
164
  }
132
165
  ],
133
166
  "eventListeners": [
167
+ {
168
+ "type": "@themost/data/previous-state-listener"
169
+ },
170
+ {
171
+ "type": "./listeners/data-localization"
172
+ }
134
173
  ],
135
174
  "privileges": [
136
175
  {
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "https://themost-framework.github.io/themost/models/2018/2/schema.json",
3
+ "@id": "https://universis.io/entities/AccommodationRoomLocale",
4
+ "name": "AccommodationRoomLocale",
5
+ "description": "Contains a collection of extra field required for accommodation room.",
6
+ "title": "AccommodationRoomLocale",
7
+ "abstract": false,
8
+ "contains": "AccommodationRoom",
9
+ "hidden": true,
10
+ "sealed": false,
11
+ "version": "1.0",
12
+ "fields": [
13
+ {
14
+ "@id": "https://themost.io/schemas/id",
15
+ "name": "id",
16
+ "title": "ID",
17
+ "description": "The identifier of the item.",
18
+ "type": "Counter",
19
+ "primary": true,
20
+ "nullable": false
21
+ },
22
+ {
23
+ "@id": "https://themost.io/schemas/object",
24
+ "name": "object",
25
+ "title": "object",
26
+ "description": "The parent item.",
27
+ "type": "AccommodationRoom"
28
+ },
29
+ {
30
+ "@id": "http://schema.org/inLanguage",
31
+ "name": "inLanguage",
32
+ "title": "inLanguage",
33
+ "description": "The language of this item.",
34
+ "type": "Text",
35
+ "size": 5
36
+ },
37
+ {
38
+ "name": "name",
39
+ "title": "Ονομασία",
40
+ "description": "Η ονομασία του αντικειμένου",
41
+ "type": "Text",
42
+ "nullable": true,
43
+ "size": 100
44
+ },
45
+ {
46
+ "name": "description",
47
+ "title": "Περιγραφή",
48
+ "description": "Περιγραφή του τύπου εργασίας",
49
+ "type": "Text",
50
+ "nullable": true,
51
+ "size": 80
52
+ },
53
+ {
54
+ "name": "displayCode",
55
+ "title": "Display code",
56
+ "description": "The display code of the place",
57
+ "type": "Text",
58
+ "size": 15
59
+ }
60
+ ],
61
+ "constraints": [
62
+ {
63
+ "type": "unique",
64
+ "fields": [
65
+ "object",
66
+ "inLanguage"
67
+ ]
68
+ }
69
+ ],
70
+ "privileges": [
71
+ {
72
+ "mask": 1,
73
+ "type": "global",
74
+ "account": "*"
75
+ },
76
+ {
77
+ "mask": 15,
78
+ "type": "global"
79
+ },
80
+ {
81
+ "mask": 15,
82
+ "type": "global",
83
+ "account": "Administrators"
84
+ }
85
+ ]
86
+ }
@@ -9,16 +9,6 @@ export default [
9
9
  "write"
10
10
  ]
11
11
  },
12
- {
13
- "scope": [
14
- "registrar"
15
- ],
16
- "resource": "/api/Accommodations/?$",
17
- "access": [
18
- "read",
19
- "write"
20
- ]
21
- },
22
12
  {
23
13
  "scope": [
24
14
  "registrar"
@@ -47,9 +47,9 @@ async function afterSaveAsync(event) {
47
47
  academicPeriod = student && student.department && student.department.currentPeriod ? student.department.currentPeriod : null;
48
48
  }
49
49
  let cardActionStatus = {};
50
- if (event.target.accommodation && (Object.keys(event.target.accommodation).length === 0 || event.target.accommodation === '')) {
50
+ if (!event.target.accommodation ){
51
51
  // get accommodation valid through date
52
- cardActionStatus = { alternateName: 'PotentialActionStatus' }
52
+ cardActionStatus = { alternateName: 'ActiveActionStatus' }
53
53
 
54
54
  } else {
55
55
  cardActionStatus = { alternateName: 'CompletedActionStatus' }
@@ -13,16 +13,16 @@ async function afterSaveAsync(event) {
13
13
  const mailer = getMailer(context);
14
14
 
15
15
  const currentCardStatus = await context
16
- .model('StudentDiningCard')
16
+ .model('StudentAccommodationCard')
17
17
  .where('id')
18
18
  .equal(event.target.id)
19
- .select('active')
19
+ .select('cardStatus')
20
20
  .value();
21
21
  let previousCardStatus = 'UnknownStatus';
22
22
  if (event.previous) {
23
- previousCardStatus = event.previous.active;
23
+ previousCardStatus = event.previous.cardStatus;
24
24
  } else {
25
- throw new DataError('E_STATE', 'The previous state of an object cannot be determined', null, 'StudentDiningCard');
25
+ throw new DataError('E_STATE', 'The previous state of an object cannot be determined', null, 'StudentAccommodationCard');
26
26
  }
27
27
  if (currentCardStatus === previousCardStatus) {
28
28
  return;
@@ -32,7 +32,7 @@ async function afterSaveAsync(event) {
32
32
  const mailTemplate = await context
33
33
  .model('MailConfigurations')
34
34
  .where('target')
35
- .equal('DiningCardActiveStatusChange')
35
+ .equal('AccommodationCardActiveStatusChange')
36
36
  .silent()
37
37
  .getItem();
38
38
  if (mailTemplate == null) {
@@ -44,7 +44,7 @@ async function afterSaveAsync(event) {
44
44
  let item;
45
45
  if (typeof event.target.action === 'object' && typeof event.target.action.id === 'number' && Number.isInteger(event.target.action.id) && event.target.action.id > 0) {
46
46
  item = await context
47
- .model('DiningRequestAction')
47
+ .model('AccommodationRequestAction')
48
48
  .where('id')
49
49
  .equal(event.target.action.id)
50
50
  .expand({
@@ -58,7 +58,7 @@ async function afterSaveAsync(event) {
58
58
 
59
59
  } else if (typeof event.target.action === 'number' && Number.isInteger(event.target.action) && event.target.action > 0) {
60
60
  item = await context
61
- .model('DiningRequestAction')
61
+ .model('AccommodationRequestAction')
62
62
  .where('id')
63
63
  .equal(event.target.action)
64
64
  .expand({
@@ -83,7 +83,7 @@ async function afterSaveAsync(event) {
83
83
  const config = await context
84
84
  .model('StudentRequestConfiguration')
85
85
  .where('additionalType')
86
- .equal('DiningRequestAction')
86
+ .equal('AccommodationRequestAction')
87
87
  .and('inLanguage')
88
88
  .equal(event.target.inLanguage || context.locale)
89
89
  .silent()