diff --git a/.gitignore b/.gitignore index 0be78500..41b3dadc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,17 @@ -/.settings -/.buildpath -/.project -/.idea/ -/build -/deployment/clients/dev/data/ -/deployment/clients/test/data/ -/deployment/clients/local/data/ -/.vagrant -/app/config.php -/app/data/* +.settings +.buildpath +.project +.idea/ +build +deployment/clients/dev/data/ +deployment/clients/test/data/ +deployment/clients/local/data/ +.vagrant +app/config.php +app/data/* +cache.properties +node_modules/* +web/dist/*.map +web/admin/dist/*.map +web/modules/dist/*.map .gitkeep diff --git a/Vagrantfile b/Vagrantfile index 70d78268..269b878d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -21,9 +21,8 @@ Vagrant.configure(2) do |config| config.vm.hostname = "icehrm.open" config.hostsupdater.aliases = [ - "app.dev", - "app.app.dev", - "clients.app.dev" + "app.icehrm-open.test", + "clients.icehrm-open.test" ] end diff --git a/build.xml b/build.xml index 622aa124..97964395 100644 --- a/build.xml +++ b/build.xml @@ -1,5 +1,5 @@ - + @@ -11,7 +11,7 @@ - @@ -94,7 +93,6 @@ - @@ -145,7 +143,7 @@ - + @@ -181,12 +179,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -196,11 +223,16 @@ - - - - - + + + + + + + + + + @@ -219,6 +251,9 @@ + + + diff --git a/cache.properties b/cache.properties index 8b30eb9b..405e7561 100644 --- a/cache.properties +++ b/cache.properties @@ -1,244 +1,499 @@ -#Sun Apr 29 05:47:35 CEST 2018 -/Users/Thilina/Projects/icehrm/src/Expenses/Common/Model/EmployeeExpenseApproval.php=db8eedd8fb151769acded489e9d616c1 -/Users/Thilina/Projects/icehrm/src/Attendance/Common/Calculations/BasicOvertimeCalculator.php=9c96ae3f71796029d3f93e5c63783f53 -/Users/Thilina/Projects/icehrm/src/Classes/Email/SNSEmailSender.php=fa905e3ab63ea745c591e744d6741b6b -/Users/Thilina/Projects/icehrm/src/Salary/Common/Model/SalaryComponent.php=31e89f1115de7986cd790c8e113ab6d5 -/Users/Thilina/Projects/icehrm/src/Classes/Email/EmailSender.php=03a98d7d1bcc56a77cc5b3bfa46b79fd -/Users/Thilina/Projects/icehrm/test/bootstrap.php=391db040530140c40c84cbbc65645d58 -/Users/Thilina/Projects/icehrm/src/Utils/InputCleaner.php=e86fcb9daf1d32a4328edf40a31152f8 -/Users/Thilina/Projects/icehrm/src/Projects/Common/Model/Project.php=05b1cd967d67cb977558f2567d7f6cb6 -/Users/Thilina/Projects/icehrm/src/Model/DataEntryBackup.php=9ab3a7d48dbdd377a90c505cf692c17e -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/Skill.php=e1441a2526e24a7ada7d20b36ff9e355 -/Users/Thilina/Projects/icehrm/src/Permissions/Admin/Api/PermissionsAdminManager.php=c66e06b926b4006e8a2d7f2e77e0f1fa -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/Province.php=4a718577000772ab7591a2586f7c75c8 -/Users/Thilina/Projects/icehrm/src/Loans/Common/Model/EmployeeCompanyLoan.php=abc8959df2ec0f3e19ff6da12c3163f9 -/Users/Thilina/Projects/icehrm/src/Classes/Approval/ApprovalStatus.php=7a3bc0a73f237eb677254b245887f48f -/Users/Thilina/Projects/icehrm/src/Classes/FileService.php=806ff6c25c7654c30e99b0418e1c1475 -/Users/Thilina/Projects/icehrm/src/Dashboard/User/Api/DashboardActionManager.php=3f797cf4807ad5cd4f881607142df049 -/Users/Thilina/Projects/icehrm/src/Classes/Cron/Task/EmailSenderTask.php=f0c93e7c807706922cb812723e51bd09 -/Users/Thilina/Projects/icehrm/src/Attendance/Admin/Api/AttendanceUtil.php=34fe63a4c0f954451afae6c359ea5b38 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/Deduction.php=1e49d0fd8d4673e3fd094cfb0e467df4 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/PayrollDataExport.php=83bd6faa73c75667ecf25091c3729abc -/Users/Thilina/Projects/icehrm/src/Employees/Common/Model/Employee.php=f8814257c241892fcf45e1d409d6ab1b -/Users/Thilina/Projects/icehrm/src/Metadata/Admin/Api/MetadataAdminManager.php=9f383f9c34ec98a8e2e701825c548a8a -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/NewHiresEmployeeReport.php=64eab525953538d481dab6052dd76d81 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/DeductionGroup.php=c35db5b88aa4b0c7d78b8444688931b5 -/Users/Thilina/Projects/icehrm/src/Utils/Math/EvalMathFuncs.php=d6f7c26eab307d205ee8483d87a380cb -/Users/Thilina/Projects/icehrm/src/Classes/ModuleBuilder/ModuleTabGroup.php=d81cfc2b3dcad2f57317b1274c884d95 -/Users/Thilina/Projects/icehrm/src/Model/RestAccessToken.php=77c292675944ff887fc8b4c3f7b6da94 -/Users/Thilina/Projects/icehrm/src/Classes/LDAPManager.php=e88dd0634a6ca372564faa5a1d540796 -/Users/Thilina/Projects/icehrm/src/Expenses/Admin/Api/ExpensesAdminManager.php=ef6961e298a55379ec4dfff8b9db77fc -/Users/Thilina/Projects/icehrm/src/Dashboard/User/Api/DashboardModulesManager.php=2e8968121b445353ee864c76c44483d3 -/Users/Thilina/Projects/icehrm/src/Model/UserReport.php=0a8a8476e3088011cc54fda139567b56 -/Users/Thilina/Projects/icehrm/src/Travel/Common/Model/EmployeeTravelRecordApproval.php=d84b2a1323f3663806cc30545e748cd4 -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/SupportedLanguage.php=3ec1220796f6e33641998a33f036d709 -/Users/Thilina/Projects/icehrm/src/TimeSheets/Common/Model/QTDays.php=32a00e65a966331b776dc37cc0609edf -/Users/Thilina/Projects/icehrm/src/Salary/Common/Model/EmployeeSalary.php=ec80c4e8280d23568df79f59d1b32de8 -/Users/Thilina/Projects/icehrm/src/Classes/SimpleImage.php=fdfb7b2e71e14975ebce16de44ea9dee -/Users/Thilina/Projects/icehrm/src/Expenses/User/Api/ExpensesModulesManager.php=4860a1fbb24f4074a6918b2c0b973e80 -/Users/Thilina/Projects/icehrm/src/Employees/User/Api/EmployeesActionManager.php=7f495266d28737c779e1e9ab3c61e0db -/Users/Thilina/Projects/icehrm/src/Classes/Approval/ApproveAdminActionManager.php=3c26b53f0e5141b8f4a033cbbd4c622e -/Users/Thilina/Projects/icehrm/src/Settings/Admin/Api/SettingsAdminManager.php=5e5df0056db6f9593128720581feca18 -/Users/Thilina/Projects/icehrm/src/Travel/User/Api/TravelModulesManager.php=94c9204a67e99af9133cd2aa371cb6da -/Users/Thilina/Projects/icehrm/test/unit/UserAttendanceActionManagerUnit.php=1d71d366a13f253ef6931aa87202ac42 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/OvertimeRequestReport.php=3cd3bc887da768a32bfc61c152489528 -/Users/Thilina/Projects/icehrm/src/Employees/User/Api/EmployeesModulesManager.php=ad9ab05afd9cf551870352dba82e6d69 -/Users/Thilina/Projects/icehrm/test/helper/EmployeeTestDataHelper.php=65ec2048653c9e4e4359d9b6967a860d -/Users/Thilina/Projects/icehrm/test/integration/ApprovalStatusIntegration.php=8b9243e5cbb302513d906ff9de246acd -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeTimeSheetData.php=9d612ee603fdf4e6b710eec725da2656 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayrollData.php=f1a49da4e6e5a91695dd96c9585e1686 -/Users/Thilina/Projects/icehrm/src/TimeSheets/User/Api/TimeSheetsInitialize.php=d47372f12494019c1004a04cbe57013d -/Users/Thilina/Projects/icehrm/src/Modules/Admin/Api/ModulesAdminManager.php=ef70889c3b3b9eae52800ce3a326d540 -/Users/Thilina/Projects/icehrm/src/Modules/Common/Model/Module.php=8f0d1680087f555f5628c53236c7625f -/Users/Thilina/Projects/icehrm/src/Expenses/Common/Model/ExpensesPaymentMethod.php=338ce9cabb90a291e88b940756b06701 -/Users/Thilina/Projects/icehrm/src/Company/Common/Model/Timezone.php=50aff3bc39221658c35041abdc55ad98 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/OvertimeSummaryReport.php=16d9e2f10de82f25d0965e2d327086b9 -/Users/Thilina/Projects/icehrm/src/Data/Common/Model/DataImport.php=a6af4d8acd5585932823889509cca581 -/Users/Thilina/Projects/icehrm/src/FieldNames/Common/Model/FieldNameMapping.php=73bd1da0f6e51329dbe12930bb566ccd -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/ActiveEmployeeReport.php=261180dfbe69ab83d9d63646111695ba -/Users/Thilina/Projects/icehrm/test/unit/LanguageManagerUnit.php=ebb20febce875350bfddd7f0358e6ad0 -/Users/Thilina/Projects/icehrm/src/Utils/LogManager.php=144ebae4d0ff60f0fd21e79a45aa6e6a -/Users/Thilina/Projects/icehrm/src/Dependents/Common/Model/EmployeeDependent.php=1f4b6cd6dfbc14269b53dbbac3730f9e -/Users/Thilina/Projects/icehrm/src/Data/Admin/Import/PayrollDataImporter.php=7350ec94ef8a70ba6c263e53c70c7073 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/ExpenseReport.php=397c8deb446994b64e2b9fef2845bb89 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/OvertimeReport.php=f630ae5402ec7957f42b64fa46cd1923 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeLeaveEntitlementReport.php=9be41bfeb88fd0171028203f6513c799 -/Users/Thilina/Projects/icehrm/src/Projects/User/Api/ProjectsModulesManager.php=4fc0463507ca7768a1e493d703ac2581 -/Users/Thilina/Projects/icehrm/src/Permissions/Common/Model/Permission.php=0745dd3786e95cfc5265c32f47f4ee4a -/Users/Thilina/Projects/icehrm/src/Overtime/Admin/Api/OvertimeActionManager.php=0b039c008daf52e64f9ce827eabdd25a -/Users/Thilina/Projects/icehrm/src/Salary/User/Api/SalaryModulesManager.php=050d077e79532353a7d12a7221829b7c -/Users/Thilina/Projects/icehrm/src/Classes/Cron/IceTask.php=cc9b1481e824fd967eb503248eb92e29 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeTimesheetReport.php=8661944cf39b10c441841a8af72cb988 -/Users/Thilina/Projects/icehrm/src/EmergencyContacts/User/Api/EmergencyContactModulesManager.php=527888466137dad3da5c6bf5b7bf9b28 -/Users/Thilina/Projects/icehrm/src/Classes/SettingsManager.php=ebed24cde74d7fb33cca4ba156389760 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/EmployeeLanguage.php=66127455502fb29181324c1cc25f93c4 -/Users/Thilina/Projects/icehrm/src/Classes/Approval/ApproveCommonActionManager.php=c1b7efb8c4f3fe8199c7e0d6fdd1ccce -/Users/Thilina/Projects/icehrm/src/Overtime/Common/Model/EmployeeOvertime.php=50c166318a354b05dc2ae0e442d43a33 -/Users/Thilina/Projects/icehrm/src/Reports/User/Api/ReportsModulesManager.php=1645b61be16b96d0085510f6a2d30b68 -/Users/Thilina/Projects/icehrm/src/Classes/RestApiManager.php=c53180aa40576c5fe8c519b2b0a39e32 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/Payroll.php=5c7eb622aade003f693275944e041cc7 -/Users/Thilina/Projects/icehrm/src/Attendance/Admin/Api/AttendanceActionManager.php=9045182bc0854647219b0a0418c37ffd -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/PDFReportBuilder.php=fbbc196b5ea432671667bcc239d8bf54 -/Users/Thilina/Projects/icehrm/src/Employees/Rest/EmployeeRestEndPoint.php=5a006d8637a05d63f19e130b37bdd97d -/Users/Thilina/Projects/icehrm/src/Model/File.php=8211922ac309e1c3e5fc316a90bc0bf0 -/Users/Thilina/Projects/icehrm/src/Data/Admin/Api/AbstractDataImporter.php=315bf5eec45aa13e174d412014e2237f -/Users/Thilina/Projects/icehrm/src/Classes/NotificationManager.php=a739fd4177892d44e78efed1641072cc -/Users/Thilina/Projects/icehrm/src/Utils/SessionUtils.php=f5c4db2214dfb4d8bf5b9bfe5edb1bac -/Users/Thilina/Projects/icehrm/src/Travel/Admin/Api/TravelActionManager.php=0e2fdd403d3456ebda102d554349e9f4 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayrollColumn.php=0f2e8fd9b44c038f163ae646d3c6f4b6 -/Users/Thilina/Projects/icehrm/src/Travel/Common/Model/EmployeeTravelRecord.php=5366a1927bd94630217ffbc9386ff605 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/TravelRequestReport.php=c4bdd4c88f4a7b15c8091a0dcbb5018a -/Users/Thilina/Projects/icehrm/src/Classes/StatusChangeLogManager.php=b091e855d9800eea9d4190e0c75e3e8c -/Users/Thilina/Projects/icehrm/src/Qualifications/Admin/Api/QualificationsAdminManager.php=3037d64a2344a497ff0ceea52265d2a6 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeLeavesReport.php=bd5efb4666ca4103a2e7e98aa24e1c83 -/Users/Thilina/Projects/icehrm/src/TimeSheets/User/Api/TimeSheetsActionManager.php=ef271183cf6e71d8db24b8d3369e19b9 -/Users/Thilina/Projects/icehrm/src/Expenses/Common/Model/ExpensesCategory.php=e9c0e170b950a39994d0a33d5981374f -/Users/Thilina/Projects/icehrm/src/Classes/Email/SwiftMailer.php=eca37dc0add437ae1089c695b5074b90 -/Users/Thilina/Projects/icehrm/src/Data/Admin/Import/AttendanceDataImporter.php=dc4dec4294b9feac08a5f996b85cab85 -/Users/Thilina/Projects/icehrm/src/Salary/Common/Model/PayrollEmployee.php=1a01bd60d1f82fc6f3eeb1875006f659 -/Users/Thilina/Projects/icehrm/src/Classes/Crypt/AesCtr.php=4897c7fe9a510f38eeb91046127d79f7 -/Users/Thilina/Projects/icehrm/src/Classes/AbstractModuleManager.php=5bb9fc5859bdd790753277a47752b0b9 -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/ImmigrationStatus.php=f0dc9a94bcc487df21d53387ae8e89ba -/Users/Thilina/Projects/icehrm/src/Salary/Admin/Api/SalaryAdminManager.php=8bedb5d82608974feedd1c094cac64fa -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/ClassBasedReportBuilder.php=fc77219539745bdb6364fc81bdda2516 -/Users/Thilina/Projects/icehrm/src/Classes/BaseService.php=e0de0276b6a8b58a4e318848a45439b6 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayrollColumnTemplate.php=cb69bf4717cfbaf0f395b931296efd9a -/Users/Thilina/Projects/icehrm/src/Expenses/Admin/Api/ExpensesActionManager.php=2997346b4574ccd83e564c338e38b189 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeTimeTrackReport.php=eddda882fae0c258e97fb50aafe21061 -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/Nationality.php=0f0cd1d95496f95ac9de08aa15e6b6a4 -/Users/Thilina/Projects/icehrm/src/Classes/ReportHandler.php=80b280cae34fdfbee864b05b07c6789a -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/ExpenseReport.php=7c8d187bc57175a92b8bc0fa33e501f0 -/Users/Thilina/Projects/icehrm/src/Overtime/Admin/Api/OvertimeAdminManager.php=7ae7776e6445429a1f0158a5efd38c04 -/Users/Thilina/Projects/icehrm/src/Salary/Common/Model/SalaryComponentType.php=d96878a0b1547f44731830526306ab56 -/Users/Thilina/Projects/icehrm/src/Travel/Common/Model/EmployeeImmigration.php=1dcb690d0045699a1aa65eda033f9adf -/Users/Thilina/Projects/icehrm/src/Classes/MenuItemTemplate.php=7ad7eb3a874ec729ec1baf0760f0b4ed -/Users/Thilina/Projects/icehrm/src/Employees/Admin/Api/EmployeesAdminManager.php=15e983c78e17191ced1a7eec13be0d3e -/Users/Thilina/Projects/icehrm/src/Classes/Cron/CronUtils.php=b55a1fe1c4ed55dc582e208b341f52b4 -/Users/Thilina/Projects/icehrm/src/Overtime/Common/Model/EmployeeOvertimeApproval.php=edd2eedebb9f62a44f0e588c615654ce -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/EmployeeSkill.php=a02c5ceda0489aba4ed47df010d4892e -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/EmployeeAttendanceReport.php=a20c94c986fa57c52daebbcbf4fa1f3f -/Users/Thilina/Projects/icehrm/src/Overtime/User/Api/OvertimeActionManager.php=f6d2c26500ed9e10b90bb5826d6c124e -/Users/Thilina/Projects/icehrm/src/Projects/Common/Model/Client.php=666b6d5ad575ddd9ccc198f5e98e1211 -/Users/Thilina/Projects/icehrm/src/Dependents/User/Api/DependentsModulesManager.php=409b6ea72b6ce0319bb12df6458d2bef -/Users/Thilina/Projects/icehrm/src/Jobs/Common/Model/JobTitle.php=4765635589eb4cc84cec2e578faa1557 -/Users/Thilina/Projects/icehrm/src/Model/Cron.php=4f3da95d8dd8e6b4642e6a2c6390c5fe -/Users/Thilina/Projects/icehrm/src/Projects/Admin/Api/ProjectsAdminManager.php=8f20c5277a8560a69318263166b804e3 -/Users/Thilina/Projects/icehrm/src/Loans/Common/Model/CompanyLoan.php=6e1e409dd612f22b47c6ffdcda4fe3a0 -/Users/Thilina/Projects/icehrm/src/Classes/Migration/MigrationManager.php=10ce5f1187ed06d2b12820a0d9d7e90a -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/ReportsAdminManager.php=be16482fcb8d6714f13618407acf25a5 -/Users/Thilina/Projects/icehrm/src/Utils/CalendarTools.php=9f60bf1aaa928a02163680da60ac255c -/Users/Thilina/Projects/icehrm/src/Data/Admin/Api/DataAdminManager.php=3913dc1f43ae1965956c420d0d9084c8 -/Users/Thilina/Projects/icehrm/src/TimeSheets/Common/Model/EmployeeTimeEntry.php=f69d37222ff6d528b5dde53fcbb5b3a8 -/Users/Thilina/Projects/icehrm/src/Classes/UIManager.php=03b64742f6595dedce18bba1372d4b20 -/Users/Thilina/Projects/icehrm/src/Classes/MemcacheService.php=e07916b1c628686162c19fa26aad93d5 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/EmployeeTimesheetReport.php=2ec16a7dccb131862f295ad97db9067b -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/Country.php=f772b574b2b1310977a50daf9d2a51ef -/Users/Thilina/Projects/icehrm/src/Model/Audit.php=31e7780e4e210a8c840188d2015d2e01 -/Users/Thilina/Projects/icehrm/src/Classes/Approval/ApproveModuleActionManager.php=834a7aad3a07c194a0a830cc353daec9 -/Users/Thilina/Projects/icehrm/src/Loans/Admin/Api/LoansAdminManager.php=0954d425f553598a6f3a9dbefc19fb45 -/Users/Thilina/Projects/icehrm/src/Classes/SubActionManager.php=7523ec5017da87c8d7d3e4438310d96f -/Users/Thilina/Projects/icehrm/src/Model/ApproveModel.php=7f15abbdae78812f15d65e7a165f6115 -/Users/Thilina/Projects/icehrm/src/Classes/CustomFieldManager.php=7259e4d11e73fdd04984097e00233203 -/Users/Thilina/Projects/icehrm/src/Payroll/Admin/Api/PayrollActionManager.php=177d85ae36ed00f8a42d9bb9e8f9aa1a -/Users/Thilina/Projects/icehrm/src/Loans/User/Api/LoansModulesManager.php=4f0650c7b4ab3ec6c241bd32c680dfca -/Users/Thilina/Projects/icehrm/src/Utils/Math/EvalMathStack.php=4b86e2041c19d8ef8eaf7f4ea630e116 -/Users/Thilina/Projects/icehrm/src/Users/Admin/Api/UsersAdminManager.php=695662b7186616d4379d0a588b5130e6 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/Language.php=c904c6e3e2e167f5e79afffabf94716a -/Users/Thilina/Projects/icehrm/src/Classes/Macaw.php=5a2f26ffcb41c9f42af776a91c283572 -/Users/Thilina/Projects/icehrm/src/Attendance/Common/Model/AttendanceStatus.php=ad80af2d596e584a3ab60a5fce4aac09 -/Users/Thilina/Projects/icehrm/src/Classes/Email/SMTPEmailSender.php=0df2a519ce3a2d61d486b9527782f72b -/Users/Thilina/Projects/icehrm/src/FieldNames/Admin/Api/FieldNamesAdminManager.php=5eca8c33ccd8d9fc1c4e5b7fa81ed93c -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayFrequency.php=9207a551d667bab9734aa041e02a1be1 -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/CurrencyType.php=e9f5f17d4e18a706e4c4068f253c01ac -/Users/Thilina/Projects/icehrm/src/Employees/Common/Model/EmployeeApproval.php=481ddd171d66e644bb442ab02e97b097 -/Users/Thilina/Projects/icehrm/src/Data/Admin/Api/DataImporter.php=ad94e2de98e11c1d3f0f0b32c46f358c -/Users/Thilina/Projects/icehrm/src/Expenses/Common/Model/EmployeeExpense.php=29d2dccb5d009d392c4b8f44c59fcdd8 -/Users/Thilina/Projects/icehrm/test/TestTemplate.php=8e6ff185d587f339892a9a720e2bfa5f -/Users/Thilina/Projects/icehrm/src/Classes/Crypt/Aes.php=d0b15a04faf73b0ff35efc308d09b6e7 -/Users/Thilina/Projects/icehrm/src/Classes/LanguageManager.php=8df5d6d62bae8a5e14ab1cd486325af3 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/Education.php=6f992ef2bb13951f3c52f5209d73733b -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/EmployeeLeavesReport.php=0bd5801ac4c9803db53198c68904d5f5 -/Users/Thilina/Projects/icehrm/src/TimeSheets/Common/Model/EmployeeTimeSheet.php=2a4e685315485e4933df5d2ba856d8fb -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/ClientProjectTimeReport.php=f860b3cff536b5074bb7d1e193c1c41d -/Users/Thilina/Projects/icehrm/src/Expenses/User/Api/ExpensesActionManager.php=c8ce93f6877fd2cdbc963b5c38708f04 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/EmployeeAttendanceReport.php=600c1feca3eab6d724ac9661f2f514d5 -/Users/Thilina/Projects/icehrm/src/Utils/Math/EvalMath.php=476cb2ee5306966d7cd7bee2f3202559 -/Users/Thilina/Projects/icehrm/src/Model/Migration.php=3f11c6dfaa18d4a6dcb2caa8d3677121 -/Users/Thilina/Projects/icehrm/src/Data/Common/Model/DataImportFile.php=a0b3f8410e80862ba79aa9d8fed383d7 -/Users/Thilina/Projects/icehrm/src/Travel/User/Api/TravelActionManager.php=e6241358886dc00138506f3bc4d13346 -/Users/Thilina/Projects/icehrm/src/Company/Common/Model/CompanyStructure.php=a1957202858bc093b29e8dfe48955cc6 -/Users/Thilina/Projects/icehrm/src/Classes/Migration/AbstractMigration.php=324fe15e15a0ca2b0f50f4029ae10548 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/EmployeeCertification.php=96045388cba569f4ea9617dc8fbeded6 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayslipTemplate.php=cc9bf7552cfccd84a0b9b1431f224f1f -/Users/Thilina/Projects/icehrm/test/test.includes.php=d87bcd9386b3271b62818e2b86df6c28 -/Users/Thilina/Projects/icehrm/src/Company/Admin/Api/CompanyAdminManager.php=484a8b669d5fed117f1f40f289f2c6f4 -/Users/Thilina/Projects/icehrm/src/Classes/Email/PHPMailer.php=54789d10177cc5075cb4d50838b05821 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/EmployeeEducation.php=8ba4cbc034b5ee23d593cc3352cf46a9 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Reports/TerminatedEmployeeReport.php=1b8b58d6e85eb77e45aaf44f426025ea -/Users/Thilina/Projects/icehrm/src/Users/Admin/Api/UsersEmailSender.php=87247955c331115e482aa3e577eca0b4 -/Users/Thilina/Projects/icehrm/src/Classes/IceConstants.php=5f7497997d12c27dab080b6f34640df1 -/Users/Thilina/Projects/icehrm/test/test.config.php=2d82ac9b697f10bb9bd6d760f63d2be4 -/Users/Thilina/Projects/icehrm/src/Travel/Common/Model/ImmigrationDocument.php=c0636d2ce3e7d89d9e4ebb00c8d1450f -/Users/Thilina/Projects/icehrm/src/Classes/ModuleBuilder/ModuleBuilder.php=29fed2a27587032060efc02c7a30a838 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/PayslipReport.php=a7197be66726cf126c196bf6beccb907 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/EmployeeTimeTrackReport.php=ce6f2b098845233342c336f837001554 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/PDFReportBuilderInterface.php=cc049c4c1b86e5a5e4fd99ddf24e563d -/Users/Thilina/Projects/icehrm/src/Qualifications/User/Api/QualificationsModulesManager.php=e668d64139ecc146af9ebaea2f91e1fe -/Users/Thilina/Projects/icehrm/src/Classes/RestEndPoint.php=86136262a2e2a8f45564d17123dd5812 -/Users/Thilina/Projects/icehrm/src/Classes/S3FileSystem.php=6308aca72380cef1981625946b59652f -/Users/Thilina/Projects/icehrm/src/Classes/Cron/Task/EmailIceTask.php=b754a286061db310b3f18677946d7b43 -/Users/Thilina/Projects/icehrm/src/Data/Admin/Import/EmployeeDataImporter.php=d1b66e2d042335df792fa8913d363d5f -/Users/Thilina/Projects/icehrm/src/Projects/Common/Model/EmployeeProject.php=b0de956de8ec4c423604195b96f57df9 -/Users/Thilina/Projects/icehrm/src/Model/Report.php=498c96015d1be2b31d8cd0bcedea7fab -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/CustomFieldValue.php=a9b7d8db9ee113345298ba49f9354be8 -/Users/Thilina/Projects/icehrm/src/Classes/Cron/IceCron.php=edb023962095493d7daa728793ceaf9c -/Users/Thilina/Projects/icehrm/src/Settings/Admin/Api/SettingsInitialize.php=148bc391f5d101121f915a590f991a6b -/Users/Thilina/Projects/icehrm/src/Dashboard/Admin/Api/DashboardActionManager.php=5e8e996f9f4b77f1fbd10e026a5d1351 -/Users/Thilina/Projects/icehrm/src/Payroll/Admin/Api/PayrollAdminManager.php=9bac9a6ed8406c9eb6fe7ef666aee482 -/Users/Thilina/Projects/icehrm/src/Jobs/Admin/Api/JobsAdminManager.php=12546328edffcc5bda7e84f6a8c56d9e -/Users/Thilina/Projects/icehrm/src/Jobs/Common/Model/PayGrade.php=55f2f83ff22136154b14460b6b37632a -/Users/Thilina/Projects/icehrm/src/EmergencyContacts/Common/Model/EmergencyContact.php=6ec07210d94e695732c6d1a6a0fb34be -/Users/Thilina/Projects/icehrm/src/Employees/Admin/Api/EmployeesActionManager.php=63c6ccf63f54eab8556c893cf47f983c -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/CalculationHook.php=bbfa6f83e4042db9640b67c131274118 -/Users/Thilina/Projects/icehrm/src/Users/Common/Model/User.php=cc9b6c966b40678574fdd35bb1f16cb2 -/Users/Thilina/Projects/icehrm/src/Users/Admin/Api/UsersActionManager.php=b65c97c665190f9fb011cc8d0b97888c -/Users/Thilina/Projects/icehrm/src/Attendance/User/Api/AttendanceModulesManager.php=f1b34fae71cc963e197b41ed2ca032ca -/Users/Thilina/Projects/icehrm/src/Classes/IceResponse.php=bb74495c33fab87e96f72b610cfd5374 -/Users/Thilina/Projects/icehrm/src/Qualifications/Common/Model/Certification.php=e81a7f90a10799d97a918e2cb071c1a9 -/Users/Thilina/Projects/icehrm/src/Model/BaseModel.php=d932a9bb126c174000b9c51a8cb4d2f6 -/Users/Thilina/Projects/icehrm/src/Model/StatusChangeLog.php=0745140bddda3f06915dcfcc6ac97ce8 -/Users/Thilina/Projects/icehrm/src/Classes/AbstractInitialize.php=841a38244ca1d44b008f67a6b45df348 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/EmployeeTimeSheetData.php=2d6e95947963949b1c5150269d7527f7 -/Users/Thilina/Projects/icehrm/src/Data/Admin/Api/DataActionManager.php=82f3ced08b946ca6e10a83c6e07475db -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/OvertimeReport.php=431965980b2458019398d2ed6d7fc39a -/Users/Thilina/Projects/icehrm/src/Metadata/Common/Model/Ethnicity.php=5f5935cdeab1b41ac0d2db9f6973f6b0 -/Users/Thilina/Projects/icehrm/test/integration/MigrationManagerIntegration.php=f0f5bccf120067b34396f1e61fd6d20a -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/CSVReportBuilderInterface.php=6ada9a15e850c09162fc75020d6b00e4 -/Users/Thilina/Projects/icehrm/src/Payroll/Common/Model/PayrollCalculations.php=70d1b733b1adbb6c6a2ea0dcec89efca -/Users/Thilina/Projects/icehrm/src/Travel/Admin/Api/TravelAdminManager.php=9b3c6e369e2264d2bc9fca122e8ed90c -/Users/Thilina/Projects/icehrm/src/Model/ReportFile.php=0a766e94902b5473ef1fa24583cf2481 -/Users/Thilina/Projects/icehrm/src/Modules/Admin/Api/ModulesActionManager.php=c4d592d8930201a883a5d1ea71a037af -/Users/Thilina/Projects/icehrm/src/Model/IceEmail.php=02bd3cd01cb37ab05d763e468cba3835 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/ReportBuilderInterface.php=dd7e723c48ec4f97db98ffec0d0f39cb -/Users/Thilina/Projects/icehrm/src/TimeSheets/User/Api/TimeSheetsModulesManager.php=63a8c4364cd579be46b60a2e83f8f87f -/Users/Thilina/Projects/icehrm/src/Employees/Common/Model/ArchivedEmployee.php=6056e5073538c0d7a22dea52b6c25374 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/ReportBuilder.php=9b0e8e996157caebcf17a2a342ba0f6e -/Users/Thilina/Projects/icehrm/src/Users/Common/Model/UserRole.php=8d7dbcdf68c2c5a7a4d4f73dbb07d63b -/Users/Thilina/Projects/icehrm/src/Salary/Common/Model/PayFrequency.php=fab16310b7db7bb9aace5a6b038c9d2a -/Users/Thilina/Projects/icehrm/src/Model/Notification.php=0b06b249e456508d5a8ce06b453efe6b -/Users/Thilina/Projects/icehrm/src/Attendance/Admin/Api/AttendanceDashboardManager.php=c08fc7c021dd0c0780851c308225291f -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/TravelRequestReport.php=810d405042307fe9c6ca82e082c3673e -/Users/Thilina/Projects/icehrm/src/Attendance/Common/Model/Attendance.php=aa0945e6fc70e6e3418d0e09f7110082 -/Users/Thilina/Projects/icehrm/src/Employees/Common/Model/EmploymentStatus.php=11365db49528f08847e0dfbf1b31472d -/Users/Thilina/Projects/icehrm/src/Attendance/Admin/Api/AttendanceAdminManager.php=21e4a22a3eb290704181e5a4a7a5df7a -/Users/Thilina/Projects/icehrm/src/Classes/HistoryManager.php=4741dd856bb81ec2e27bd016afb8e042 -/Users/Thilina/Projects/icehrm/src/Dashboard/Admin/Api/DashboardAdminManager.php=800b72969de1b8c311a8e1b7d2940c79 -/Users/Thilina/Projects/icehrm/src/Overtime/User/Api/OvertimeModulesManager.php=b29d52a4e3f021cdd786f41cbf1b9837 -/Users/Thilina/Projects/icehrm/src/Reports/User/Reports/OvertimeSummaryReport.php=3918d7210957040977b8a43c580abae0 -/Users/Thilina/Projects/icehrm/src/Classes/ModuleBuilder/ModuleTab.php=89136363d7520967c2d42e175052f4d5 -/Users/Thilina/Projects/icehrm/src/Reports/Admin/Api/CSVReportBuilder.php=5c5f7175cc2aff776388c3281cea9cf3 -/Users/Thilina/Projects/icehrm/src/Model/Setting.php=5b9440e9211662f5ed69f29794b6054d -/Users/Thilina/Projects/icehrm/src/FieldNames/Common/Model/CustomField.php=88578da07f1f07bae868e17b4a8e4cf7 -/Users/Thilina/Projects/icehrm/src/Attendance/User/Api/AttendanceActionManager.php=feaa97dd192e7faec2045aba7dc03125 -/Users/Thilina/Projects/icehrm/src/Overtime/Common/Model/OvertimeCategory.php=e9c90b23155e3fe1c7d9dd9cef462d1e -/Users/Thilina/Projects/icehrm/src/Attendance/Common/Calculations/CaliforniaOvertimeCalculator.php=a1a5ff46939030747f505710fbd49ffd +#Fri Feb 01 06:41:09 GMT+00:00 2019 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Admin/Api/AttendanceUtil.php=34fe63a4c0f954451afae6c359ea5b38 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/ClientProjectTimeReport.php=f860b3cff536b5074bb7d1e193c1c41d +/Users/Thilina/Projects/icehrm-open/core/src/Classes/S3FileSystem.php=6308aca72380cef1981625946b59652f +/vagrant/core/src/Classes/AbstractInitialize.php=a6e16a53a0178bc30b27dcf3684fbdad +/vagrant/core/src/Reports/User/Reports/EmployeeTimeSheetData.php=2d6e95947963949b1c5150269d7527f7 +/vagrant/core/src/Classes/ReportHandler.php=80b280cae34fdfbee864b05b07c6789a +/vagrant/core/src/Classes/Migration/AbstractMigration.php=324fe15e15a0ca2b0f50f4029ae10548 +/vagrant/core/src/Classes/Crypt/AesCtr.php=4897c7fe9a510f38eeb91046127d79f7 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Approval/ApproveAdminActionManager.php=01eaf59752e8379205bc52f3278f96fc +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Api/DataActionManager.php=82f3ced08b946ca6e10a83c6e07475db +/Users/Thilina/Projects/icehrm-open/core/src/Utils/CalendarTools.php=9f60bf1aaa928a02163680da60ac255c +/vagrant/core/src/Data/Admin/Api/DataAdminManager.php=3913dc1f43ae1965956c420d0d9084c8 +/vagrant/core/src/Travel/User/Api/TravelActionManager.php=d055895c69bafe0b6855566dc4054699 +/vagrant/core/src/Reports/Admin/Reports/ExpenseReport.php=397c8deb446994b64e2b9fef2845bb89 +/vagrant/core/src/Metadata/Common/Model/CurrencyType.php=0fc8e338a2f0f149ac24757427470971 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/Nationality.php=639ee9f14c53032ff26e7105c2219593 +/vagrant/core/src/Classes/Migration/MigrationManager.php=b2a6fae32ad9370a4e3375a623330fa7 +/Users/Thilina/Projects/icehrm-open/core/src/Projects/Common/Model/EmployeeProject.php=b0de956de8ec4c423604195b96f57df9 +/vagrant/core/src/Classes/Cron/IceCron.php=217fba4cf5ce69cdf734447f6a45b356 +/Users/Thilina/Projects/icehrm-open/core/src/Dashboard/Admin/Api/DashboardAdminManager.php=800b72969de1b8c311a8e1b7d2940c79 +/Users/Thilina/Projects/icehrm-open/test/bootstrap.php=0e9cfabb3aec1ac52ecf4d27334f2624 +/vagrant/core/src/Reports/Admin/Reports/EmployeeTimesheetReport.php=8661944cf39b10c441841a8af72cb988 +/vagrant/core/src/Company/Admin/Api/CompanyAdminManager.php=484a8b669d5fed117f1f40f289f2c6f4 +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/User/Api/QualificationsModulesManager.php=e668d64139ecc146af9ebaea2f91e1fe +/vagrant/core/src/Loans/Common/Model/EmployeeCompanyLoan.php=abc8959df2ec0f3e19ff6da12c3163f9 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/Province.php=0ff661394cbcfec7f514f2d5eae7ca25 +/Users/Thilina/Projects/icehrm-open/core/src/Salary/User/Api/SalaryModulesManager.php=050d077e79532353a7d12a7221829b7c +/vagrant/core/src/Utils/Math/EvalMathFuncs.php=d6f7c26eab307d205ee8483d87a380cb +/vagrant/core/src/Metadata/Common/Model/Nationality.php=639ee9f14c53032ff26e7105c2219593 +/vagrant/core/src/Data/Common/Model/DataImport.php=a6af4d8acd5585932823889509cca581 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeTimeTrackReport.php=eddda882fae0c258e97fb50aafe21061 +/Users/Thilina/Projects/icehrm-open/core/src/FieldNames/Admin/Api/FieldNamesAdminManager.php=5eca8c33ccd8d9fc1c4e5b7fa81ed93c +/vagrant/core/src/Projects/Common/Model/Project.php=05b1cd967d67cb977558f2567d7f6cb6 +/Users/Thilina/Projects/icehrm-open/test/integration/ApprovalStatusIntegration.php=8b9243e5cbb302513d906ff9de246acd +/Users/Thilina/Projects/icehrm-open/test/TestTemplate.php=8e6ff185d587f339892a9a720e2bfa5f +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Admin/Api/EmployeesAdminManager.php=15e983c78e17191ced1a7eec13be0d3e +/vagrant/core/src/Payroll/Common/Model/PayrollCalculations.php=70d1b733b1adbb6c6a2ea0dcec89efca +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Data/Query/DataQuery.php=eae53f27055f569d43fd2cad06b7beff +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeDetailsReport.php=1e415e088afc4fc56e3cbf77af8f84c5 +/vagrant/core/src/Dashboard/Admin/Api/DashboardActionManager.php=5e8e996f9f4b77f1fbd10e026a5d1351 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/BaseService.php=92bd3a9bb4e7eb84e079b0db75d5f752 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Approval/ApprovalStatus.php=7a3bc0a73f237eb677254b245887f48f +/vagrant/core/src/Model/Audit.php=6259d9e1d7e7777bb8cde096bdc742aa +/vagrant/core/src/Utils/Math/EvalMathStack.php=4b86e2041c19d8ef8eaf7f4ea630e116 +/vagrant/core/src/Reports/Admin/Reports/PayrollDataExport.php=83bd6faa73c75667ecf25091c3729abc +/vagrant/test/integration/ApprovalStatusIntegration.php=cff0c3e3e051bf87d6a5313655b741cd +/vagrant/core/src/Employees/Common/Model/EmployeeApproval.php=481ddd171d66e644bb442ab02e97b097 +/Users/Thilina/Projects/icehrm-open/core/src/EmergencyContacts/Common/Model/EmergencyContact.php=6ec07210d94e695732c6d1a6a0fb34be +/vagrant/core/src/Users/Common/Model/User.php=ad497e45b540b026aa80fa58f5055cc1 +/Users/Thilina/Projects/icehrm-open/core/src/Company/Common/Model/CompanyStructure.php=a1957202858bc093b29e8dfe48955cc6 +/Users/Thilina/Projects/icehrm-open/test/test.includes.php=66d627b31f3f6b76f1739a54e7d9fd9f +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Approval/ApproveModuleActionManager.php=834a7aad3a07c194a0a830cc353daec9 +/vagrant/core/src/Reports/User/Reports/TravelRequestReport.php=810d405042307fe9c6ca82e082c3673e +/Users/Thilina/Projects/icehrm-open/core/src/Users/Common/Model/UserRole.php=9f9021a51c94b25e203cc3c0322c80d7 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/Payroll.php=8aa76dfc05183abe955552b15e3c4351 +/vagrant/core/src/Classes/PermissionManager.php=149c16e23f9066538e9c7a0ee3bb397f +/vagrant/core/src/Employees/User/Api/EmployeesActionManager.php=e34f4fe38b3e0eb45cb65232fa6ec359 +/vagrant/core/src/Classes/Email/SwiftMailer.php=eca37dc0add437ae1089c695b5074b90 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeLeaveEntitlementReport.php=9be41bfeb88fd0171028203f6513c799 +/vagrant/core/src/Projects/Admin/Api/ProjectsAdminManager.php=8f20c5277a8560a69318263166b804e3 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/EmployeeTimeSheetData.php=2d6e95947963949b1c5150269d7527f7 +/vagrant/core/src/Employees/User/Api/EmployeesModulesManager.php=ad9ab05afd9cf551870352dba82e6d69 +/vagrant/core/src/Reports/Admin/Reports/EmployeeTimeSheetData.php=9d612ee603fdf4e6b710eec725da2656 +/Users/Thilina/Projects/icehrm-open/core/src/Travel/User/Api/TravelActionManager.php=d055895c69bafe0b6855566dc4054699 +/vagrant/core/src/Metadata/Common/Model/ImmigrationStatus.php=f0dc9a94bcc487df21d53387ae8e89ba +/vagrant/test/test.config.php=68587cbb63b8a37dc07fdac177eb23a4 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Common/Model/Employee.php=1e8f3958597a1d2f138e927115671538 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/IceResponse.php=bb74495c33fab87e96f72b610cfd5374 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/OvertimeSummaryReport.php=3918d7210957040977b8a43c580abae0 +/vagrant/core/src/Travel/Common/Model/ImmigrationDocument.php=c0636d2ce3e7d89d9e4ebb00c8d1450f +/vagrant/core/src/Reports/Admin/Reports/OvertimeSummaryReport.php=16d9e2f10de82f25d0965e2d327086b9 +/vagrant/core/src/Jobs/Common/Model/PayGrade.php=9cc01a86f03deb884884681a73deb27a +/vagrant/core/src/Classes/RestEndPoint.php=48bd6506bb12af195f32d65c0ae635f2 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Admin/Api/PayrollActionManager.php=c95c4e2ae643a16b8e59fa73dc1f0193 +/vagrant/core/src/Data/Admin/Import/EmployeeDataImporter.php=d1b66e2d042335df792fa8913d363d5f +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/User/Api/TimeSheetsModulesManager.php=63a8c4364cd579be46b60a2e83f8f87f +/vagrant/test/bootstrap.php=0e9cfabb3aec1ac52ecf4d27334f2624 +/vagrant/core/src/Salary/Common/Model/PayrollEmployee.php=1a01bd60d1f82fc6f3eeb1875006f659 +/vagrant/core/src/Employees/Admin/Api/EmployeesAdminManager.php=15e983c78e17191ced1a7eec13be0d3e +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/EmployeeLanguage.php=66127455502fb29181324c1cc25f93c4 +/Users/Thilina/Projects/icehrm-open/core/src/Model/Cron.php=9e638c23f7cb93500a1b1f1ef4edf86f +/Users/Thilina/Projects/icehrm-open/core/src/Utils/SessionUtils.php=cdb9d769cf1f51bab1462ddac2387e81 +/vagrant/core/src/Classes/Cron/Task/EmailIceTask.php=b754a286061db310b3f18677946d7b43 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Common/Model/EmployeeOvertime.php=4275d184646684892b289524b33cf9d7 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Macaw.php=5a2f26ffcb41c9f42af776a91c283572 +/Users/Thilina/Projects/icehrm-open/core/src/StaffDirectory/Common/Model/StaffDirectory.php=73f3c132e741460f200be3b3100833f6 +/vagrant/core/src/Jobs/Admin/Api/JobsAdminManager.php=12546328edffcc5bda7e84f6a8c56d9e +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/User/Api/OvertimeModulesManager.php=b29d52a4e3f021cdd786f41cbf1b9837 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Common/Model/Attendance.php=aa0945e6fc70e6e3418d0e09f7110082 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Common/Model/EmploymentStatus.php=6e72924fac0cecc49aaf070389f8d73a +/Users/Thilina/Projects/icehrm-open/core/src/Modules/Common/Model/Module.php=6930680c77dfbcd410e1425c76511c16 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Common/Model/DataImport.php=a6af4d8acd5585932823889509cca581 +/vagrant/core/src/Modules/Admin/Api/ModulesActionManager.php=a4f9c92a8f6de83ed72c5f775369b883 +/Users/Thilina/Projects/icehrm-open/core/src/Dependents/User/Api/DependentsModulesManager.php=409b6ea72b6ce0319bb12df6458d2bef +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Common/Model/PayFrequency.php=fab16310b7db7bb9aace5a6b038c9d2a +/Users/Thilina/Projects/icehrm-open/core/src/Classes/FileService.php=b948c3e305263af82269976e01af17c4 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Crypt/AesCtr.php=4897c7fe9a510f38eeb91046127d79f7 +/Users/Thilina/Projects/icehrm-open/core/src/FieldNames/Common/Model/CustomField.php=32400d304e8064e69624311c3c80dffb +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/Country.php=be5371104ea0bbfa7132201d5e31e62f +/vagrant/core/src/EmergencyContacts/Common/Model/EmergencyContact.php=6ec07210d94e695732c6d1a6a0fb34be +/Users/Thilina/Projects/icehrm-open/core/src/Settings/Admin/Api/SettingsAdminManager.php=5e5df0056db6f9593128720581feca18 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/Ethnicity.php=5f5935cdeab1b41ac0d2db9f6973f6b0 +/vagrant/core/src/TimeSheets/User/Api/TimeSheetsPayrollUtils.php=85db5b3cf330d2010ac14aaff1bccc2a +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeLeavesReport.php=bd5efb4666ca4103a2e7e98aa24e1c83 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/User/Api/EmployeesModulesManager.php=ad9ab05afd9cf551870352dba82e6d69 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/IceCron.php=217fba4cf5ce69cdf734447f6a45b356 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Api/DataImporter.php=ad94e2de98e11c1d3f0f0b32c46f358c +/vagrant/core/src/Loans/User/Api/LoansModulesManager.php=4f0650c7b4ab3ec6c241bd32c680dfca +/Users/Thilina/Projects/icehrm-open/test/unit/UserAttendanceActionManagerUnit.php=1d71d366a13f253ef6931aa87202ac42 +/vagrant/core/src/Attendance/Common/Calculations/BasicOvertimeCalculator.php=9c96ae3f71796029d3f93e5c63783f53 +/vagrant/core/src/Reports/Admin/Api/PDFReportBuilder.php=fbbc196b5ea432671667bcc239d8bf54 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/PDFReportBuilderInterface.php=cc049c4c1b86e5a5e4fd99ddf24e563d +/vagrant/core/src/Reports/Admin/Api/CSVReportBuilderInterface.php=6ada9a15e850c09162fc75020d6b00e4 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Common/Model/AttendanceStatus.php=ad80af2d596e584a3ab60a5fce4aac09 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/CurrencyType.php=0fc8e338a2f0f149ac24757427470971 +/vagrant/test/integration/MigrationManagerIntegration.php=f0f5bccf120067b34396f1e61fd6d20a +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Common/Model/PayrollEmployee.php=1a01bd60d1f82fc6f3eeb1875006f659 +/vagrant/core/src/Reports/User/Reports/ExpenseReport.php=7c8d187bc57175a92b8bc0fa33e501f0 +/vagrant/core/src/Model/UserReport.php=0a8a8476e3088011cc54fda139567b56 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/LanguageManager.php=e019a01be56a46a93177a50340fc3eea +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/Education.php=327f74726fca1a976e2fc6272ffecdea +/vagrant/core/src/TimeSheets/Common/Model/QTDays.php=32a00e65a966331b776dc37cc0609edf +/vagrant/core/src/TimeSheets/User/Api/TimeSheetsInitialize.php=d47372f12494019c1004a04cbe57013d +/Users/Thilina/Projects/icehrm-open/test/helper/EmployeeTestDataHelper.php=65ec2048653c9e4e4359d9b6967a860d +/vagrant/core/src/Classes/Approval/ApprovalStatus.php=7a3bc0a73f237eb677254b245887f48f +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/User/Api/AttendanceModulesManager.php=f1b34fae71cc963e197b41ed2ca032ca +/vagrant/core/src/Reports/User/Reports/OvertimeReport.php=431965980b2458019398d2ed6d7fc39a +/vagrant/core/src/Overtime/User/Api/OvertimeActionManager.php=5ace85f1fdbd23f5adc8d089f2d6b5fa +/vagrant/core/src/Model/File.php=3bc6c71925ad1e20721ffd63567c7783 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Admin/Api/OvertimeAdminManager.php=701c52c0bca0b0d89c5bb8e7cbafac8e +/vagrant/core/src/Settings/Admin/Api/SettingsInitialize.php=148bc391f5d101121f915a590f991a6b +/vagrant/core/src/Utils/SessionUtils.php=cdb9d769cf1f51bab1462ddac2387e81 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/CronUtils.php=b55a1fe1c4ed55dc582e208b341f52b4 +/vagrant/core/src/Reports/Admin/Api/CSVReportBuilder.php=5c5f7175cc2aff776388c3281cea9cf3 +/Users/Thilina/Projects/icehrm-open/core/src/Projects/User/Api/ProjectsModulesManager.php=4fc0463507ca7768a1e493d703ac2581 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayrollColumn.php=0f2e8fd9b44c038f163ae646d3c6f4b6 +/vagrant/core/src/Classes/SimpleImage.php=fdfb7b2e71e14975ebce16de44ea9dee +/vagrant/core/src/Dashboard/User/Api/DashboardActionManager.php=3f797cf4807ad5cd4f881607142df049 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/SettingsManager.php=ebed24cde74d7fb33cca4ba156389760 +/vagrant/core/src/FieldNames/Common/Model/FieldNameMapping.php=e3e81b3a4e0f6c74cd687038632107d8 +/vagrant/core/src/Reports/Admin/Reports/NewHiresEmployeeReport.php=64eab525953538d481dab6052dd76d81 +/vagrant/core/src/Classes/Email/SNSEmailSender.php=fa905e3ab63ea745c591e744d6741b6b +/Users/Thilina/Projects/icehrm-open/core/src/Model/ApproveModel.php=97c98d153a6cca455cbeb0b637eac098 +/vagrant/core/src/Jobs/Common/Model/JobTitle.php=2f24525e14942c7f284a44c8e416cd34 +/Users/Thilina/Projects/icehrm-open/core/src/Loans/Common/Model/EmployeeCompanyLoan.php=abc8959df2ec0f3e19ff6da12c3163f9 +/vagrant/core/src/Loans/Common/Model/CompanyLoan.php=cca60a4d5fa1189cdbd35146b010a2c7 +/vagrant/core/src/Reports/User/Reports/PayslipReport.php=7582da680dd305d073faf95d268083cd +/vagrant/core/src/Classes/FileService.php=b948c3e305263af82269976e01af17c4 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Common/Model/ArchivedEmployee.php=6056e5073538c0d7a22dea52b6c25374 +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/Skill.php=293e642127ea74960ebd79d81f11b0f9 +/Users/Thilina/Projects/icehrm-open/core/src/Model/Notification.php=fe1cf65671434bc29c8d17a78577e1f3 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/SupportedLanguage.php=3ec1220796f6e33641998a33f036d709 +/vagrant/core/src/FieldNames/Admin/Api/FieldNamesAdminManager.php=5eca8c33ccd8d9fc1c4e5b7fa81ed93c +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/User/Api/TimeSheetsPayrollUtils.php=85db5b3cf330d2010ac14aaff1bccc2a +/vagrant/core/src/Reports/Admin/Reports/EmployeeTimeTrackReport.php=eddda882fae0c258e97fb50aafe21061 +/Users/Thilina/Projects/icehrm-open/core/src/StaffDirectory/Rest/StaffDirectoryRestEndPoint.php=ba417b136c9c65cd5096c3bde7d141c2 +/vagrant/core/src/Classes/Approval/ApproveCommonActionManager.php=c1b7efb8c4f3fe8199c7e0d6fdd1ccce +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/ReportBuilderInterface.php=dd7e723c48ec4f97db98ffec0d0f39cb +/vagrant/core/src/Reports/Admin/Reports/EmployeeDetailsReport.php=1e415e088afc4fc56e3cbf77af8f84c5 +/vagrant/core/src/Qualifications/Common/Model/Skill.php=293e642127ea74960ebd79d81f11b0f9 +/Users/Thilina/Projects/icehrm-open/test/integration/MigrationManagerIntegration.php=f0f5bccf120067b34396f1e61fd6d20a +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/EmployeeEducation.php=8ba4cbc034b5ee23d593cc3352cf46a9 +/vagrant/core/src/Overtime/Common/Model/OvertimeCategory.php=49198d964e954be3d427e3a7a29a6443 +/vagrant/core/src/Data/Admin/Import/PayrollDataImporter.php=7350ec94ef8a70ba6c263e53c70c7073 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/TravelRequestReport.php=c4bdd4c88f4a7b15c8091a0dcbb5018a +/vagrant/core/src/Classes/Email/SMTPEmailSender.php=0df2a519ce3a2d61d486b9527782f72b +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/EmployeeTimesheetReport.php=2ec16a7dccb131862f295ad97db9067b +/Users/Thilina/Projects/icehrm-open/core/src/Utils/Math/EvalMathFuncs.php=d6f7c26eab307d205ee8483d87a380cb +/vagrant/core/src/Qualifications/Common/Model/EmployeeCertification.php=96045388cba569f4ea9617dc8fbeded6 +/vagrant/core/src/Classes/AbstractModuleManager.php=69d73f9f71155445c32222050528b2e0 +/vagrant/core/src/Classes/Approval/ApproveModuleActionManager.php=834a7aad3a07c194a0a830cc353daec9 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/Task/EmailIceTask.php=b754a286061db310b3f18677946d7b43 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/ActiveEmployeeReport.php=261180dfbe69ab83d9d63646111695ba +/vagrant/core/src/Classes/Macaw.php=5a2f26ffcb41c9f42af776a91c283572 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Common/Calculations/CaliforniaOvertimeCalculator.php=a1a5ff46939030747f505710fbd49ffd +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/EmployeeSkill.php=a02c5ceda0489aba4ed47df010d4892e +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/EmployeeAttendanceReport.php=600c1feca3eab6d724ac9661f2f514d5 +/Users/Thilina/Projects/icehrm-open/core/src/Users/Admin/Api/UsersAdminManager.php=695662b7186616d4379d0a588b5130e6 +/Users/Thilina/Projects/icehrm-open/core/src/Users/Admin/Api/UsersActionManager.php=52c9dc80e7d81e244b5f0ed9a90693cd +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/OvertimeReport.php=431965980b2458019398d2ed6d7fc39a +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/ReportsAdminManager.php=be16482fcb8d6714f13618407acf25a5 +/vagrant/core/src/Reports/User/Reports/EmployeeTimeTrackReport.php=ce6f2b098845233342c336f837001554 +/vagrant/core/src/Classes/LDAPManager.php=e88dd0634a6ca372564faa5a1d540796 +/vagrant/core/src/Classes/Email/PHPMailer.php=54789d10177cc5075cb4d50838b05821 +/Users/Thilina/Projects/icehrm-open/core/src/Company/Common/Model/Timezone.php=50aff3bc39221658c35041abdc55ad98 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Data/DataReader.php=b788e0ab03f397f845ee49427f9689da +/vagrant/core/src/Utils/LogManager.php=144ebae4d0ff60f0fd21e79a45aa6e6a +/Users/Thilina/Projects/icehrm-open/core/src/Utils/Math/EvalMathStack.php=4b86e2041c19d8ef8eaf7f4ea630e116 +/Users/Thilina/Projects/icehrm-open/core/src/Model/IceEmail.php=02bd3cd01cb37ab05d763e468cba3835 +/vagrant/core/src/Users/Admin/Api/UsersAdminManager.php=695662b7186616d4379d0a588b5130e6 +/Users/Thilina/Projects/icehrm-open/core/src/Model/UserReport.php=0a8a8476e3088011cc54fda139567b56 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Import/EmployeeDataImporter.php=d1b66e2d042335df792fa8913d363d5f +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Common/Model/EmployeeImmigration.php=1dcb690d0045699a1aa65eda033f9adf +/vagrant/core/src/Classes/UIManager.php=b43c282c50f732086e6cc07381794cf6 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Admin/Api/OvertimePayrollUtils.php=839c6f828000c302512d8d3058286506 +/vagrant/core/src/Model/ApproveModel.php=97c98d153a6cca455cbeb0b637eac098 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/ReportBuilder.php=9b0e8e996157caebcf17a2a342ba0f6e +/Users/Thilina/Projects/icehrm-open/core/src/Loans/Admin/Api/LoansAdminManager.php=0954d425f553598a6f3a9dbefc19fb45 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/OvertimeRequestReport.php=3cd3bc887da768a32bfc61c152489528 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Admin/Api/MetadataAdminManager.php=9f383f9c34ec98a8e2e701825c548a8a +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Data/Query/FieldMapping.php=59bf4b2160b88d4ceb3729588b341b64 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/HistoryManager.php=4741dd856bb81ec2e27bd016afb8e042 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Common/Model/EmployeeOvertimeApproval.php=edd2eedebb9f62a44f0e588c615654ce +/vagrant/core/src/Qualifications/Common/Model/Language.php=16759d70f3d52e38cbe81abed9b220d8 +/vagrant/core/src/Attendance/Admin/Api/AttendanceDashboardManager.php=c08fc7c021dd0c0780851c308225291f +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Email/SNSEmailSender.php=fa905e3ab63ea745c591e744d6741b6b +/Users/Thilina/Projects/icehrm-open/core/src/Modules/Admin/Api/ModulesAdminManager.php=e0bc5316cc3c7c6e214761c54e738e9c +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/TerminatedEmployeeReport.php=1b8b58d6e85eb77e45aaf44f426025ea +/vagrant/core/src/Model/Notification.php=fe1cf65671434bc29c8d17a78577e1f3 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Migration/AbstractMigration.php=324fe15e15a0ca2b0f50f4029ae10548 +/vagrant/core/src/Dashboard/User/Api/DashboardModulesManager.php=2e8968121b445353ee864c76c44483d3 +/Users/Thilina/Projects/icehrm-open/core/src/Loans/User/Api/LoansModulesManager.php=4f0650c7b4ab3ec6c241bd32c680dfca +/Users/Thilina/Projects/icehrm-open/core/src/Modules/Admin/Api/ModulesActionManager.php=a4f9c92a8f6de83ed72c5f775369b883 +/vagrant/core/src/Classes/CustomFieldManager.php=ed6fd78e1a485b2dc05e4fe683ec4731 +/vagrant/core/src/Loans/Admin/Api/LoansAdminManager.php=0954d425f553598a6f3a9dbefc19fb45 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Admin/Api/AttendanceActionManager.php=ebf11e8f9395c7ef272b08c8f1fcd22c +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/Certification.php=39426e51081f6385feb4803f6a62e937 +/vagrant/core/src/Reports/Admin/Reports/EmployeeAttendanceReport.php=a20c94c986fa57c52daebbcbf4fa1f3f +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/Common/Model/QTDays.php=32a00e65a966331b776dc37cc0609edf +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/PDFReportBuilder.php=fbbc196b5ea432671667bcc239d8bf54 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/Task/EmailSenderTask.php=f0c93e7c807706922cb812723e51bd09 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/ExpenseReport.php=397c8deb446994b64e2b9fef2845bb89 +/vagrant/core/src/Dashboard/Admin/Api/DashboardAdminManager.php=800b72969de1b8c311a8e1b7d2940c79 +/vagrant/core/src/Classes/ModuleBuilder/ModuleTab.php=89136363d7520967c2d42e175052f4d5 +/Users/Thilina/Projects/icehrm-open/core/src/Dependents/Common/Model/EmployeeDependent.php=1f4b6cd6dfbc14269b53dbbac3730f9e +/Users/Thilina/Projects/icehrm-open/core/src/Utils/Math/EvalMath.php=bdae5673431ca215e080d3b0aa0f74c8 +/vagrant/core/src/Utils/CalendarTools.php=9f60bf1aaa928a02163680da60ac255c +/Users/Thilina/Projects/icehrm-open/core/src/Jobs/Common/Model/JobTitle.php=2f24525e14942c7f284a44c8e416cd34 +/vagrant/core/src/StaffDirectory/User/Api/StaffDirectoryModulesManager.php=01de49a245a08bcf9a770bcee9331136 +/vagrant/core/src/Classes/Cron/Task/EmailSenderTask.php=f0c93e7c807706922cb812723e51bd09 +/vagrant/core/src/Reports/User/Reports/ClientProjectTimeReport.php=f860b3cff536b5074bb7d1e193c1c41d +/vagrant/core/src/Reports/User/Api/ReportsModulesManager.php=1645b61be16b96d0085510f6a2d30b68 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/AbstractInitialize.php=a6e16a53a0178bc30b27dcf3684fbdad +/vagrant/core/src/Salary/Admin/Api/SalaryAdminManager.php=8bedb5d82608974feedd1c094cac64fa +/vagrant/core/src/Employees/Common/Model/EmploymentStatus.php=6e72924fac0cecc49aaf070389f8d73a +/vagrant/core/src/Classes/HistoryManager.php=4741dd856bb81ec2e27bd016afb8e042 +/Users/Thilina/Projects/icehrm-open/core/src/Loans/Common/Model/CompanyLoan.php=cca60a4d5fa1189cdbd35146b010a2c7 +/vagrant/core/src/Travel/Admin/Api/TravelActionManager.php=3a1057fd319a38ff8eecf55b4879d517 +/vagrant/core/src/Projects/Common/Model/Client.php=e4ee80d40f4bbcd94516d767b639f4e4 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/CSVReportBuilder.php=5c5f7175cc2aff776388c3281cea9cf3 +/vagrant/core/src/Reports/Admin/Api/PDFReportBuilderInterface.php=cc049c4c1b86e5a5e4fd99ddf24e563d +/vagrant/core/src/Overtime/User/Api/OvertimeModulesManager.php=b29d52a4e3f021cdd786f41cbf1b9837 +/Users/Thilina/Projects/icehrm-open/core/src/Permissions/Admin/Api/PermissionsAdminManager.php=c66e06b926b4006e8a2d7f2e77e0f1fa +/vagrant/core/src/Attendance/Common/Calculations/CaliforniaOvertimeCalculator.php=a1a5ff46939030747f505710fbd49ffd +/Users/Thilina/Projects/icehrm-open/test/test.config.php=68587cbb63b8a37dc07fdac177eb23a4 +/Users/Thilina/Projects/icehrm-open/core/src/Dashboard/Admin/Api/DashboardActionManager.php=5e8e996f9f4b77f1fbd10e026a5d1351 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/PayslipReport.php=7582da680dd305d073faf95d268083cd +/vagrant/core/src/Salary/Common/Model/EmployeeSalary.php=f7d994ee11b471fff1a6d522d0c62232 +/vagrant/core/src/Classes/BaseService.php=92bd3a9bb4e7eb84e079b0db75d5f752 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeTimesheetReport.php=8661944cf39b10c441841a8af72cb988 +/vagrant/core/src/Settings/Admin/Api/SettingsAdminManager.php=5e5df0056db6f9593128720581feca18 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Common/Model/EmployeeApproval.php=481ddd171d66e644bb442ab02e97b097 +/vagrant/core/src/Permissions/Common/Model/Permission.php=0745dd3786e95cfc5265c32f47f4ee4a +/Users/Thilina/Projects/icehrm-open/core/src/Utils/LogManager.php=144ebae4d0ff60f0fd21e79a45aa6e6a +/Users/Thilina/Projects/icehrm-open/core/src/Dashboard/User/Api/DashboardModulesManager.php=2e8968121b445353ee864c76c44483d3 +/vagrant/core/src/Users/Admin/Api/UsersEmailSender.php=44ef76064fa528f8c88b0cf6b6e9b448 +/Users/Thilina/Projects/icehrm-open/core/src/StaffDirectory/User/Api/StaffDirectoryModulesManager.php=01de49a245a08bcf9a770bcee9331136 +/vagrant/core/src/StaffDirectory/Rest/StaffDirectoryRestEndPoint.php=ba417b136c9c65cd5096c3bde7d141c2 +/vagrant/core/src/Payroll/Common/Model/PayslipTemplate.php=cc9bf7552cfccd84a0b9b1431f224f1f +/vagrant/core/src/Classes/Email/EmailSender.php=7a77f7e9c4622634bddd8ac1ff7b6fa3 +/vagrant/test/test.includes.php=66d627b31f3f6b76f1739a54e7d9fd9f +/vagrant/core/src/Attendance/Common/Model/AttendanceStatus.php=ad80af2d596e584a3ab60a5fce4aac09 +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Admin/Api/QualificationsAdminManager.php=3037d64a2344a497ff0ceea52265d2a6 +/Users/Thilina/Projects/icehrm-open/core/src/EmergencyContacts/User/Api/EmergencyContactModulesManager.php=527888466137dad3da5c6bf5b7bf9b28 +/vagrant/core/src/Classes/MemcacheService.php=e07916b1c628686162c19fa26aad93d5 +/vagrant/core/src/Payroll/Common/Model/PayrollData.php=f1a49da4e6e5a91695dd96c9585e1686 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Migration/MigrationManager.php=b2a6fae32ad9370a4e3375a623330fa7 +/vagrant/core/src/Classes/IceResponse.php=bb74495c33fab87e96f72b610cfd5374 +/vagrant/core/src/Classes/Cron/Task/DocumentExpiryNotificationTask.php=c5f29d1d3ea8b984b442fee8d07d08a1 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Api/DataAdminManager.php=3913dc1f43ae1965956c420d0d9084c8 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Rest/AttendanceRestEndPoint.php=98b5f7f6dc8bfe0fb0eddbc8f894837b +/vagrant/core/src/Utils/Math/EvalMath.php=bdae5673431ca215e080d3b0aa0f74c8 +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Admin/Api/SalaryAdminManager.php=8bedb5d82608974feedd1c094cac64fa +/vagrant/core/src/Classes/IceConstants.php=76b653fed16d089de7da45fe4dfd32a0 +/vagrant/core/src/Overtime/Admin/Api/OvertimeAdminManager.php=701c52c0bca0b0d89c5bb8e7cbafac8e +/vagrant/core/src/Classes/ModuleBuilder/ModuleBuilder.php=29fed2a27587032060efc02c7a30a838 +/vagrant/test/unit/LanguageManagerUnit.php=ebb20febce875350bfddd7f0358e6ad0 +/vagrant/core/src/Metadata/Common/Model/CalculationHook.php=14b41df5f777aa74832b359d43d45140 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/Task/DocumentExpiryNotificationTask.php=c5f29d1d3ea8b984b442fee8d07d08a1 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/CustomFieldManager.php=ed6fd78e1a485b2dc05e4fe683ec4731 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Admin/Api/OvertimeActionManager.php=63ef6d09e21234f0ee963106c417a196 +/vagrant/core/src/Reports/Admin/Api/ReportBuilder.php=9b0e8e996157caebcf17a2a342ba0f6e +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/Common/Model/OvertimeCategory.php=49198d964e954be3d427e3a7a29a6443 +/vagrant/core/src/Classes/Data/Query/FieldMapping.php=59bf4b2160b88d4ceb3729588b341b64 +/vagrant/core/src/Classes/MenuItemTemplate.php=7ad7eb3a874ec729ec1baf0760f0b4ed +/vagrant/core/src/Projects/User/Api/ProjectsModulesManager.php=4fc0463507ca7768a1e493d703ac2581 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/PermissionManager.php=149c16e23f9066538e9c7a0ee3bb397f +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Admin/Api/AttendanceDashboardManager.php=c08fc7c021dd0c0780851c308225291f +/vagrant/core/src/Payroll/Common/Model/Deduction.php=1e49d0fd8d4673e3fd094cfb0e467df4 +/vagrant/core/src/Employees/Common/Model/ArchivedEmployee.php=6056e5073538c0d7a22dea52b6c25374 +/Users/Thilina/Projects/icehrm-open/core/src/Jobs/Common/Model/PayGrade.php=9cc01a86f03deb884884681a73deb27a +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Email/SwiftMailer.php=eca37dc0add437ae1089c695b5074b90 +/vagrant/core/src/Data/Admin/Api/AbstractDataImporter.php=315bf5eec45aa13e174d412014e2237f +/Users/Thilina/Projects/icehrm-open/core/src/Model/BaseModel.php=18a7c31592c280ad3e6d2fdee42e1514 +/vagrant/core/src/Metadata/Common/Model/SupportedLanguage.php=3ec1220796f6e33641998a33f036d709 +/Users/Thilina/Projects/icehrm-open/core/src/Model/Migration.php=3f11c6dfaa18d4a6dcb2caa8d3677121 +/vagrant/core/src/TimeSheets/User/Api/TimeSheetsModulesManager.php=63a8c4364cd579be46b60a2e83f8f87f +/vagrant/core/src/Classes/SubActionManager.php=efcd05491fde9cd1f19c7baf8d09669a +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Admin/Api/AttendanceAdminManager.php=21e4a22a3eb290704181e5a4a7a5df7a +/vagrant/core/src/Employees/Common/Model/Employee.php=1e8f3958597a1d2f138e927115671538 +/vagrant/core/src/Qualifications/Common/Model/EmployeeLanguage.php=66127455502fb29181324c1cc25f93c4 +/Users/Thilina/Projects/icehrm-open/core/src/Projects/Common/Model/Project.php=05b1cd967d67cb977558f2567d7f6cb6 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/RestEndPoint.php=48bd6506bb12af195f32d65c0ae635f2 +/vagrant/core/src/Reports/Admin/Api/ReportBuilderInterface.php=dd7e723c48ec4f97db98ffec0d0f39cb +/vagrant/core/src/Employees/Admin/Api/EmployeesActionManager.php=422c05fab85d0c9f398a8c71fdef6758 +/vagrant/core/src/Classes/NotificationManager.php=e1bf4227b181f06feed9ed678a80ad2a +/vagrant/core/src/Attendance/Rest/AttendanceRestEndPoint.php=98b5f7f6dc8bfe0fb0eddbc8f894837b +/vagrant/core/src/Model/BaseModel.php=18a7c31592c280ad3e6d2fdee42e1514 +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/Language.php=16759d70f3d52e38cbe81abed9b220d8 +/vagrant/core/src/Model/Migration.php=3f11c6dfaa18d4a6dcb2caa8d3677121 +/vagrant/core/src/Employees/Rest/EmployeeRestEndPoint.php=c133d71de94b3c13fac97f9d1061ce06 +/vagrant/core/src/Dependents/User/Api/DependentsModulesManager.php=409b6ea72b6ce0319bb12df6458d2bef +/vagrant/core/src/Salary/Common/Model/PayFrequency.php=fab16310b7db7bb9aace5a6b038c9d2a +/vagrant/core/src/Travel/Admin/Api/TravelAdminManager.php=9b3c6e369e2264d2bc9fca122e8ed90c +/vagrant/core/src/Classes/Cron/CronUtils.php=b55a1fe1c4ed55dc582e208b341f52b4 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/ModuleBuilder/ModuleBuilder.php=29fed2a27587032060efc02c7a30a838 +/Users/Thilina/Projects/icehrm-open/core/src/Company/Admin/Api/CompanyAdminManager.php=484a8b669d5fed117f1f40f289f2c6f4 +/vagrant/core/src/Qualifications/Common/Model/Education.php=327f74726fca1a976e2fc6272ffecdea +/Users/Thilina/Projects/icehrm-open/core/src/Classes/NotificationManager.php=e1bf4227b181f06feed9ed678a80ad2a +/vagrant/core/src/Classes/LanguageManager.php=e019a01be56a46a93177a50340fc3eea +/vagrant/core/src/Classes/Data/Query/Filter.php=3ec1fa1e59c0cbc0955dd3f2f738d1c3 +/vagrant/core/src/Metadata/Common/Model/Country.php=be5371104ea0bbfa7132201d5e31e62f +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/Common/Model/EmployeeTimeEntry.php=f69d37222ff6d528b5dde53fcbb5b3a8 +/Users/Thilina/Projects/icehrm-open/core/src/Overtime/User/Api/OvertimeActionManager.php=5ace85f1fdbd23f5adc8d089f2d6b5fa +/vagrant/core/src/Travel/Common/Model/EmployeeImmigration.php=1dcb690d0045699a1aa65eda033f9adf +/vagrant/test/unit/UserAttendanceActionManagerUnit.php=1d71d366a13f253ef6931aa87202ac42 +/Users/Thilina/Projects/icehrm-open/core/src/Model/StatusChangeLog.php=0745140bddda3f06915dcfcc6ac97ce8 +/vagrant/core/src/Reports/Admin/Reports/AssetUsageReport.php=176cc5363c46aee80f4fc1802b0d29c3 +/Users/Thilina/Projects/icehrm-open/core/src/Users/Common/Model/User.php=ad497e45b540b026aa80fa58f5055cc1 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Api/AbstractDataImporter.php=315bf5eec45aa13e174d412014e2237f +/vagrant/core/src/Metadata/Admin/Api/MetadataAdminManager.php=9f383f9c34ec98a8e2e701825c548a8a +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Admin/Api/TravelActionManager.php=3a1057fd319a38ff8eecf55b4879d517 +/vagrant/core/src/Metadata/Common/Model/Ethnicity.php=5f5935cdeab1b41ac0d2db9f6973f6b0 +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Common/Model/SalaryComponentType.php=d96878a0b1547f44731830526306ab56 +/vagrant/core/src/Metadata/Common/Model/CustomFieldValue.php=a5d9109aa3b465bf98ba0b04ce5d0430 +/vagrant/core/src/Model/Report.php=498c96015d1be2b31d8cd0bcedea7fab +/vagrant/core/src/Classes/SettingsManager.php=ebed24cde74d7fb33cca4ba156389760 +/vagrant/core/src/Payroll/Admin/Api/PayrollAdminManager.php=9bac9a6ed8406c9eb6fe7ef666aee482 +/Users/Thilina/Projects/icehrm-open/core/src/Jobs/Admin/Api/JobsAdminManager.php=12546328edffcc5bda7e84f6a8c56d9e +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Api/ReportsModulesManager.php=1645b61be16b96d0085510f6a2d30b68 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Email/EmailSender.php=7a77f7e9c4622634bddd8ac1ff7b6fa3 +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/User/Api/TimeSheetsActionManager.php=ef271183cf6e71d8db24b8d3369e19b9 +/Users/Thilina/Projects/icehrm-open/core/src/Model/Report.php=498c96015d1be2b31d8cd0bcedea7fab +/vagrant/core/src/Classes/Cron/IceTask.php=cc9b1481e824fd967eb503248eb92e29 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Admin/Api/EmployeesActionManager.php=422c05fab85d0c9f398a8c71fdef6758 +/vagrant/core/src/Model/StatusChangeLog.php=0745140bddda3f06915dcfcc6ac97ce8 +/vagrant/core/src/Attendance/User/Api/AttendanceModulesManager.php=f1b34fae71cc963e197b41ed2ca032ca +/Users/Thilina/Projects/icehrm-open/core/src/Employees/Rest/EmployeeRestEndPoint.php=c133d71de94b3c13fac97f9d1061ce06 +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/User/Api/AttendanceActionManager.php=feaa97dd192e7faec2045aba7dc03125 +/Users/Thilina/Projects/icehrm-open/core/src/Employees/User/Api/EmployeesActionManager.php=e34f4fe38b3e0eb45cb65232fa6ec359 +/vagrant/core/src/Classes/StatusChangeLogManager.php=b091e855d9800eea9d4190e0c75e3e8c +/vagrant/core/src/Reports/Admin/Reports/TravelRequestReport.php=c4bdd4c88f4a7b15c8091a0dcbb5018a +/vagrant/core/src/Permissions/Admin/Api/PermissionsAdminManager.php=c66e06b926b4006e8a2d7f2e77e0f1fa +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Admin/Api/TravelAdminManager.php=9b3c6e369e2264d2bc9fca122e8ed90c +/Users/Thilina/Projects/icehrm-open/core/src/Classes/IceConstants.php=76b653fed16d089de7da45fe4dfd32a0 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Crypt/Aes.php=d0b15a04faf73b0ff35efc308d09b6e7 +/vagrant/core/src/Reports/User/Reports/OvertimeSummaryReport.php=3918d7210957040977b8a43c580abae0 +/Users/Thilina/Projects/icehrm-open/test/unit/LanguageManagerUnit.php=ebb20febce875350bfddd7f0358e6ad0 +/Users/Thilina/Projects/icehrm-open/core/src/Model/Setting.php=f24f377a9590eb8ead2400b186f18a80 +/Users/Thilina/Projects/icehrm-open/core/src/Model/File.php=3bc6c71925ad1e20721ffd63567c7783 +/vagrant/core/src/Reports/Admin/Reports/OvertimeReport.php=f630ae5402ec7957f42b64fa46cd1923 +/vagrant/core/src/Qualifications/Common/Model/EmployeeSkill.php=a02c5ceda0489aba4ed47df010d4892e +/vagrant/core/src/Travel/Common/Model/EmployeeTravelRecordApproval.php=d84b2a1323f3663806cc30545e748cd4 +/vagrant/core/src/Reports/Admin/Reports/EmployeeLeaveEntitlementReport.php=9be41bfeb88fd0171028203f6513c799 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/ExpenseReport.php=7c8d187bc57175a92b8bc0fa33e501f0 +/vagrant/core/src/Data/Common/Model/DataImportFile.php=a0b3f8410e80862ba79aa9d8fed383d7 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayslipTemplate.php=cc9bf7552cfccd84a0b9b1431f224f1f +/vagrant/core/src/Payroll/Common/Model/DeductionGroup.php=c35db5b88aa4b0c7d78b8444688931b5 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/ClassBasedReportBuilder.php=fc77219539745bdb6364fc81bdda2516 +/vagrant/core/src/TimeSheets/Common/Model/EmployeeTimeEntry.php=f69d37222ff6d528b5dde53fcbb5b3a8 +/vagrant/core/src/Classes/ModuleBuilder/ModuleTabGroup.php=d81cfc2b3dcad2f57317b1274c884d95 +/Users/Thilina/Projects/icehrm-open/core/src/Travel/User/Api/TravelModulesManager.php=94c9204a67e99af9133cd2aa371cb6da +/vagrant/core/src/Projects/Common/Model/EmployeeProject.php=b0de956de8ec4c423604195b96f57df9 +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/Common/Model/EmployeeTimeSheet.php=2a4e685315485e4933df5d2ba856d8fb +/Users/Thilina/Projects/icehrm-open/core/src/Users/Admin/Api/UsersEmailSender.php=44ef76064fa528f8c88b0cf6b6e9b448 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/RestApiManager.php=c53180aa40576c5fe8c519b2b0a39e32 +/vagrant/core/src/Travel/Common/Model/EmployeeTravelRecord.php=5366a1927bd94630217ffbc9386ff605 +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Common/Model/EmployeeTravelRecordApproval.php=d84b2a1323f3663806cc30545e748cd4 +/vagrant/core/src/Reports/Admin/Api/ReportsAdminManager.php=be16482fcb8d6714f13618407acf25a5 +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Common/Model/EmployeeTravelRecord.php=5366a1927bd94630217ffbc9386ff605 +/vagrant/core/src/Users/Common/Model/UserRole.php=9f9021a51c94b25e203cc3c0322c80d7 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/Deduction.php=1e49d0fd8d4673e3fd094cfb0e467df4 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Approval/ApproveCommonActionManager.php=c1b7efb8c4f3fe8199c7e0d6fdd1ccce +/vagrant/core/src/Payroll/Common/Model/PayrollColumnTemplate.php=cb69bf4717cfbaf0f395b931296efd9a +/vagrant/core/src/StaffDirectory/Common/Model/StaffDirectory.php=73f3c132e741460f200be3b3100833f6 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayrollCalculations.php=70d1b733b1adbb6c6a2ea0dcec89efca +/vagrant/core/src/Classes/Data/DataReader.php=b788e0ab03f397f845ee49427f9689da +/vagrant/core/src/Data/Admin/Api/DataActionManager.php=82f3ced08b946ca6e10a83c6e07475db +/vagrant/test/helper/EmployeeTestDataHelper.php=65ec2048653c9e4e4359d9b6967a860d +/vagrant/core/src/Payroll/Common/Model/PayrollColumn.php=0f2e8fd9b44c038f163ae646d3c6f4b6 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayrollData.php=f1a49da4e6e5a91695dd96c9585e1686 +/vagrant/core/src/Reports/User/Reports/EmployeeTimesheetReport.php=2ec16a7dccb131862f295ad97db9067b +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/PayrollDataExport.php=83bd6faa73c75667ecf25091c3729abc +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/TravelRequestReport.php=810d405042307fe9c6ca82e082c3673e +/vagrant/core/src/Modules/Admin/Api/ModulesAdminManager.php=e0bc5316cc3c7c6e214761c54e738e9c +/vagrant/core/src/Company/Common/Model/CompanyStructure.php=a1957202858bc093b29e8dfe48955cc6 +/vagrant/core/src/Qualifications/Common/Model/Certification.php=39426e51081f6385feb4803f6a62e937 +/vagrant/core/src/Reports/Admin/Reports/EmployeeLeavesReport.php=bd5efb4666ca4103a2e7e98aa24e1c83 +/vagrant/core/src/FieldNames/Common/Model/CustomField.php=32400d304e8064e69624311c3c80dffb +/vagrant/core/src/EmergencyContacts/User/Api/EmergencyContactModulesManager.php=527888466137dad3da5c6bf5b7bf9b28 +/vagrant/core/src/Data/Admin/Import/AttendanceDataImporter.php=dc4dec4294b9feac08a5f996b85cab85 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Import/AttendanceDataImporter.php=dc4dec4294b9feac08a5f996b85cab85 +/vagrant/core/src/Company/Common/Model/Timezone.php=50aff3bc39221658c35041abdc55ad98 +/Users/Thilina/Projects/icehrm-open/core/src/Model/RestAccessToken.php=77c292675944ff887fc8b4c3f7b6da94 +/Users/Thilina/Projects/icehrm-open/core/src/Model/ReportFile.php=0a766e94902b5473ef1fa24583cf2481 +/vagrant/core/src/Classes/RestApiManager.php=c53180aa40576c5fe8c519b2b0a39e32 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/MemcacheService.php=e07916b1c628686162c19fa26aad93d5 +/Users/Thilina/Projects/icehrm-open/core/src/Projects/Admin/Api/ProjectsAdminManager.php=8f20c5277a8560a69318263166b804e3 +/vagrant/core/src/Model/IceEmail.php=02bd3cd01cb37ab05d763e468cba3835 +/vagrant/core/src/Salary/Common/Model/SalaryComponent.php=31e89f1115de7986cd790c8e113ab6d5 +/vagrant/core/src/Dependents/Common/Model/EmployeeDependent.php=1f4b6cd6dfbc14269b53dbbac3730f9e +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/NewHiresEmployeeReport.php=64eab525953538d481dab6052dd76d81 +/vagrant/core/src/Travel/User/Api/TravelModulesManager.php=94c9204a67e99af9133cd2aa371cb6da +/vagrant/core/src/Reports/Admin/Api/ClassBasedReportBuilder.php=fc77219539745bdb6364fc81bdda2516 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/DeductionGroup.php=c35db5b88aa4b0c7d78b8444688931b5 +/vagrant/core/src/Modules/Common/Model/Module.php=6930680c77dfbcd410e1425c76511c16 +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/ImmigrationStatus.php=f0dc9a94bcc487df21d53387ae8e89ba +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Data/Query/Filter.php=3ec1fa1e59c0cbc0955dd3f2f738d1c3 +/vagrant/core/src/TimeSheets/Common/Model/EmployeeTimeSheet.php=2a4e685315485e4933df5d2ba856d8fb +/vagrant/core/src/Classes/S3FileSystem.php=6308aca72380cef1981625946b59652f +/vagrant/core/src/Salary/User/Api/SalaryModulesManager.php=050d077e79532353a7d12a7221829b7c +/Users/Thilina/Projects/icehrm-open/core/src/Attendance/Common/Calculations/BasicOvertimeCalculator.php=9c96ae3f71796029d3f93e5c63783f53 +/Users/Thilina/Projects/icehrm-open/core/src/Travel/Common/Model/ImmigrationDocument.php=c0636d2ce3e7d89d9e4ebb00c8d1450f +/vagrant/core/src/Attendance/Admin/Api/AttendanceAdminManager.php=21e4a22a3eb290704181e5a4a7a5df7a +/vagrant/core/src/Users/Admin/Api/UsersActionManager.php=52c9dc80e7d81e244b5f0ed9a90693cd +/vagrant/core/src/Model/RestAccessToken.php=77c292675944ff887fc8b4c3f7b6da94 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/MenuItemTemplate.php=7ad7eb3a874ec729ec1baf0760f0b4ed +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/CalculationHook.php=14b41df5f777aa74832b359d43d45140 +/vagrant/core/src/Qualifications/Admin/Api/QualificationsAdminManager.php=3037d64a2344a497ff0ceea52265d2a6 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayrollColumnTemplate.php=cb69bf4717cfbaf0f395b931296efd9a +/Users/Thilina/Projects/icehrm-open/core/src/Classes/SimpleImage.php=fdfb7b2e71e14975ebce16de44ea9dee +/Users/Thilina/Projects/icehrm-open/core/src/Settings/Admin/Api/SettingsInitialize.php=148bc391f5d101121f915a590f991a6b +/vagrant/core/src/Overtime/Admin/Api/OvertimeActionManager.php=63ef6d09e21234f0ee963106c417a196 +/vagrant/core/src/Attendance/Admin/Api/AttendanceActionManager.php=ebf11e8f9395c7ef272b08c8f1fcd22c +/Users/Thilina/Projects/icehrm-open/core/src/Utils/InputCleaner.php=e86fcb9daf1d32a4328edf40a31152f8 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeTimeSheetData.php=9d612ee603fdf4e6b710eec725da2656 +/vagrant/core/src/Data/Admin/Api/DataImporter.php=ad94e2de98e11c1d3f0f0b32c46f358c +/Users/Thilina/Projects/icehrm-open/core/src/Model/Audit.php=6259d9e1d7e7777bb8cde096bdc742aa +/Users/Thilina/Projects/icehrm-open/core/src/Classes/UIManager.php=b43c282c50f732086e6cc07381794cf6 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Email/SMTPEmailSender.php=0df2a519ce3a2d61d486b9527782f72b +/vagrant/core/src/Qualifications/Common/Model/EmployeeEducation.php=8ba4cbc034b5ee23d593cc3352cf46a9 +/vagrant/core/src/Metadata/Common/Model/Province.php=0ff661394cbcfec7f514f2d5eae7ca25 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/SubActionManager.php=efcd05491fde9cd1f19c7baf8d09669a +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Cron/IceTask.php=cc9b1481e824fd967eb503248eb92e29 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/AbstractModuleManager.php=69d73f9f71155445c32222050528b2e0 +/Users/Thilina/Projects/icehrm-open/core/src/Projects/Common/Model/Client.php=e4ee80d40f4bbcd94516d767b639f4e4 +/Users/Thilina/Projects/icehrm-open/core/src/Permissions/Common/Model/Permission.php=0745dd3786e95cfc5265c32f47f4ee4a +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/OvertimeSummaryReport.php=16d9e2f10de82f25d0965e2d327086b9 +/Users/Thilina/Projects/icehrm-open/core/src/Dashboard/User/Api/DashboardActionManager.php=3f797cf4807ad5cd4f881607142df049 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/StatusChangeLogManager.php=b091e855d9800eea9d4190e0c75e3e8c +/vagrant/core/src/Reports/User/Reports/EmployeeAttendanceReport.php=600c1feca3eab6d724ac9661f2f514d5 +/vagrant/core/src/Model/Setting.php=f24f377a9590eb8ead2400b186f18a80 +/vagrant/core/src/Payroll/Admin/Api/PayrollActionManager.php=c95c4e2ae643a16b8e59fa73dc1f0193 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/EmployeeTimeTrackReport.php=ce6f2b098845233342c336f837001554 +/vagrant/core/src/Overtime/Common/Model/EmployeeOvertimeApproval.php=edd2eedebb9f62a44f0e588c615654ce +/Users/Thilina/Projects/icehrm-open/core/src/Reports/User/Reports/EmployeeLeavesReport.php=0bd5801ac4c9803db53198c68904d5f5 +/vagrant/core/src/Reports/Admin/Reports/TerminatedEmployeeReport.php=1b8b58d6e85eb77e45aaf44f426025ea +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Common/Model/SalaryComponent.php=31e89f1115de7986cd790c8e113ab6d5 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/EmployeeAttendanceReport.php=a20c94c986fa57c52daebbcbf4fa1f3f +/vagrant/test/TestTemplate.php=8e6ff185d587f339892a9a720e2bfa5f +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/AssetUsageReport.php=176cc5363c46aee80f4fc1802b0d29c3 +/vagrant/core/src/Attendance/Admin/Api/AttendanceUtil.php=34fe63a4c0f954451afae6c359ea5b38 +/vagrant/core/src/Classes/Approval/ApproveAdminActionManager.php=01eaf59752e8379205bc52f3278f96fc +/Users/Thilina/Projects/icehrm-open/core/src/Metadata/Common/Model/CustomFieldValue.php=a5d9109aa3b465bf98ba0b04ce5d0430 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Admin/Import/PayrollDataImporter.php=7350ec94ef8a70ba6c263e53c70c7073 +/vagrant/core/src/Overtime/Common/Model/EmployeeOvertime.php=4275d184646684892b289524b33cf9d7 +/vagrant/core/src/Classes/Crypt/Aes.php=d0b15a04faf73b0ff35efc308d09b6e7 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/LDAPManager.php=e88dd0634a6ca372564faa5a1d540796 +/vagrant/core/src/Reports/Admin/Reports/OvertimeRequestReport.php=3cd3bc887da768a32bfc61c152489528 +/vagrant/core/src/Reports/Admin/Reports/ActiveEmployeeReport.php=261180dfbe69ab83d9d63646111695ba +/Users/Thilina/Projects/icehrm-open/core/src/Classes/Email/PHPMailer.php=54789d10177cc5075cb4d50838b05821 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/ModuleBuilder/ModuleTab.php=89136363d7520967c2d42e175052f4d5 +/vagrant/core/src/TimeSheets/User/Api/TimeSheetsActionManager.php=ef271183cf6e71d8db24b8d3369e19b9 +/Users/Thilina/Projects/icehrm-open/core/src/TimeSheets/User/Api/TimeSheetsInitialize.php=d47372f12494019c1004a04cbe57013d +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Reports/OvertimeReport.php=f630ae5402ec7957f42b64fa46cd1923 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Common/Model/PayFrequency.php=9207a551d667bab9734aa041e02a1be1 +/vagrant/core/src/Classes/Data/Query/DataQuery.php=eae53f27055f569d43fd2cad06b7beff +/Users/Thilina/Projects/icehrm-open/core/src/Qualifications/Common/Model/EmployeeCertification.php=96045388cba569f4ea9617dc8fbeded6 +/Users/Thilina/Projects/icehrm-open/core/src/Model/DataEntryBackup.php=9ab3a7d48dbdd377a90c505cf692c17e +/vagrant/core/src/Attendance/User/Api/AttendanceActionManager.php=feaa97dd192e7faec2045aba7dc03125 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/ModuleBuilder/ModuleTabGroup.php=d81cfc2b3dcad2f57317b1274c884d95 +/vagrant/core/src/Utils/InputCleaner.php=e86fcb9daf1d32a4328edf40a31152f8 +/vagrant/core/src/Salary/Common/Model/SalaryComponentType.php=d96878a0b1547f44731830526306ab56 +/vagrant/core/src/Payroll/Common/Model/PayFrequency.php=9207a551d667bab9734aa041e02a1be1 +/vagrant/core/src/Overtime/Admin/Api/OvertimePayrollUtils.php=839c6f828000c302512d8d3058286506 +/vagrant/core/src/Attendance/Common/Model/Attendance.php=aa0945e6fc70e6e3418d0e09f7110082 +/Users/Thilina/Projects/icehrm-open/core/src/Classes/ReportHandler.php=80b280cae34fdfbee864b05b07c6789a +/vagrant/core/src/Model/ReportFile.php=0a766e94902b5473ef1fa24583cf2481 +/Users/Thilina/Projects/icehrm-open/core/src/FieldNames/Common/Model/FieldNameMapping.php=e3e81b3a4e0f6c74cd687038632107d8 +/Users/Thilina/Projects/icehrm-open/core/src/Reports/Admin/Api/CSVReportBuilderInterface.php=6ada9a15e850c09162fc75020d6b00e4 +/Users/Thilina/Projects/icehrm-open/core/src/Data/Common/Model/DataImportFile.php=a0b3f8410e80862ba79aa9d8fed383d7 +/vagrant/core/src/Qualifications/User/Api/QualificationsModulesManager.php=e668d64139ecc146af9ebaea2f91e1fe +/vagrant/core/src/Payroll/Common/Model/Payroll.php=8aa76dfc05183abe955552b15e3c4351 +/Users/Thilina/Projects/icehrm-open/core/src/Payroll/Admin/Api/PayrollAdminManager.php=9bac9a6ed8406c9eb6fe7ef666aee482 +/vagrant/core/src/Reports/User/Reports/EmployeeLeavesReport.php=0bd5801ac4c9803db53198c68904d5f5 +/Users/Thilina/Projects/icehrm-open/core/src/Salary/Common/Model/EmployeeSalary.php=f7d994ee11b471fff1a6d522d0c62232 +/vagrant/core/src/Model/Cron.php=9e638c23f7cb93500a1b1f1ef4edf86f +/vagrant/core/src/Model/DataEntryBackup.php=9ab3a7d48dbdd377a90c505cf692c17e diff --git a/core/admin/attendance/index.php b/core/admin/attendance/index.php index ebd47161..d4a38310 100644 --- a/core/admin/attendance/index.php +++ b/core/admin/attendance/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'attendance_monitor'; diff --git a/core/admin/company_structure/index.php b/core/admin/company_structure/index.php index cd468c6a..0d41b4e3 100644 --- a/core/admin/company_structure/index.php +++ b/core/admin/company_structure/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'company_structure'; diff --git a/core/admin/dashboard/index.php b/core/admin/dashboard/index.php index 12fad5b8..dbdbc8f9 100644 --- a/core/admin/dashboard/index.php +++ b/core/admin/dashboard/index.php @@ -1,85 +1,15 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'dashboard'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; - -$invoices = []; -$numOfUnpaidInvoices = 0; -if (class_exists('\\Billing\\Admin\\Api\\BillingActionManager')) { - $billingActionManager = new \Billing\Admin\Api\BillingActionManager(); - - $invoices = $billingActionManager->getInvoices(null)->getData(); - if(!empty($invoices)){ - $invoices = json_decode(json_encode($invoices)); - } - - foreach($invoices as $inv){ - if($inv->status == "Sent"){ - $numOfUnpaidInvoices++; - } - } -} - - ?>
- -
-

You have a pending invoice

-

- You have a pending invoice. Please make you complete the payment so we can provide a better service. -
-
- Make a Payment -

-
- 1){?> -
-

You have pending invoices

-

- You have pending invoice. None of your employees are currently allowed to login. Please make sure you complete payments to all the invoices to restore your service. - Please logout and login after completing the payment to get your service restored. -
-
- Make a Payment -

-
- - - -
-

Your Trial Has Expired

-

- Your Icehrm Trial has expired. Please upgrade subscription to continue. If not upgraded your account will be deleted with in few days. -
-
- Upgrade Subscription -

-
- getModuleManagers(); diff --git a/core/admin/fieldnames/index.php b/core/admin/fieldnames/index.php index 92ae663d..8cf6ce94 100644 --- a/core/admin/fieldnames/index.php +++ b/core/admin/fieldnames/index.php @@ -5,7 +5,7 @@ This file is part of Ice Framework. ------------------------------------------------------------------ Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'fieldnames'; diff --git a/core/admin/jobs/index.php b/core/admin/jobs/index.php index 87ea3c94..db3dff50 100644 --- a/core/admin/jobs/index.php +++ b/core/admin/jobs/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'jobs'; define('MODULE_PATH',dirname(__FILE__)); diff --git a/core/admin/loans/index.php b/core/admin/loans/index.php index dc659f39..644cf7b8 100644 --- a/core/admin/loans/index.php +++ b/core/admin/loans/index.php @@ -1,24 +1,7 @@ -. - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'CompanyLoans'; @@ -26,27 +9,27 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
- + - +
- +
- +
@@ -61,4 +44,4 @@ modJsList['tabEmployeeCompanyLoan'] = new EmployeeCompanyLoanAdapter('EmployeeCo var modJs = modJsList['tabCompanyLoan']; - + diff --git a/core/admin/metadata/index.php b/core/admin/metadata/index.php index 245d92c1..76b92573 100644 --- a/core/admin/metadata/index.php +++ b/core/admin/metadata/index.php @@ -18,7 +18,7 @@ along with Ice Framework. If not, see . ------------------------------------------------------------------ Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'metadata'; diff --git a/core/admin/modules/index.php b/core/admin/modules/index.php index 92480d0c..a5f0556d 100644 --- a/core/admin/modules/index.php +++ b/core/admin/modules/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'Modules'; diff --git a/core/admin/overtime/index.php b/core/admin/overtime/index.php index 74580c3a..49709ba3 100644 --- a/core/admin/overtime/index.php +++ b/core/admin/overtime/index.php @@ -1,27 +1,10 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ -$moduleName = 'travel'; +$moduleName = 'overtime'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; diff --git a/core/admin/permissions/index.php b/core/admin/permissions/index.php index ba53430a..ea159193 100644 --- a/core/admin/permissions/index.php +++ b/core/admin/permissions/index.php @@ -1,24 +1,7 @@ -. - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'Permissions'; @@ -26,18 +9,18 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
- + - +
- +
@@ -51,4 +34,4 @@ modJsList['tabPermission'].setShowAddNew(false); var modJs = modJsList['tabPermission']; - + diff --git a/core/admin/projects/index.php b/core/admin/projects/index.php index 304b9333..e333c3a1 100644 --- a/core/admin/projects/index.php +++ b/core/admin/projects/index.php @@ -1,24 +1,7 @@ -. - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'projects'; @@ -26,36 +9,36 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
- + - +
- +
- +
- +
@@ -110,4 +93,4 @@ modJsList['tabEmployeeProject'].setShowEdit(false); var modJs = modJsList['tabClient']; - + diff --git a/core/admin/qualifications/index.php b/core/admin/qualifications/index.php index 1e425ded..935b05db 100644 --- a/core/admin/qualifications/index.php +++ b/core/admin/qualifications/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'company_structure'; @@ -26,37 +9,37 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
- + - +
- +
- +
- +
@@ -124,4 +107,4 @@ modJsList['tabLanguage'].setShowEdit(false); var modJs = modJsList['tabSkill']; - + diff --git a/core/admin/settings/index.php b/core/admin/settings/index.php index ce16c9ea..1bcefb35 100644 --- a/core/admin/settings/index.php +++ b/core/admin/settings/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'settings'; diff --git a/core/admin/travel/index.php b/core/admin/travel/index.php index 0ce5216b..5a85b880 100644 --- a/core/admin/travel/index.php +++ b/core/admin/travel/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'travel'; diff --git a/core/admin/users/emailTemplates/welcomeUser.html b/core/admin/users/emailTemplates/welcomeUser.html index d67217b9..d5646a13 100644 --- a/core/admin/users/emailTemplates/welcomeUser.html +++ b/core/admin/users/emailTemplates/welcomeUser.html @@ -4,14 +4,23 @@ Your account in IceHrm has been created on #_url_#< Please find your account information below:

Username: #_username_#
Email: #_email_# (You can use, username or email to login)
-Password: #_password_# (Strongly advised to change this password once logged in)
+Temporary Password: #_password_# (Strongly advised to change this password once logged in)

-To get started, follow this link: #_url_#

+Login to IceHrm here: (#_url_#)
+ + + + +
+ +
THIS IS AN AUTOMATED EMAIL - REPLIES WILL BE SENT TO #_adminEmail_#
-
\ No newline at end of file +
diff --git a/core/admin/users/index.php b/core/admin/users/index.php index 4ffc2b40..e6d910df 100644 --- a/core/admin/users/index.php +++ b/core/admin/users/index.php @@ -1,24 +1,7 @@ -. - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'users'; @@ -31,14 +14,14 @@ $csrf = \Classes\BaseService::getInstance()->generateCsrf('User');
  • - +
    - +
    @@ -63,4 +46,4 @@ modJsList['tabUserRole'] = new UserRoleAdapter('UserRole'); var modJs = modJsList['tabUser']; - + diff --git a/core/config.base.php b/core/config.base.php index 41fc89bc..4c051372 100644 --- a/core/config.base.php +++ b/core/config.base.php @@ -13,10 +13,10 @@ if(!defined('HOME_LINK_OTHERS')){ } //Version -define('VERSION', '24.0.0.OS'); -define('CACHE_VALUE', '24.0.0.OS'); -define('VERSION_NUMBER', '2400'); -define('VERSION_DATE', '26/06/2018'); +define('VERSION', '26.1.0.OS'); +define('CACHE_VALUE', '26.1.0.OS'); +define('VERSION_NUMBER', '2610'); +define('VERSION_DATE', '31/01/2019'); if(!defined('CONTACT_EMAIL')){define('CONTACT_EMAIL','icehrm@gamonoid.com');} if(!defined('KEY_PREFIX')){define('KEY_PREFIX','IceHrm');} diff --git a/core/crons/cron.php b/core/crons/cron.php index 269115ed..27f3ea51 100644 --- a/core/crons/cron.php +++ b/core/crons/cron.php @@ -10,7 +10,6 @@ if(!$crons){ \Utils\LogManager::getInstance()->info(CLIENT_NAME." cron count :".count($crons)); foreach($crons as $cron){ - $count++; $iceCron = new \Classes\Cron\IceCron($cron); \Utils\LogManager::getInstance()->info(CLIENT_NAME." check cron :".$cron->name); if($iceCron->isRunNow()){ diff --git a/core/data/payroll/Ghana-Payroll.txt b/core/data/payroll/Ghana-Payroll.txt new file mode 100644 index 00000000..c1861e30 --- /dev/null +++ b/core/data/payroll/Ghana-Payroll.txt @@ -0,0 +1,312 @@ +{ + "name": "Ghana Payroll Calculation", + "description": "", + "deductions": [ + { + "id": "101", + "name": "Housing Allowance (10%)", + "componentType": "[]", + "component": "[\"1\"]", + "payrollColumn": null, + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":0,\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"X*0.1\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "102", + "name": "Overtime Allowance (10%)", + "componentType": "[]", + "component": "[\"1\"]", + "payrollColumn": null, + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":0,\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"X*0.1\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "103", + "name": "SSNIT", + "componentType": "[]", + "component": "[\"1\"]", + "payrollColumn": null, + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":0,\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"X*0.055\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "104", + "name": "Tax - Ghana", + "componentType": "[]", + "component": "[]", + "payrollColumn": null, + "rangeAmounts": "" + }, + { + "id": "106", + "name": "Next 108 GHC", + "componentType": "[]", + "component": "[]", + "payrollColumn": "112", + "rangeAmounts": "[{\"lowerCondition\":\"gte\",\"lowerLimit\":\"216\",\"upperCondition\":\"lt\",\"upperLimit\":\"324\",\"amount\":\"X*0.05\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gte\",\"lowerLimit\":\"324\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"5.4\",\"id\":\"rangeAmounts_2\"}]" + }, + { + "id": "107", + "name": "Next 151 GHC", + "componentType": "[]", + "component": "[]", + "payrollColumn": "112", + "rangeAmounts": "[{\"lowerCondition\":\"gte\",\"lowerLimit\":\"324\",\"upperCondition\":\"lt\",\"upperLimit\":\"475\",\"amount\":\"(X-324) * 0.1\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gte\",\"lowerLimit\":\"259\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"15.10\",\"id\":\"rangeAmounts_2\"}]" + }, + { + "id": "108", + "name": "Next 2765 GHC", + "componentType": "[]", + "component": "[]", + "payrollColumn": "112", + "rangeAmounts": "[{\"lowerCondition\":\"gte\",\"lowerLimit\":\"475\",\"upperCondition\":\"lt\",\"upperLimit\":\"3240\",\"amount\":\"(X - 475) * 0.175\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gte\",\"lowerLimit\":\"3240\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"483.88\",\"id\":\"rangeAmounts_2\"}]" + }, + { + "id": "111", + "name": "Remaining after 3240 GHC", + "componentType": "[]", + "component": "[]", + "payrollColumn": "112", + "rangeAmounts": "[{\"lowerCondition\":\"gte\",\"lowerLimit\":\"3240\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"(X-3240)*0.25\",\"id\":\"rangeAmounts_1\"}]" + } + ], + "columns": [ + { + "id": "105", + "name": "GH - Salary (Basic)", + "calculation_hook": null, + "salary_components": "[\"1\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "1", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "106", + "name": "GH - Housing Allowance", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"101\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "2", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "107", + "name": "GH - Overtime Allowance", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"102\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "3", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "108", + "name": "GH - Total", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"106\",\"107\",\"105\"]", + "sub_columns": "[]", + "colorder": "4", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "109", + "name": "GH - SSNIT", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"103\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "5", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "112", + "name": "GH - Taxable Income", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"106\",\"105\"]", + "sub_columns": "[\"109\"]", + "colorder": "7", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "113", + "name": "GH - Next 108 GHC", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"106\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "9", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "114", + "name": "GH - Next 151 GHC", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"107\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "10", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "115", + "name": "GH - Next 2765 GHC", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"108\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "11", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "120", + "name": "GH - Remaining after 3240 GHC", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"111\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "12", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "121", + "name": "GH - Overtime Allow. Tax", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "13", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "[{\"name\":\"O\",\"column\":\"107\",\"id\":\"calculation_columns_1\"}]", + "calculation_function": "O*0.05" + }, + { + "id": "122", + "name": "GH - Total (PAYE Tax)", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"113\",\"114\",\"115\",\"121\",\"120\"]", + "sub_columns": "[]", + "colorder": "14", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "123", + "name": "GH - Deductions - Sub Total", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"109\",\"122\"]", + "sub_columns": "[]", + "colorder": "15", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "125", + "name": "GH - Final Total", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"108\"]", + "sub_columns": "[\"123\"]", + "colorder": "16", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + } + ], + "salaryComponents": [ + { + "id": "1", + "name": "Basic Salary", + "componentType": "1", + "details": null + } + ], + "salaryComponentTypes": [ + { + "id": "1", + "code": "B001", + "name": "Basic" + } + ], + "samplePayroll": { + "name": "Germany Payroll Calculation", + "pay_period": "4", + "columns": "[\"126\",\"127\",\"131\",\"129\",\"128\",\"133\",\"130\",\"132\"]", + "date_start": "2017-08-01", + "date_end": "2017-08-31", + "status": "Draft" + }, + "payslipTemplate": { + "name": "Sample Payslip Template", + "data": "[{\"type\":\"Company Logo\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_1\"},{\"type\":\"Company Name\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_2\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_5\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"126\",\"label\":\"Basic Salary\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_3\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"127\",\"label\":\"Car Allowance\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_4\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"130\",\"label\":\"Payment for Hours Worked\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_6\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_7\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"131\",\"label\":\"Gross Pay\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_8\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"132\",\"label\":\"Tax 19%\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_9\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_10\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"133\",\"label\":\"Net Pay\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_11\"}]", + "status": null, + "created": "2017-09-08 21:12:40", + "updated": "2017-09-08 21:12:40" + } +} \ No newline at end of file diff --git a/core/data/payroll/Sample-Country-Payroll.txt b/core/data/payroll/Sample-Country-Payroll.txt new file mode 100644 index 00000000..c2f23526 --- /dev/null +++ b/core/data/payroll/Sample-Country-Payroll.txt @@ -0,0 +1,188 @@ +{ + "name": "Sample Country Payroll", + "description": "", + "deductions": [ + { + "id": "112", + "name": "DE - Tax", + "componentType": "[]", + "component": "[]", + "payrollColumn": "131", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":0,\"upperCondition\":\"No Upper Limit\",\"upperLimit\":0,\"amount\":\"X * 0.19\",\"id\":\"rangeAmounts_1\"}]" + } + ], + "columns": [ + { + "id": "126", + "name": "DE - Basic Salary", + "calculation_hook": null, + "salary_components": "[\"1\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "1", + "editable": "Yes", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "127", + "name": "DE - Car Allowance", + "calculation_hook": null, + "salary_components": "[\"3\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "2", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "128", + "name": "DE - Hours Worked per Month", + "calculation_hook": "AttendanceUtil_getTimeWorkedHours", + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "3", + "editable": "No", + "enabled": "Yes", + "default_value": "0", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "129", + "name": "DE - Hourly Pay", + "calculation_hook": null, + "salary_components": "[\"5\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "4", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "130", + "name": "DE - Payment for Hours Worked", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "5", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "[{\"name\":\"X\",\"column\":\"128\",\"id\":\"calculation_columns_1\"},{\"name\":\"Y\",\"column\":\"129\",\"id\":\"calculation_columns_2\"}]", + "calculation_function": "X * Y" + }, + { + "id": "131", + "name": "DE - Gross Salary", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"126\",\"127\",\"130\"]", + "sub_columns": "[]", + "colorder": "6", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "132", + "name": "DE - Tax", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"112\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "7", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "133", + "name": "DE - Net Salary", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"131\"]", + "sub_columns": "[\"132\"]", + "colorder": "8", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + } + ], + "salaryComponents": [ + { + "id": "1", + "name": "Basic Salary", + "componentType": "1", + "details": null + }, + { + "id": "3", + "name": "Car Allowance", + "componentType": "2", + "details": null + }, + { + "id": "5", + "name": "Regular Hourly Pay", + "componentType": "3", + "details": null + } + ], + "salaryComponentTypes": [ + { + "id": "1", + "code": "B001", + "name": "Basic" + }, + { + "id": "2", + "code": "B002", + "name": "Allowance" + }, + { + "id": "3", + "code": "B003", + "name": "Hourly" + } + ], + "samplePayroll": { + "name": "Sample Country Payroll", + "pay_period": "4", + "columns": "[\"126\",\"127\",\"131\",\"129\",\"128\",\"133\",\"130\",\"132\"]", + "date_start": "2017-08-01", + "date_end": "2017-08-31", + "status": "Draft" + }, + "payslipTemplate": { + "name": "Sample Payslip Template", + "data": "[{\"type\":\"Company Logo\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_1\"},{\"type\":\"Company Name\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_2\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_5\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"126\",\"label\":\"Basic Salary\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_3\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"127\",\"label\":\"Car Allowance\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_4\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"130\",\"label\":\"Payment for Hours Worked\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_6\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_7\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"131\",\"label\":\"Gross Pay\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_8\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"132\",\"label\":\"Tax 19%\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_9\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_10\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"133\",\"label\":\"Net Pay\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_11\"}]", + "status": null, + "created": "2017-09-08 21:12:40", + "updated": "2017-09-08 21:12:40" + } +} \ No newline at end of file diff --git a/core/data/payroll/SriLanka-Payroll.txt b/core/data/payroll/SriLanka-Payroll.txt new file mode 100644 index 00000000..5d5c39fc --- /dev/null +++ b/core/data/payroll/SriLanka-Payroll.txt @@ -0,0 +1,264 @@ +{ + "name": "Sri Lanka Payroll Calculation", + "description": "", + "deductions": [ + { + "id": "1", + "name": "EPF Employee Contribution", + "componentType": "[]", + "component": "[]", + "payrollColumn": "7", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.08\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "2", + "name": "EPF Employer Contribution", + "componentType": "[]", + "component": "[]", + "payrollColumn": "7", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.12\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "3", + "name": "ETF Employer Contribution", + "componentType": "[]", + "component": "[]", + "payrollColumn": "7", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.03\",\"id\":\"rangeAmounts_1\"}]" + }, + { + "id": "4", + "name": "PAYE Tax", + "componentType": "[]", + "component": "[]", + "payrollColumn": "12", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"62500\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"62500\",\"upperCondition\":\"lte\",\"upperLimit\":\"104167\",\"amount\":\"X*0.04 - 2500\",\"id\":\"rangeAmounts_2\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"104167\",\"upperCondition\":\"lte\",\"upperLimit\":\"145833\",\"amount\":\"X*0.08 - 6667\",\"id\":\"rangeAmounts_3\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"145833\",\"upperCondition\":\"lte\",\"upperLimit\":\"187500\",\"amount\":\"X*0.12-12500\",\"id\":\"rangeAmounts_4\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"187500\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.16 - 20000\",\"id\":\"rangeAmounts_5\"}]" + }, + { + "id": "5", + "name": "Stamp Duty", + "componentType": "[]", + "component": "[]", + "payrollColumn": "12", + "rangeAmounts": "[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"25000\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"25000\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"25\",\"id\":\"rangeAmounts_2\"}]" + } + ], + "columns": [ + { + "id": "5", + "name": "LK - Basic Salary", + "calculation_hook": null, + "salary_components": "[\"1\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "5", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "6", + "name": "LK - Fixed Allowance", + "calculation_hook": null, + "salary_components": "[\"2\"]", + "deductions": "[]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "6", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "7", + "name": "LK - Gross Pay", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"5\",\"6\"]", + "sub_columns": "[]", + "colorder": "7", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "8", + "name": "LK - EPF Employee Contribution", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"1\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "8", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "9", + "name": "LK - EPF Employer Contribution", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"2\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "9", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "10", + "name": "LK - ETF Employer Contribution", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"3\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "10", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "11", + "name": "LK - Total EPF 20%", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"8\",\"9\"]", + "sub_columns": "[]", + "colorder": "11", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "12", + "name": "LK - Total for PAYE", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"7\"]", + "sub_columns": "[]", + "colorder": "12", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "13", + "name": "LK - PAYE Tax", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"4\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "13", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "14", + "name": "LK - Stamp Duty", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[\"5\"]", + "add_columns": "[]", + "sub_columns": "[]", + "colorder": "14", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "15", + "name": "LK - Total Deductions", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"8\",\"13\",\"14\"]", + "sub_columns": "[]", + "colorder": "15", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + }, + { + "id": "16", + "name": "LK - Salary to Bank", + "calculation_hook": null, + "salary_components": "[]", + "deductions": "[]", + "add_columns": "[\"7\"]", + "sub_columns": "[\"15\"]", + "colorder": "16", + "editable": "No", + "enabled": "Yes", + "default_value": "0.00", + "calculation_columns": "", + "calculation_function": "" + } + ], + "salaryComponents": [ + { + "id": "1", + "name": "Basic Salary", + "componentType": "1", + "details": null + }, + { + "id": "2", + "name": "Fixed Allowance", + "componentType": "1", + "details": null + } + ], + "salaryComponentTypes": [ + { + "id": "1", + "code": "B001", + "name": "Basic" + } + ], + "samplePayroll": { + "name": "Sri Lanka Payroll Sample", + "pay_period": "4", + "columns": "[\"5\",\"8\",\"9\",\"10\",\"6\",\"7\",\"13\",\"16\",\"14\",\"15\",\"11\",\"12\"]", + "date_start": "2016-03-01", + "date_end": "2016-03-31", + "status": "Draft" + }, + "payslipTemplate": { + "name": "Sri Lanka - Default Payslip", + "data": "[{\"type\":\"Company Logo\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"fontSize\":\"Normal\",\"fontStyle\":\"Normal\",\"fontColor\":\"#000000\",\"status\":\"Show\",\"id\":\"data_1\"},{\"type\":\"Company Name\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"fontSize\":\"Normal\",\"fontStyle\":\"Normal\",\"fontColor\":\"\",\"status\":\"Show\",\"id\":\"data_2\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"fontSize\":\"Normal\",\"fontStyle\":\"Normal\",\"fontColor\":\"\",\"status\":\"Show\",\"id\":\"data_8\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"5\",\"label\":\"Basic Salary\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_3\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"6\",\"label\":\"Fixed Allowance\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_4\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"7\",\"label\":\"Gross Pay\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_11\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"fontSize\":\"Normal\",\"fontStyle\":\"Normal\",\"fontColor\":\"\",\"status\":\"Show\",\"id\":\"data_9\"},{\"type\":\"Text\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"Deductions\",\"status\":\"Show\",\"id\":\"data_13\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"8\",\"label\":\"EPF Employee Contribution\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_6\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"13\",\"label\":\"PAYE Tax\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_14\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"14\",\"label\":\"Stamp Duty\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_15\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"15\",\"label\":\"Total Deductions\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_16\"},{\"type\":\"Separators\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_17\"},{\"type\":\"Text\",\"payrollColumn\":\"NULL\",\"label\":\"\",\"text\":\"Employer Contributions\",\"status\":\"Show\",\"id\":\"data_18\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"9\",\"label\":\"EPF Employer Contribution\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_19\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"7\",\"label\":\"ETF Employer Contribution\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_20\"},{\"type\":\"Separators\",\"payrollColumn\":\"7\",\"label\":\"\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_21\"},{\"type\":\"Text\",\"payrollColumn\":\"7\",\"label\":\"\",\"text\":\"Totals\",\"status\":\"Show\",\"id\":\"data_22\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"11\",\"label\":\"Total EPF 20%\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_23\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"12\",\"label\":\"Total for PAYE\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_24\"},{\"type\":\"Payroll Column\",\"payrollColumn\":\"16\",\"label\":\"Net Salary\",\"text\":\"\",\"status\":\"Show\",\"id\":\"data_25\"}]", + "status": null, + "created": "2016-06-29 22:07:12", + "updated": "2016-06-29 22:07:12" + } +} \ No newline at end of file diff --git a/core/entry_footer.php b/core/entry_footer.php index 4f9421e0..ed1301d6 100644 --- a/core/entry_footer.php +++ b/core/entry_footer.php @@ -30,9 +30,7 @@ modJsList[prop].setNoJSONRequests(''); } } - var timeUtils = new TimeUtils(); - timeUtils.setServerGMToffset(''); - + var clientUrl = ''; diff --git a/core/entry_header.php b/core/entry_header.php index abdbd633..2e1a849f 100644 --- a/core/entry_header.php +++ b/core/entry_header.php @@ -7,11 +7,25 @@ if(!file_exists($logoFileName)){ ?> - - <?=$meta->title?> - - - + + getGAKey())) { ?> + + + + + + + + + + <?=$companyName?> + + + @@ -20,76 +34,20 @@ if(!file_exists($logoFileName)){ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + diff --git a/core/footer.php b/core/footer.php index 724811d9..11d2f096 100644 --- a/core/footer.php +++ b/core/footer.php @@ -42,13 +42,8 @@ //Other static js objects - - var timeUtils = new TimeUtils(); - timeUtils.setServerGMToffset(''); - - var notificationManager = new NotificationManager(); - notificationManager.setBaseUrl('service.php'); - notificationManager.setTimeUtils(timeUtils); + var timeUtils = setupTimeUtils(''); + var notificationManager = setupNotifications('service.php'); . ------------------------------------------------------------------ Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ if (!defined('MODULE_NAME')) { define('MODULE_NAME', $moduleName); @@ -94,14 +94,18 @@ $chatUserProfile = \Classes\UIManager::getInstance()->getCurrentProfile(); ?> - - - - + getGAKey())) { ?> + + + + + + + <?=$companyName?> @@ -110,84 +114,20 @@ $chatUserProfile = \Classes\UIManager::getInstance()->getCurrentProfile(); - - - - + + + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -214,6 +154,9 @@ $chatUserProfile = \Classes\UIManager::getInstance()->getCurrentProfile();
    +getCurrentLanguageCode() === 'ar') {?> + +
    db->_connectionID === $db->_connectionID && $db->database == $d->db->database) { + if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database) { $obj = $d; break; } } } - + if ($index == false) $index = sizeof($_ADODB_ACTIVE_DBS); - + if(!isset($obj)) { $obj = new ADODB_Active_DB(); $obj->db = $db; - $obj->tables = array(); + $obj->tables = array(); } - + $_ADODB_ACTIVE_DBS[$index] = $obj; - + return $index; } @@ -82,8 +82,8 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false) class ADODB_Active_Record { static $_changeNames = true; // dynamically pluralize table names static $_quoteNames = false; - - static $_foreignSuffix = '_id'; // + + static $_foreignSuffix = '_id'; // var $_dbat; // associative index pointing to ADODB_Active_DB eg. $ADODB_Active_DBS[_dbat] var $_table; // tablename, if set in class definition then use it as table name var $_tableat; // associative index pointing to ADODB_Active_Table, eg $ADODB_Active_DBS[_dbat]->tables[$this->_tableat] @@ -103,7 +103,7 @@ class ADODB_Active_Record { } // should be static - static function SetDatabaseAdapter(&$db, $index=false) + static function SetDatabaseAdapter(&$db, $index=false) { //error_log("Coming into ".self::_pluralize(get_called_class())."'s SetDatabaseAdapter where ".get_class()); if(!$index || !isset($index)) { @@ -111,19 +111,19 @@ class ADODB_Active_Record { } return ADODB_SetDatabaseAdapter($db, $index); } - - + + public function __set($name, $value) { $name = str_replace(' ', '_', $name); $this->$name = $value; } - + // php5 constructor function __construct($table = false, $pkeyarr=false, $db=false) { global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS; - + if ($db == false && is_object($pkeyarr)) { $db = $pkeyarr; $pkeyarr = false; @@ -143,9 +143,9 @@ class ADODB_Active_Record { if(isset($_ADODB_ACTIVE_DBS[self::_pluralize(get_called_class())])) { $this->_dbat = self::_pluralize(get_called_class()); } else { - $this->_dbat = key($_ADODB_ACTIVE_DBS); + $this->_dbat = key($_ADODB_ACTIVE_DBS); } - + } $this->_table = $table; @@ -153,13 +153,13 @@ class ADODB_Active_Record { $this->UpdateActiveTable($pkeyarr); } - + function __wakeup() { $class = get_class($this); new $class; } - + static function _pluralize($table) { if (!ADODB_Active_Record::$_changeNames) return $table; @@ -170,26 +170,26 @@ class ADODB_Active_Record { $lastc2 = substr($ut,$len-2); switch ($lastc) { case 'S': - return $table.'es'; + return $table.'es'; case 'Y': return substr($table,0,$len-1).'ies'; - case 'X': + case 'X': return $table.'es'; - case 'H': + case 'H': if ($lastc2 == 'CH' || $lastc2 == 'SH') return $table.'es'; default: return $table.'s'; } } - + // CFR Lamest singular inflector ever - @todo Make it real! // Note: There is an assumption here...and it is that the argument's length >= 4 function _singularize($tables) { - + if (!ADODB_Active_Record::$_changeNames) return $table; - + $ut = strtoupper($tables); $len = strlen($tables); if($ut[$len-1] != 'S') @@ -221,14 +221,14 @@ class ADODB_Active_Record { $table->_hasMany[$foreignRef] = $ar; # $this->$foreignRef = $this->_hasMany[$foreignRef]; // WATCHME Removed assignment by ref. to please __get() } - + // use when you don't want ADOdb to auto-pluralize tablename static function TableHasMany($table, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record') { $ar = new ADODB_Active_Record($table); $ar->hasMany($foreignRef, $foreignKey, $foreignClass); } - + // use when you don't want ADOdb to auto-pluralize tablename static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record') { @@ -236,8 +236,8 @@ class ADODB_Active_Record { $ar = new ADODB_Active_Record($table,$tablePKey); $ar->hasMany($foreignRef, $foreignKey, $foreignClass); } - - + + // use when you want ADOdb to auto-pluralize tablename for you. Note that the class must already be defined. // e.g. class Person will generate relationship for table Persons static function ClassHasMany($parentclass, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record') @@ -245,7 +245,7 @@ class ADODB_Active_Record { $ar = new $parentclass(); $ar->hasMany($foreignRef, $foreignKey, $foreignClass); } - + function belongsTo($foreignRef,$foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record') { @@ -256,24 +256,24 @@ class ADODB_Active_Record { $ar->parentKey = $parentKey; $ar->UpdateActiveTable(); $ar->foreignKey = ($foreignKey) ? $foreignKey : $foreignRef.ADODB_Active_Record::$_foreignSuffix; - + $table =& $this->TableInfo(); $table->_belongsTo[$foreignRef] = $ar; # $this->$foreignRef = $this->_belongsTo[$foreignRef]; } - + static function ClassBelongsTo($class, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record') { $ar = new $class(); $ar->belongsTo($foreignRef, $foreignKey, $parentKey, $parentClass); } - + static function TableBelongsTo($table, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record') { $ar = new ADOdb_Active_Record($table); $ar->belongsTo($foreignRef, $foreignKey, $parentKey, $parentClass); } - + static function TableKeyBelongsTo($table, $tablePKey, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record') { if (!is_array($tablePKey)) $tablePKey = array($tablePKey); @@ -284,8 +284,8 @@ class ADODB_Active_Record { /** * __get Access properties - used for lazy loading - * - * @param mixed $name + * + * @param mixed $name * @access protected * @return mixed */ @@ -293,9 +293,9 @@ class ADODB_Active_Record { { return $this->LoadRelations($name, '', -1, -1); } - + /** - * @param string $name + * @param string $name * @param string $whereOrderBy : eg. ' AND field1 = value ORDER BY field2' * @param offset * @param limit @@ -307,12 +307,12 @@ class ADODB_Active_Record { $table = $this->TableInfo(); if ($limit >= 0) $extras['limit'] = $limit; if ($offset >= 0) $extras['offset'] = $offset; - - if (strlen($whereOrderBy)) + + if (strlen($whereOrderBy)) if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy)) if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i',$whereOrderBy)) $whereOrderBy = 'AND '.$whereOrderBy; - + if(!empty($table->_belongsTo[$name])) { $obj = $table->_belongsTo[$name]; @@ -323,7 +323,7 @@ class ADODB_Active_Record { { if ($obj->parentKey) $key = $obj->parentKey; else $key = reset($table->keys); - + $arrayOfOne = $obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras); if ($arrayOfOne) { $this->$name = $arrayOfOne[0]; @@ -332,7 +332,7 @@ class ADODB_Active_Record { } } if(!empty($table->_hasMany[$name])) - { + { $obj = $table->_hasMany[$name]; $key = reset($table->keys); $id = @$this->$key; @@ -345,11 +345,11 @@ class ADODB_Active_Record { $this->$name = $objs; return $objs; } - + return array(); } ////////////////////////////////// - + // update metadata function UpdateActiveTable($pkeys=false,$forceUpdate=false) { @@ -365,7 +365,7 @@ class ADODB_Active_Record { $acttab = $tables[$tableat]; foreach($acttab->flds as $name => $fld) { - if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) + if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) $this->$name = $fld->default_value; else $this->$name = null; @@ -379,19 +379,19 @@ class ADODB_Active_Record { @flock($fp, LOCK_SH); $acttab = unserialize(fread($fp,100000)); fclose($fp); - if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { + if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { // abs(rand()) randomizes deletion, reducing contention to delete/refresh file // ideally, you should cache at least 32 secs - + foreach($acttab->flds as $name => $fld) { - if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) + if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) $this->$name = $fld->default_value; else $this->$name = null; } - + $activedb->tables[$table] = $acttab; - + //if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname"); return; } else if ($db->debug) { @@ -400,18 +400,18 @@ class ADODB_Active_Record { } $activetab = new ADODB_Active_Table(); $activetab->name = $table; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false); - + $cols = $db->MetaColumns($table); - + if (isset($savem)) $db->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + if (!$cols) { - $this->Error("Invalid table name: $table",'UpdateActiveTable'); + $this->Error("Invalid table name: $table",'UpdateActiveTable'); return false; } $fld = reset($cols); @@ -421,14 +421,14 @@ class ADODB_Active_Record { foreach($cols as $name => $fld) { if (!empty($fld->primary_key)) $pkeys[] = $name; } - } else + } else $pkeys = $this->GetPrimaryKeys($db, $table); } if (empty($pkeys)) { $this->Error("No primary key found for table $table",'UpdateActiveTable'); return false; } - + $attr = array(); $keys = array(); $ADODB_ASSOC_CASE = 2; @@ -446,18 +446,18 @@ class ADODB_Active_Record { $keys[strtolower($name)] = strtolower($name); } break; - - case 1: + + case 1: foreach($cols as $name => $fldobj) { $name = strtoupper($name); - + if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) $this->$name = $fldobj->default_value; else $this->$name = null; $attr[$name] = $fldobj; } - + foreach($pkeys as $k => $name) { $keys[strtoupper($name)] = strtoupper($name); } @@ -465,7 +465,7 @@ class ADODB_Active_Record { default: foreach($cols as $name => $fldobj) { $name = ($fldobj->name); - + if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) $this->$name = $fldobj->default_value; else @@ -477,7 +477,7 @@ class ADODB_Active_Record { } break; } - + $activetab->keys = $keys; $activetab->flds = $attr; @@ -489,58 +489,58 @@ class ADODB_Active_Record { } if (isset($activedb->tables[$table])) { $oldtab = $activedb->tables[$table]; - + if ($oldtab) $activetab->_belongsTo = $oldtab->_belongsTo; if ($oldtab) $activetab->_hasMany = $oldtab->_hasMany; } $activedb->tables[$table] = $activetab; } - + function GetPrimaryKeys(&$db, $table) { return $db->MetaPrimaryKeys($table); } - - // error handler for both PHP4+5. + + // error handler for both PHP4+5. function Error($err,$fn) { global $_ADODB_ACTIVE_DBS; - + $fn = get_class($this).'::'.$fn; $this->_lasterr = $fn.': '.$err; - + if ($this->_dbat < 0) $db = false; else { $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; $db = $activedb->db; } - - if (function_exists('adodb_throw')) { + + if (function_exists('adodb_throw')) { if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false); else adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db); } else if (!$db || $db->debug) ADOConnection::outp($this->_lasterr); - + } - + // return last error message function ErrorMsg() { if (!function_exists('adodb_throw')) { if ($this->_dbat < 0) $db = false; else $db = $this->DB(); - + // last error could be database error too if ($db && $db->ErrorMsg()) return $db->ErrorMsg(); } return $this->_lasterr; } - - function ErrorNo() + + function ErrorNo() { if ($this->_dbat < 0) return -9999; // no database connection... $db = $this->DB(); - + return (int) $db->ErrorNo(); } @@ -549,7 +549,7 @@ class ADODB_Active_Record { function DB() { global $_ADODB_ACTIVE_DBS; - + if ($this->_dbat < 0) { $false = false; $this->Error("No database connection set: use ADOdb_Active_Record::SetDatabaseAdaptor(\$db)", "DB"); @@ -559,7 +559,7 @@ class ADODB_Active_Record { $db = $activedb->db; return $db; } - + // retrieve ADODB_Active_Table function &TableInfo() { @@ -568,8 +568,8 @@ class ADODB_Active_Record { $table = $activedb->tables[$this->_tableat]; return $table; } - - + + // I have an ON INSERT trigger on a table that sets other columns in the table. // So, I find that for myTable, I want to reload an active record after saving it. -- Malcolm Cook function Reload() @@ -580,21 +580,21 @@ class ADODB_Active_Record { return($this->Load($where)); } - + // set a numeric array (using natural table field ordering) as object properties function Set(&$row) { global $ACTIVE_RECORD_SAFETY; - + $db = $this->DB(); - + if (!$row) { - $this->_saved = false; + $this->_saved = false; return false; } - + $this->_saved = true; - + $table = $this->TableInfo(); if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) { # @@ -613,7 +613,7 @@ class ADODB_Active_Record { } else $keys = array_keys($row); - + # reset($keys); $this->_original = array(); @@ -627,7 +627,7 @@ class ADODB_Active_Record { # return true; } - + // get last inserted id for INSERT function LastInsertID(&$db,$fieldname) { @@ -635,32 +635,32 @@ class ADODB_Active_Record { $val = $db->Insert_ID($this->_table,$fieldname); else $val = false; - + if (is_null($val) || $val === false) { // this might not work reliably in multi-user environment return $db->GetOne("select max(".$fieldname.") from ".$this->_table); } return $val; } - + // quote data in where clause function doquote(&$db, $val,$t) { switch($t) { case 'L': if (strpos($db->databaseType,'postgres') !== false) return $db->qstr($val); - case 'D': + case 'D': case 'T': if (empty($val)) return 'null'; - - case 'B': + + case 'B': case 'N': case 'C': case 'X': if (is_null($val)) return 'null'; - - if (strlen($val)>1 && - (strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) { + + if (strlen($val)>1 && + (strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) { return $db->qstr($val); break; } @@ -669,13 +669,13 @@ class ADODB_Active_Record { break; } } - + // generate where clause for an UPDATE/SELECT function GenWhere(&$db, &$table) { $keys = $table->keys; $parr = array(); - + foreach($keys as $k) { $f = $table->flds[$k]; if ($f) { @@ -684,17 +684,17 @@ class ADODB_Active_Record { } return implode(' and ', $parr); } - - + + function _QName($n,$db=false) { if (!ADODB_Active_Record::$_quoteNames) return $n; if (!$db) $db = $this->DB(); if (!$db) return false; return $db->nameQuote.$n.$db->nameQuote; } - + //------------------------------------------------------------ Public functions below - + function Load($where=null,$bindarr=false) { $this->_where = $where; @@ -705,31 +705,31 @@ class ADODB_Active_Record { } return $this->LoadFromRawQuery($qry, $bindarr); } - + function LoadFromRawQuery($qry, $bindarr=false) { global $ADODB_FETCH_MODE; - + $db = $this->DB(); if (!$db) return false; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false); - + $row = $db->GetRow($qry,$bindarr); - + if (isset($savem)) $db->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + return $this->Set($row); } - + # useful for multiple record inserts # see http://phplens.com/lens/lensforum/msgs.php?id=17795 function Reset() { $this->_where=null; - $this->_saved = false; - $this->_lasterr = false; + $this->_saved = false; + $this->_lasterr = false; $this->_original = false; $vars=get_object_vars($this); foreach($vars as $k=>$v){ @@ -740,24 +740,24 @@ class ADODB_Active_Record { $this->foreignName=strtolower(get_class($this)); return true; } - + // false on error function Save() { if ($this->_saved) $ok = $this->Update(); else $ok = $this->Insert(); - + return $ok; } - - + + // false on error function Insert() { $db = $this->DB(); if (!$db) return false; $cnt = 0; $table = $this->TableInfo(); - + $valarr = array(); $names = array(); $valstr = array(); @@ -771,7 +771,7 @@ class ADODB_Active_Record { $cnt += 1; } } - + if (empty($names)){ foreach($table->flds as $name=>$fld) { $valarr[] = null; @@ -782,7 +782,7 @@ class ADODB_Active_Record { } $sql = 'INSERT INTO '.$this->_table."(".implode(',',$names).') VALUES ('.implode(',',$valstr).')'; $ok = $db->Execute($sql,$valarr); - + if ($ok) { $this->_saved = true; $autoinc = false; @@ -797,32 +797,32 @@ class ADODB_Active_Record { $this->$k = $this->LastInsertID($db,$k); } } - + $this->_original = $valarr; return !empty($ok); } - + function Delete() { $db = $this->DB(); if (!$db) return false; $table = $this->TableInfo(); - + $where = $this->GenWhere($db,$table); $sql = 'DELETE FROM '.$this->_table.' WHERE '.$where; $ok = $db->Execute($sql); - + return $ok ? true : false; } - + protected function intify($ret) { if(is_numeric($ret)) { return intval($ret); } else { - return $ret; + return $ret; } - + } - + function Aggregate($function, $column, $whereGroupBy, $bindarr=false) { if(!in_array($function, ADODB_Active_Record::$_supportedAggregateFunctions)) { throw new InvalidArgumentException("Unknown Aggregate Function $function"); @@ -833,11 +833,11 @@ class ADODB_Active_Record { $db = $this->DB(); if (!$db || empty($this->_table)) return false; return $db->GetOne("select $function($column) from ".$this->_table." where ". $whereGroupBy, $bindarr); } - + function Count($whereGroupBy, $bindarr=false) { return $this->intify( $this->Aggregate("count", "*", $whereGroupBy, $bindarr) ); } - + function CountDistinct($column, $whereGroupBy, $bindarr=false) { if(!in_array($column, $this->GetAttributeNames())) { throw new InvalidArgumentException("Unknown Column for CountDistinct $column"); @@ -845,7 +845,7 @@ class ADODB_Active_Record { $db = $this->DB(); if (!$db || empty($this->_table)) return false; return $this->intify( $db->GetOne("select count(distinct($column)) from ".$this->_table." where ". $whereGroupBy, $bindarr) ); } - + // returns an array of active record objects function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()) { @@ -853,7 +853,7 @@ class ADODB_Active_Record { $arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr,$extra); return $arr; } - + // returns an array of active record objects function FindFromRawQuery($query,$bindarr=false,$pkeysArr=false,$extra=array()) { @@ -861,17 +861,17 @@ class ADODB_Active_Record { $arr = $db->GetActiveRecordsClass2(get_class($this),$this->_table, $query,$bindarr,$pkeysArr,$extra); return $arr; } - + // returns 0 on error, 1 on update, 2 on insert function Replace() { global $ADODB_ASSOC_CASE; - + $db = $this->DB(); if (!$db) return false; $table = $this->TableInfo(); - + $pkey = $table->keys; - + foreach($table->flds as $name=>$fld) { $val = $this->$name; /* @@ -887,24 +887,24 @@ class ADODB_Active_Record { if (is_null($val) && !empty($fld->auto_increment)) { continue; } - + if (is_array($val)) continue; - + $t = $db->MetaType($fld->type); $arr[$name] = $this->doquote($db,$val,$t); $valarr[] = $val; } - + if (!is_array($pkey)) $pkey = array($pkey); - - - if ($ADODB_ASSOC_CASE == 0) + + + if ($ADODB_ASSOC_CASE == 0) foreach($pkey as $k => $v) $pkey[$k] = strtolower($v); - elseif ($ADODB_ASSOC_CASE == 1) + elseif ($ADODB_ASSOC_CASE == 1) foreach($pkey as $k => $v) $pkey[$k] = strtoupper($v); - + $ok = $db->Replace($this->_table,$arr,$pkey); if ($ok) { $this->_saved = true; // 1= update 2=insert @@ -921,9 +921,9 @@ class ADODB_Active_Record { $this->$k = $this->LastInsertID($db,$k); } } - + $this->_original = $valarr; - } + } return $ok; } @@ -932,14 +932,14 @@ class ADODB_Active_Record { { $db = $this->DB(); if (!$db) return false; $table = $this->TableInfo(); - + $where = $this->GenWhere($db, $table); - + if (!$where) { $this->error("Where missing for table $table", "Update"); return false; } - $valarr = array(); + $valarr = array(); $neworig = array(); $pairs = array(); $i = -1; @@ -948,10 +948,10 @@ class ADODB_Active_Record { $i += 1; $val = $this->$name; $neworig[] = $val; - - if (isset($table->keys[$name]) || is_array($val)) + + if (isset($table->keys[$name]) || is_array($val)) continue; - + if (is_null($val)) { if (isset($fld->not_null) && $fld->not_null) { if (isset($fld->default_value) && strlen($fld->default_value)) continue; @@ -969,8 +969,8 @@ class ADODB_Active_Record { $pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt); $cnt += 1; } - - + + if (!$cnt) return -1; $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where; $ok = $db->Execute($sql,$valarr); @@ -980,21 +980,21 @@ class ADODB_Active_Record { } return 0; } - + function GetAttributeNames() { $table = $this->TableInfo(); if (!$table) return false; return array_keys($table->flds); } - + }; function adodb_GetActiveRecordsClass(&$db, $class, $table,$whereOrderBy,$bindarr, $primkeyArr, $extra) { $qry = "select * from ".$table; - + if (!empty($whereOrderBy)) { $qry .= ' WHERE '.$whereOrderBy; } @@ -1006,7 +1006,7 @@ function adodb_GetActiveRecordsClass2(&$db, $class, $table, $qry, $bindarr, $pri { global $_ADODB_ACTIVE_DBS; - + $save = $db->SetFetchMode(ADODB_FETCH_NUM); if(isset($extra['limit'])) { @@ -1027,13 +1027,13 @@ function adodb_GetActiveRecordsClass2(&$db, $class, $table, $qry, $bindarr, $pri } $db->SetFetchMode($save); - + $false = false; - - if ($rows === false) { + + if ($rows === false) { return $false; } - + if (!class_exists($class)) { $db->outp_throw("Unknown class $class in GetActiveRecordsClass()",'GetActiveRecordsClass'); @@ -1047,7 +1047,7 @@ function adodb_GetActiveRecordsClass2(&$db, $class, $table, $qry, $bindarr, $pri $arrRef = array(); $bTos = array(); // Will store belongTo's indices if any foreach($rows as $row) { - + $obj = new $class($table,$primkeyArr,$db); if ($obj->ErrorNo()){ $db->_errorMsg = $obj->ErrorMsg(); @@ -1055,7 +1055,7 @@ function adodb_GetActiveRecordsClass2(&$db, $class, $table, $qry, $bindarr, $pri } $obj->Set($row); $arr[] = $obj; - } // foreach($rows as $row) + } // foreach($rows as $row) return $arr; } diff --git a/core/lib/composer/vendor/bin/export-plural-rules b/core/lib/composer/vendor/bin/export-plural-rules deleted file mode 120000 index d727a051..00000000 --- a/core/lib/composer/vendor/bin/export-plural-rules +++ /dev/null @@ -1 +0,0 @@ -../gettext/languages/bin/export-plural-rules \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/export-plural-rules b/core/lib/composer/vendor/bin/export-plural-rules new file mode 100755 index 00000000..e246599c --- /dev/null +++ b/core/lib/composer/vendor/bin/export-plural-rules @@ -0,0 +1,4 @@ +#!/usr/bin/env php + Enviro::$outputUSAscii)); + } else { + echo call_user_func(array(Exporter::getExporterClassName(Enviro::$outputFormat), 'toString'), $languages, array('us-ascii' => Enviro::$outputUSAscii)); + } +} catch (Exception $x) { + Enviro::echoErr($x->getMessage()."\n"); + Enviro::echoErr("Trace:\n"); + Enviro::echoErr($x->getTraceAsString()."\n"); + die(4); +} + +die(0); + +/** + * Helper class to handle command line options. + */ +class Enviro +{ + /** + * Shall the output contain only US-ASCII characters? + * @var bool + */ + public static $outputUSAscii; + /** + * The output format. + * @var string + */ + public static $outputFormat; + /** + * Output file name. + * @var string + */ + public static $outputFilename; + /** + * List of wanted language IDs; it not set: all languages will be returned. + * @var array|null + */ + public static $languages; + /** + * Reduce the language list to the minimum common denominator. + * @var bool + */ + public static $reduce; + /** + * Parse the command line options. + */ + public static function initialize() + { + global $argv; + self::$outputUSAscii = false; + self::$outputFormat = null; + self::$outputFilename = null; + self::$languages = null; + self::$reduce = null; + $exporters = Exporter::getExporters(); + if (isset($argv) && is_array($argv)) { + foreach ($argv as $argi => $arg) { + if ($argi === 0) { + continue; + } + if (is_string($arg)) { + $argLC = trim(strtolower($arg)); + switch ($argLC) { + case '--us-ascii': + self::$outputUSAscii = true; + break; + case '--reduce=yes': + self::$reduce = true; + break; + case '--reduce=no': + self::$reduce = false; + break; + default: + if (preg_match('/^--output=.+$/', $argLC)) { + if (isset(self::$outputFilename)) { + self::echoErr("The output file name has been specified more than once!\n"); + self::showSyntax(); + die(3); + } + list(, self::$outputFilename) = explode('=', $arg, 2); + self::$outputFilename = trim(self::$outputFilename); + } elseif (preg_match('/^--languages?=.+$/', $argLC)) { + list(, $s) = explode('=', $arg, 2); + $list = explode(',', $s); + if (is_array(self::$languages)) { + self::$languages = array_merge(self::$languages, $list); + } else { + self::$languages = $list; + } + } elseif (isset($exporters[$argLC])) { + if (isset(self::$outputFormat)) { + self::echoErr("The output format has been specified more than once!\n"); + self::showSyntax(); + die(3); + } + self::$outputFormat = $argLC; + } else { + self::echoErr("Unknown option: $arg\n"); + self::showSyntax(); + die(2); + } + break; + } + } + } + } + if (!isset(self::$outputFormat)) { + self::showSyntax(); + die(1); + } + if (isset(self::$languages)) { + self::$languages = array_values(array_unique(self::$languages)); + } + if (!isset(self::$reduce)) { + self::$reduce = isset(self::$languages) ? false : true; + } + } + + /** + * Write out the syntax. + */ + public static function showSyntax() + { + $exporters = array_keys(Exporter::getExporters(true)); + self::echoErr("Syntax: php ".basename(__FILE__)." [--us-ascii] [--languages=[,,...]] [--reduce=yes|no] [--output=] <".implode('|', $exporters).">\n"); + self::echoErr("Where:\n"); + self::echoErr("--us-ascii : if specified, the output will contain only US-ASCII characters.\n"); + self::echoErr("--languages: (or --language) export only the specified language codes.\n"); + self::echoErr(" Separate languages with commas; you can also use this argument\n"); + self::echoErr(" more than once; it's case insensitive and accepts both '_' and\n"); + self::echoErr(" '-' as locale chunks separator (eg we accept 'it_IT' as well as\n"); + self::echoErr(" 'it-it').\n"); + self::echoErr("--reduce : if set to yes the output won't contain languages with the same\n"); + self::echoErr(" base language and rules.\n For instance nl_BE ('Flemish') will be\n"); + self::echoErr(" omitted because it's the same as nl ('Dutch').\n"); + self::echoErr(" Defaults to 'no' --languages is specified, to 'yes' otherwise.\n"); + self::echoErr("--output : if specified, the output will be saved to . If not\n"); + self::echoErr(" specified we'll output to standard output.\n"); + self::echoErr("Output formats\n"); + $len = max(array_map('strlen', $exporters)); + foreach ($exporters as $exporter) { + self::echoErr(str_pad($exporter, $len).": ".Exporter::getExporterDescription($exporter)."\n"); + } + } + /** + * Print a string to stderr. + * @param string $str The string to be printed out. + */ + public static function echoErr($str) + { + $hStdErr = @fopen('php://stderr', 'a'); + if ($hStdErr === false) { + echo $str; + } else { + fwrite($hStdErr, $str); + fclose($hStdErr); + } + } + /** + * Reduce a language list to the minimum common denominator. + * @param Language[] $languages + * @return Language[] + */ + public static function reduce($languages) + { + for ($numChunks = 3; $numChunks >= 2; $numChunks--) { + $filtered = array(); + foreach ($languages as $language) { + $chunks = explode('_', $language->id); + $compatibleFound = false; + if (count($chunks) === $numChunks) { + $categoriesHash = serialize($language->categories); + $otherIds = array(); + $otherIds[] = $chunks[0]; + for ($k = 2; $k < $numChunks; $k++) { + $otherIds[] = $chunks[0].'_'.$chunks[$numChunks - 1]; + } + + foreach ($languages as $check) { + foreach ($otherIds as $otherId) { + if (($check->id === $otherId) && ($check->formula === $language->formula) && (serialize($check->categories) === $categoriesHash)) { + $compatibleFound = true; + break; + } + } + if ($compatibleFound === true) { + break; + } + } + } + if (!$compatibleFound) { + $filtered[] = $language; + } + } + $languages = $filtered; + } + + return $languages; + } +} diff --git a/core/lib/composer/vendor/bin/markdown b/core/lib/composer/vendor/bin/markdown deleted file mode 120000 index 252d9870..00000000 --- a/core/lib/composer/vendor/bin/markdown +++ /dev/null @@ -1 +0,0 @@ -../cebe/markdown/bin/markdown \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/markdown b/core/lib/composer/vendor/bin/markdown new file mode 100755 index 00000000..f8893e05 --- /dev/null +++ b/core/lib/composer/vendor/bin/markdown @@ -0,0 +1,170 @@ +#!/usr/bin/env php + ['cebe\\markdown\\GithubMarkdown', __DIR__ . '/../GithubMarkdown.php'], + 'extra' => ['cebe\\markdown\\MarkdownExtra', __DIR__ . '/../MarkdownExtra.php'], +]; + +$full = false; +$src = []; +foreach($argv as $k => $arg) { + if ($k == 0) { + continue; + } + if ($arg[0] == '-') { + $arg = explode('=', $arg); + switch($arg[0]) { + case '--flavor': + if (isset($arg[1])) { + if (isset($flavors[$arg[1]])) { + require($flavors[$arg[1]][1]); + $flavor = $flavors[$arg[1]][0]; + } else { + error("Unknown flavor: " . $arg[1], "usage"); + } + } else { + error("Incomplete argument --flavor!", "usage"); + } + break; + case '--full': + $full = true; + break; + case '-h': + case '--help': + echo "PHP Markdown to HTML converter\n"; + echo "------------------------------\n\n"; + echo "by Carsten Brandt \n\n"; + usage(); + break; + default: + error("Unknown argument " . $arg[0], "usage"); + } + } else { + $src[] = $arg; + } +} + +if (empty($src)) { + $markdown = file_get_contents("php://stdin"); +} elseif (count($src) == 1) { + $file = reset($src); + if (!file_exists($file)) { + error("File does not exist:" . $file); + } + $markdown = file_get_contents($file); +} else { + error("Converting multiple files is not yet supported.", "usage"); +} + +/** @var cebe\markdown\Parser $md */ +$md = new $flavor(); +$markup = $md->parse($markdown); + +if ($full) { + echo << + + + + + + +$markup + + +HTML; +} else { + echo $markup; +} + +// functions + +/** + * Display usage information + */ +function usage() { + global $argv; + $cmd = $argv[0]; + echo <<] [--full] [file.md] + + --flavor specifies the markdown flavor to use. If omitted the original markdown by John Gruber [1] will be used. + Available flavors: + + gfm - Github flavored markdown [2] + extra - Markdown Extra [3] + + --full ouput a full HTML page with head and body. If not given, only the parsed markdown will be output. + + --help shows this usage information. + + If no file is specified input will be read from STDIN. + +Examples: + + Render a file with original markdown: + + $cmd README.md > README.html + + Render a file using gihtub flavored markdown: + + $cmd --flavor=gfm README.md > README.html + + Convert the original markdown description to html using STDIN: + + curl http://daringfireball.net/projects/markdown/syntax.text | $cmd > md.html + + +[1] http://daringfireball.net/projects/markdown/syntax +[2] https://help.github.com/articles/github-flavored-markdown +[3] http://michelf.ca/projects/php-markdown/extra/ + +EOF; + exit(1); +} + +/** + * Send custom error message to stderr + * @param $message string + * @param $callback mixed called before script exit + * @return void + */ +function error($message, $callback = null) { + $fe = fopen("php://stderr", "w"); + fwrite($fe, "Error: " . $message . "\n"); + + if (is_callable($callback)) { + call_user_func($callback); + } + + exit(1); +} diff --git a/core/lib/composer/vendor/bin/phpunit b/core/lib/composer/vendor/bin/phpunit deleted file mode 120000 index 2c489303..00000000 --- a/core/lib/composer/vendor/bin/phpunit +++ /dev/null @@ -1 +0,0 @@ -../phpunit/phpunit/phpunit \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/phpunit b/core/lib/composer/vendor/bin/phpunit new file mode 100755 index 00000000..8271fa34 --- /dev/null +++ b/core/lib/composer/vendor/bin/phpunit @@ -0,0 +1,53 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (version_compare('7.0.0', PHP_VERSION, '>')) { + fwrite( + STDERR, + sprintf( + 'This version of PHPUnit is supported on PHP 7.0 and PHP 7.1.' . PHP_EOL . + 'You are using PHP %s (%s).' . PHP_EOL, + PHP_VERSION, + PHP_BINARY + ) + ); + + die(1); +} + +if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); +} + +foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) { + if (file_exists($file)) { + define('PHPUNIT_COMPOSER_INSTALL', $file); + + break; + } +} + +unset($file); + +if (!defined('PHPUNIT_COMPOSER_INSTALL')) { + fwrite( + STDERR, + 'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL . + ' composer install' . PHP_EOL . PHP_EOL . + 'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL + ); + + die(1); +} + +require PHPUNIT_COMPOSER_INSTALL; + +PHPUnit\TextUI\Command::main(); diff --git a/core/lib/composer/vendor/bin/robo b/core/lib/composer/vendor/bin/robo deleted file mode 120000 index 701d42dd..00000000 --- a/core/lib/composer/vendor/bin/robo +++ /dev/null @@ -1 +0,0 @@ -../consolidation/robo/robo \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/robo b/core/lib/composer/vendor/bin/robo new file mode 100755 index 00000000..2093bd11 --- /dev/null +++ b/core/lib/composer/vendor/bin/robo @@ -0,0 +1,22 @@ +#!/usr/bin/env php +setSelfUpdateRepository('consolidation/robo'); +$statusCode = $runner->execute($_SERVER['argv']); +exit($statusCode); diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src deleted file mode 120000 index 929cb3dc..00000000 --- a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src +++ /dev/null @@ -1 +0,0 @@ -../../src \ No newline at end of file diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Config.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Config.php new file mode 100644 index 00000000..25f714f2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Config.php @@ -0,0 +1,157 @@ +config = new Data($data); + $this->setDefaults(new Data()); + } + + /** + * {@inheritdoc} + */ + public function has($key) + { + return ($this->config->has($key)); + } + + /** + * {@inheritdoc} + */ + public function get($key, $defaultFallback = null) + { + if ($this->has($key)) { + return $this->config->get($key); + } + return $this->getDefault($key, $defaultFallback); + } + + /** + * {@inheritdoc} + */ + public function set($key, $value) + { + $this->config->set($key, $value); + return $this; + } + + /** + * {@inheritdoc} + */ + public function import($data) + { + return $this->replace($data); + } + + /** + * {@inheritdoc} + */ + public function replace($data) + { + $this->config = new Data($data); + return $this; + } + + /** + * {@inheritdoc} + */ + public function combine($data) + { + if (!empty($data)) { + $this->config->import($data, true); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function export() + { + return $this->config->export(); + } + + /** + * {@inheritdoc} + */ + public function hasDefault($key) + { + return $this->getDefaults()->has($key); + } + + /** + * {@inheritdoc} + */ + public function getDefault($key, $defaultFallback = null) + { + return $this->hasDefault($key) ? $this->getDefaults()->get($key) : $defaultFallback; + } + + /** + * {@inheritdoc} + */ + public function setDefault($key, $value) + { + $this->getDefaults()->set($key, $value); + return $this; + } + + /** + * Return the class $defaults property and ensure it's a Data object + * TODO: remove Data object validation in 2.0 + * + * @return Data + */ + protected function getDefaults() + { + // Ensure $this->defaults is a Data object (not an array) + if (!$this->defaults instanceof Data) { + $this->setDefaults($this->defaults); + } + return $this->defaults; + } + + /** + * Sets the $defaults class parameter + * TODO: remove support for array in 2.0 as this would currently break backward compatibility + * + * @param Data|array $defaults + * + * @throws \Exception + */ + protected function setDefaults($defaults) + { + if (is_array($defaults)) { + $this->defaults = new Data($defaults); + } elseif ($defaults instanceof Data) { + $this->defaults = $defaults; + } else { + throw new \Exception("Unknown type provided for \$defaults"); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/ConfigInterface.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/ConfigInterface.php new file mode 100644 index 00000000..5124ea1f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/ConfigInterface.php @@ -0,0 +1,105 @@ + default-value + */ + public function getGlobalOptionDefaultValues(); +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForCommand.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForCommand.php new file mode 100644 index 00000000..ce2646e1 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForCommand.php @@ -0,0 +1,127 @@ +config = $config; + } + + public function setApplication(Application $application) + { + $this->application = $application; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ConsoleEvents::COMMAND => 'injectConfiguration']; + } + + /** + * Before a Console command runs, inject configuration settings + * for this command into the default value of the options of + * this command. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function injectConfiguration(ConsoleCommandEvent $event) + { + $command = $event->getCommand(); + $this->injectConfigurationForGlobalOptions($event->getInput()); + $this->injectConfigurationForCommand($command, $event->getInput()); + + $targetOfHelpCommand = $this->getHelpCommandTarget($command, $event->getInput()); + if ($targetOfHelpCommand) { + $this->injectConfigurationForCommand($targetOfHelpCommand, $event->getInput()); + } + } + + protected function injectConfigurationForGlobalOptions($input) + { + if (!$this->application) { + return; + } + + $configGroup = new ConfigFallback($this->config, 'options'); + + $definition = $this->application->getDefinition(); + $options = $definition->getOptions(); + + return $this->injectConfigGroupIntoOptions($configGroup, $options, $input); + } + + protected function injectConfigurationForCommand($command, $input) + { + $commandName = $command->getName(); + $commandName = str_replace(':', '.', $commandName); + $configGroup = new ConfigFallback($this->config, $commandName, 'command.', '.options.'); + + $definition = $command->getDefinition(); + $options = $definition->getOptions(); + + return $this->injectConfigGroupIntoOptions($configGroup, $options, $input); + } + + protected function injectConfigGroupIntoOptions($configGroup, $options, $input) + { + foreach ($options as $option => $inputOption) { + $key = str_replace('.', '-', $option); + $value = $configGroup->get($key); + if ($value !== null) { + if (is_bool($value) && ($value == true)) { + $input->setOption($key, $value); + } elseif ($inputOption->acceptValue()) { + $inputOption->setDefault($value); + } + } + } + } + + protected function getHelpCommandTarget($command, $input) + { + if (($command->getName() != 'help') || (!isset($this->application))) { + return false; + } + + $this->fixInputForSymfony2($command, $input); + + // Symfony Console helpfully swaps 'command_name' and 'command' + // depending on whether the user entered `help foo` or `--help foo`. + // One of these is always `help`, and the other is the command we + // are actually interested in. + $nameOfCommandToDescribe = $input->getArgument('command_name'); + if ($nameOfCommandToDescribe == 'help') { + $nameOfCommandToDescribe = $input->getArgument('command'); + } + return $this->application->find($nameOfCommandToDescribe); + } + + protected function fixInputForSymfony2($command, $input) + { + // Symfony 3.x prepares $input for us; Symfony 2.x, on the other + // hand, passes it in prior to binding with the command definition, + // so we have to go to a little extra work. It may be inadvisable + // to do these steps for commands other than 'help'. + if (!$input->hasArgument('command_name')) { + $command->ignoreValidationErrors(); + $command->mergeApplicationDefinition(); + $input->bind($command->getDefinition()); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForSetters.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForSetters.php new file mode 100644 index 00000000..5ec87042 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Inject/ConfigForSetters.php @@ -0,0 +1,47 @@ +config = new ConfigMerge($config, $group, $prefix, $postfix); + } + + public function apply($object, $configurationKey) + { + $settings = $this->config->get($configurationKey); + foreach ($settings as $setterMethod => $args) { + $fn = [$object, $setterMethod]; + if (is_callable($fn)) { + $result = call_user_func_array($fn, (array)$args); + + // We require that $fn must only be used with setter methods. + // Setter methods are required to always return $this so that + // they may be chained. We will therefore throw an exception + // for any setter that returns something else. + if ($result != $object) { + $methodDescription = get_class($object) . "::$setterMethod"; + $propertyDescription = $this->config->describe($configurationKey); + throw new \Exception("$methodDescription did not return '\$this' when processing $propertyDescription."); + } + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoader.php new file mode 100644 index 00000000..ecc6f64f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoader.php @@ -0,0 +1,35 @@ +source; + } + + protected function setSourceName($source) + { + $this->source = $source; + return $this; + } + + public function export() + { + return $this->config; + } + + public function keys() + { + return array_keys($this->config); + } + + abstract public function load($path); +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoaderInterface.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoaderInterface.php new file mode 100644 index 00000000..9b155c1b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/ConfigLoaderInterface.php @@ -0,0 +1,29 @@ +expander = $expander ?: new Expander(); + } + + /** + * Extend the configuration to be processed with the + * configuration provided by the specified loader. + * + * @param ConfigLoaderInterface $loader + */ + public function extend(ConfigLoaderInterface $loader) + { + return $this->addFromSource($loader->export(), $loader->getSourceName()); + } + + /** + * Extend the configuration to be processed with + * the provided nested array. + * + * @param array $data + */ + public function add($data) + { + $this->unprocessedConfig[] = $data; + return $this; + } + + /** + * Extend the configuration to be processed with + * the provided nested array. Also record the name + * of the data source, if applicable. + * + * @param array $data + * @param string $source + */ + protected function addFromSource($data, $source = '') + { + if (empty($source)) { + return $this->add($data); + } + $this->unprocessedConfig[$source] = $data; + return $this; + } + + /** + * Process all of the configuration that has been collected, + * and return a nested array. + * + * @return array + */ + public function export($referenceArray = []) + { + if (!empty($this->unprocessedConfig)) { + $this->processedConfig = $this->process( + $this->processedConfig, + $this->fetchUnprocessed(), + $referenceArray + ); + } + return $this->processedConfig; + } + + /** + * To aid in debugging: return the source of each configuration item. + * n.b. Must call this function *before* export and save the result + * if persistence is desired. + */ + public function sources() + { + $sources = []; + foreach ($this->unprocessedConfig as $sourceName => $config) { + if (!empty($sourceName)) { + $configSources = ArrayUtil::fillRecursive($config, $sourceName); + $sources = ArrayUtil::mergeRecursiveDistinct($sources, $configSources); + } + } + return $sources; + } + + /** + * Get the configuration to be processed, and clear out the + * 'unprocessed' list. + * + * @return array + */ + protected function fetchUnprocessed() + { + $toBeProcessed = $this->unprocessedConfig; + $this->unprocessedConfig = []; + return $toBeProcessed; + } + + /** + * Use a map-reduce to evaluate the items to be processed, + * and merge them into the processed array. + * + * @param array $processed + * @param array $toBeProcessed + * @return array + */ + protected function process(array $processed, array $toBeProcessed, $referenceArray = []) + { + $toBeReduced = array_map([$this, 'preprocess'], $toBeProcessed); + $reduced = array_reduce($toBeReduced, [$this, 'reduceOne'], $processed); + return $this->evaluate($reduced, $referenceArray); + } + + /** + * Process a single configuration file from the 'to be processed' + * list. By default this is a no-op. Override this method to + * provide any desired configuration preprocessing, e.g. dot-notation + * expansion of the configuration keys, etc. + * + * @param array $config + * @return array + */ + protected function preprocess(array $config) + { + return $config; + } + + /** + * Evaluate one item in the 'to be evaluated' list, and then + * merge it into the processed configuration (the 'carry'). + * + * @param array $processed + * @param array $config + * @return array + */ + protected function reduceOne(array $processed, array $config) + { + return ArrayUtil::mergeRecursiveDistinct($processed, $config); + } + + /** + * Evaluate one configuration item. + * + * @param array $processed + * @param array $config + * @return array + */ + protected function evaluate(array $config, $referenceArray = []) + { + return $this->expander->expandArrayProperties( + $config, + $referenceArray + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/YamlConfigLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/YamlConfigLoader.php new file mode 100644 index 00000000..45705662 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Loader/YamlConfigLoader.php @@ -0,0 +1,26 @@ +setSourceName($path); + + // We silently skip any nonexistent config files, so that + // clients may simply `load` all of their candidates. + if (!file_exists($path)) { + $this->config = []; + return $this; + } + $this->config = (array) Yaml::parse(file_get_contents($path)); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ArrayUtil.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ArrayUtil.php new file mode 100644 index 00000000..a23f854e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ArrayUtil.php @@ -0,0 +1,75 @@ + &$value) { + $merged[$key] = self::mergeRecursiveValue($merged, $key, $value); + } + return $merged; + } + + /** + * Process the value in an mergeRecursiveDistinct - make a recursive + * call if needed. + */ + protected static function mergeRecursiveValue(&$merged, $key, $value) + { + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { + return self::mergeRecursiveDistinct($merged[$key], $value); + } + return $value; + } + + /** + * Fills all of the leaf-node values of a nested array with the + * provided replacement value. + */ + public static function fillRecursive(array $data, $fill) + { + $result = []; + foreach ($data as $key => $value) { + $result[$key] = $fill; + if (self::isAssociative($value)) { + $result[$key] = self::fillRecursive($value, $fill); + } + } + return $result; + } + + /** + * Return true if the provided parameter is an array, and at least + * one key is non-numeric. + */ + public static function isAssociative($testArray) + { + if (!is_array($testArray)) { + return false; + } + foreach (array_keys($testArray) as $key) { + if (!is_numeric($key)) { + return true; + } + } + return false; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigFallback.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigFallback.php new file mode 100644 index 00000000..9f9972f6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigFallback.php @@ -0,0 +1,51 @@ +getWithFallback($key, $this->group, $this->prefix, $this->postfix); + } + + /** + * Fetch an option value from a given key, or, if that specific key does + * not contain a value, then consult various fallback options until a + * value is found. + * + */ + protected function getWithFallback($key, $group, $prefix = '', $postfix = '.') + { + $configKey = "{$prefix}{$group}${postfix}{$key}"; + if ($this->config->has($configKey)) { + return $this->config->get($configKey); + } + if ($this->config->hasDefault($configKey)) { + return $this->config->getDefault($configKey); + } + $moreGeneralGroupname = $this->moreGeneralGroupName($group); + if ($moreGeneralGroupname) { + return $this->getWithFallback($key, $moreGeneralGroupname, $prefix, $postfix); + } + return null; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigGroup.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigGroup.php new file mode 100644 index 00000000..24b29dd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigGroup.php @@ -0,0 +1,61 @@ +config = $config; + $this->group = $group; + $this->prefix = $prefix; + $this->postfix = $postfix; + } + + /** + * Return a description of the configuration group (with prefix and postfix). + */ + public function describe($property) + { + return $this->prefix . $this->group . $this->postfix . $property; + } + + /** + * Get the requested configuration key from the most specific configuration + * group that contains it. + */ + abstract public function get($key); + + /** + * Given a group name, such as "foo.bar.baz", return the next configuration + * group in the fallback hierarchy, e.g. "foo.bar". + */ + protected function moreGeneralGroupName($group) + { + $result = preg_replace('#\.[^.]*$#', '', $group); + if ($result != $group) { + return $result; + } + return false; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigMerge.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigMerge.php new file mode 100644 index 00000000..65fccf72 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigMerge.php @@ -0,0 +1,34 @@ +getWithMerge($key, $this->group, $this->prefix, $this->postfix); + } + + /** + * Merge available configuration from each configuration group. + */ + public function getWithMerge($key, $group, $prefix = '', $postfix = '.') + { + $configKey = "{$prefix}{$group}${postfix}{$key}"; + $result = $this->config->get($configKey, []); + if (!is_array($result)) { + throw new \UnexpectedValueException($configKey . ' must be a list of settings to apply.'); + } + $moreGeneralGroupname = $this->moreGeneralGroupName($group); + if ($moreGeneralGroupname) { + $result += $this->getWithMerge($key, $moreGeneralGroupname, $prefix, $postfix); + } + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigOverlay.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigOverlay.php new file mode 100644 index 00000000..d1f12697 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/ConfigOverlay.php @@ -0,0 +1,203 @@ +contexts[self::DEFAULT_CONTEXT] = new Config(); + $this->contexts[self::PROCESS_CONTEXT] = new Config(); + } + + /** + * Add a named configuration object to the configuration overlay. + * Configuration objects added LAST have HIGHEST priority, with the + * exception of the fact that the process context always has the + * highest priority. + * + * If a context has already been added, its priority will not change. + */ + public function addContext($name, ConfigInterface $config) + { + $process = $this->contexts[self::PROCESS_CONTEXT]; + unset($this->contexts[self::PROCESS_CONTEXT]); + $this->contexts[$name] = $config; + $this->contexts[self::PROCESS_CONTEXT] = $process; + + return $this; + } + + /** + * Add a placeholder context that will be prioritized higher than + * existing contexts. This is done to ensure that contexts added + * later will maintain a higher priority if the placeholder context + * is later relaced with a different configuration set via addContext(). + * + * @param string $name + * @return $this + */ + public function addPlaceholder($name) + { + return $this->addContext($name, new Config()); + } + + /** + * Increase the priority of the named context such that it is higher + * in priority than any existing context except for the 'process' + * context. + * + * @param string $name + * @return $this + */ + public function increasePriority($name) + { + $config = $this->getContext($name); + unset($this->contexts[$name]); + return $this->addContext($name, $config); + } + + public function hasContext($name) + { + return isset($this->contexts[$name]); + } + + public function getContext($name) + { + if ($this->hasContext($name)) { + return $this->contexts[$name]; + } + return new Config(); + } + + public function removeContext($name) + { + unset($this->contexts[$name]); + } + + /** + * Determine if a non-default config value exists. + */ + public function findContext($key) + { + foreach (array_reverse($this->contexts) as $name => $config) { + if ($config->has($key)) { + return $config; + } + } + return false; + } + + /** + * @inheritdoc + */ + public function has($key) + { + return $this->findContext($key) != false; + } + + /** + * @inheritdoc + */ + public function get($key, $default = null) + { + $context = $this->findContext($key); + if ($context) { + return $context->get($key, $default); + } + return $default; + } + + /** + * @inheritdoc + */ + public function set($key, $value) + { + $this->contexts[self::PROCESS_CONTEXT]->set($key, $value); + return $this; + } + + /** + * @inheritdoc + */ + public function import($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + public function replace($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + public function combine($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + protected function unsupported($fn) + { + throw new \Exception("The method '$fn' is not supported for the ConfigOverlay class."); + } + + /** + * @inheritdoc + */ + public function export() + { + $export = []; + foreach ($this->contexts as $name => $config) { + $export = array_merge_recursive($export, $config->export()); + } + return $export; + } + + /** + * @inheritdoc + */ + public function hasDefault($key) + { + return $this->contexts[self::DEFAULT_CONTEXT]->has($key); + } + + /** + * @inheritdoc + */ + public function getDefault($key, $default = null) + { + return $this->contexts[self::DEFAULT_CONTEXT]->get($key, $default); + } + + /** + * @inheritdoc + */ + public function setDefault($key, $value) + { + $this->contexts[self::DEFAULT_CONTEXT]->set($key, $value); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/EnvConfig.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/EnvConfig.php new file mode 100644 index 00000000..05f8d2a8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/src/Util/EnvConfig.php @@ -0,0 +1,96 @@ +prefix = strtoupper(rtrim($prefix, '_')) . '_'; + } + + /** + * @inheritdoc + */ + public function has($key) + { + return $this->get($key) !== null; + } + + /** + * @inheritdoc + */ + public function get($key, $defaultFallback = null) + { + $envKey = $this->prefix . strtoupper(strtr($key, '.-', '__')); + $envKey = str_replace($this->prefix . $this->prefix, $this->prefix, $envKey); + return getenv($envKey) ?: $defaultFallback; + } + + /** + * @inheritdoc + */ + public function set($key, $value) + { + throw new \Exception('Cannot call "set" on environmental configuration.'); + } + + /** + * @inheritdoc + */ + public function import($data) + { + // no-op + } + + /** + * @inheritdoc + */ + public function export() + { + return []; + } + + /** + * @inheritdoc + */ + public function hasDefault($key) + { + return false; + } + + /** + * @inheritdoc + */ + public function getDefault($key, $defaultFallback = null) + { + return $defaultFallback; + } + + /** + * @inheritdoc + */ + public function setDefault($key, $value) + { + throw new \Exception('Cannot call "setDefault" on environmental configuration.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests deleted file mode 120000 index c2ebfe53..00000000 --- a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests \ No newline at end of file diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForCommandTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForCommandTest.php new file mode 100644 index 00000000..41da3076 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForCommandTest.php @@ -0,0 +1,130 @@ + [ + 'global' => 'from-config', + ], + // Define some configuration settings for the options for + // the commands my:foo and my:bar. + 'command' => [ + 'my' => [ + // commands.my.options.* apply to all my:* commands. + 'options' => [ + 'dir' => '/etc/common', + 'priority' => 'normal', + ], + 'foo' => [ + // commands.my.foo.options.* apply only to the my:foo command. + 'options' => [ + 'name' => 'baz', + ], + ], + ], + ], + ]; + + $this->config = new Config($data); + } + + public function testInjection() + { + $command = new MyFooCommand(); + $input = new StringInput('my:foo'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +Enter my:foo +dir: /etc/common +name: baz +other: fish +EOT; + + $this->assertEquals(0, $status); + $this->assertEquals($expectedOutput, $output); + } + + public function testInjectionWithOverride() + { + $command = new MyFooCommand(); + $input = new StringInput('my:foo --name=Fred'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +Enter my:foo +dir: /etc/common +name: Fred +other: fish +EOT; + + $this->assertEquals(0, $status); + $this->assertEquals($expectedOutput, $output); + } + + public function testHelpDefaultInjection() + { + $command = new MyFooCommand(); + $input = new StringInput('help my:foo'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +What is the name of the thing we are naming [default: "baz"] +EOT; + + $this->assertEquals(0, $status); + $this->assertContains($expectedOutput, $output); + + $expectedOutput = <<< EOT +A certain global option. [default: "from-config"] +EOT; + + $this->assertContains($expectedOutput, $output); + } + + protected function runCommandViaApplication($command, $input) + { + $application = new Application('TestApplication', '0.0.0'); + $application->getDefinition() + ->addOption( + new InputOption('--global', null, InputOption::VALUE_REQUIRED, 'A certain global option.', 'hardcoded') + ); + + $output = new BufferedOutput(); + + $configInjector = new ConfigForCommand($this->config); + $configInjector->setApplication($application); + + $eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); + $eventDispatcher->addSubscriber($configInjector); + $application->setDispatcher($eventDispatcher); + + $application->setAutoExit(false); + $application->add($command); + + $statusCode = $application->run($input, $output); + $commandOutput = trim($output->fetch()); + + return [$statusCode, $commandOutput]; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForSettersTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForSettersTest.php new file mode 100644 index 00000000..422b0a00 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigForSettersTest.php @@ -0,0 +1,87 @@ + [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'dir' => '/override/dir', + ], + ], + ], + ], + ]; + $config = new Config($data); + + $applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.'); + + $testTarget = new ApplyConfigTestTarget(); + + $applicator->apply($testTarget, 'settings'); + + $this->assertEquals('/override/dir', $testTarget->getDir()); + $this->assertEquals(null, $testTarget->getBad()); + } + + public function testApplyBadConfig() + { + $data = [ + // Define some configuration settings for the configuration + // of some task \My\Tasks\Operations\Frobulate. + 'task' => [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'bad' => 'fire truck', + ], + ], + ], + ], + ]; + $config = new Config($data); + + $applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.'); + + $testTarget = new ApplyConfigTestTarget(); + + $exceptionMessage = ''; + try + { + $applicator->apply($testTarget, 'settings'); + } + catch (\Exception $e) + { + $exceptionMessage = $e->getMessage(); + } + // We would prefer it if bad methods were never called; unfortunately, + // declaring the return type of a method cannot be done in a reliable + // way (via reflection) until php 7, so we allow these methods to be + // called for now. + $this->assertEquals('fire truck', $testTarget->getBad()); + $this->assertEquals('Consolidation\\TestUtils\\ApplyConfigTestTarget::bad did not return \'$this\' when processing task.Operations.Frobulate.settings.', $exceptionMessage); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigGroupTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigGroupTest.php new file mode 100644 index 00000000..21e470e5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigGroupTest.php @@ -0,0 +1,91 @@ + [ + 'my' => [ + // commands.my.options.* apply to all my:* commands. + 'options' => [ + 'path' => '/etc/common', + 'priority' => 'normal', + ], + 'foo' => [ + // commands.my.foo.options.* apply only to the my:foo command. + 'options' => [ + 'name' => 'baz', + ], + ], + 'bar' => [ + // Similarly, commands.my.bar.options is for the my:bar command. + 'options' => [ + 'priority' => 'high', + ], + ], + ], + ], + // Define some configuration settings for the configuration + // of some task \My\Tasks\Operations\Frobulate. + 'task' => [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'object' => 'fire truck', + ], + ], + ], + ], + ]; + + $this->config = new Config($data); + } + + public function testDotNotation() + { + // Test the test + $this->assertEquals('baz', $this->config->get('command.my.foo.options.name')); + } + + public function testFallback() + { + $fooFallback = new ConfigFallback($this->config, 'my.foo', 'command.', '.options.'); + $barFallback = new ConfigFallback($this->config, 'my.bar', 'command.', '.options.'); + + $this->assertEquals(null, $barFallback->get('name')); + $this->assertEquals('baz', $fooFallback->get('name')); + $this->assertEquals('high', $barFallback->get('priority')); + + $this->assertEquals('normal', $fooFallback->get('priority')); + $this->assertEquals('/etc/common', $barFallback->get('path')); + $this->assertEquals('/etc/common', $fooFallback->get('path')); + } + + public function testMerge() + { + $frobulateMerge = new ConfigMerge($this->config, 'Operations.Frobulate', 'task.'); + + $settings = $frobulateMerge->get('settings'); + $this->assertEquals('fire truck', $settings['object']); + $this->assertEquals('/base/dir', $settings['dir']); + $keys = array_keys($settings); + sort($keys); + $this->assertEquals('dir,object', implode(',', $keys)); + } +} + diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigLoaderTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigLoaderTest.php new file mode 100644 index 00000000..6dedb1f3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigLoaderTest.php @@ -0,0 +1,29 @@ +assertTrue(file_exists($path)); + + $loader->load($path); + + $configFile = basename($loader->getSourceName()); + $this->assertEquals('config-1.yml', $configFile); + + // Make sure that the data we loaded contained the expected keys + $keys = $loader->keys(); + sort($keys); + $keysString = implode(',', $keys); + $this->assertEquals('c,m', $keysString); + + $configData = $loader->export(); + $this->assertEquals('foo', $configData['c']); + $this->assertEquals('1', $configData['m'][0]); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigOverlayTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigOverlayTest.php new file mode 100644 index 00000000..f7faf748 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigOverlayTest.php @@ -0,0 +1,168 @@ +import([ + 'hidden-by-a' => 'alias hidden-by-a', + 'hidden-by-process' => 'alias hidden-by-process', + 'options' =>[ + 'a-a' => 'alias-a', + ], + 'command' => [ + 'foo' => [ + 'bar' => [ + 'command' => [ + 'options' => [ + 'a-b' => 'alias-b', + ], + ], + ], + ], + ], + ]); + + $configFileContext = new Config(); + $configFileContext->import([ + 'hidden-by-cf' => 'config-file hidden-by-cf', + 'hidden-by-a' => 'config-file hidden-by-a', + 'hidden-by-process' => 'config-file hidden-by-process', + 'options' =>[ + 'cf-a' => 'config-file-a', + ], + 'command' => [ + 'foo' => [ + 'bar' => [ + 'command' => [ + 'options' => [ + 'cf-b' => 'config-file-b', + ], + ], + ], + ], + ], + ]); + + $this->overlay = new ConfigOverlay(); + $this->overlay->set('hidden-by-process', 'process-h'); + $this->overlay->addContext('cf', $configFileContext); + $this->overlay->addContext('a', $aliasContext); + $this->overlay->setDefault('df-a', 'default'); + $this->overlay->setDefault('hidden-by-a', 'default hidden-by-a'); + $this->overlay->setDefault('hidden-by-cf', 'default hidden-by-cf'); + $this->overlay->setDefault('hidden-by-process', 'default hidden-by-process'); + } + + public function testGetPriority() + { + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + $this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testDefault() + { + $this->assertEquals('alias-a', $this->overlay->get('options.a-a')); + $this->assertEquals('alias-a', $this->overlay->get('options.a-a', 'ignored')); + $this->assertEquals('default', $this->overlay->getDefault('df-a', 'ignored')); + $this->assertEquals('nsv', $this->overlay->getDefault('a-a', 'nsv')); + + $this->overlay->setDefault('df-a', 'new value'); + $this->assertEquals('new value', $this->overlay->getDefault('df-a', 'ignored')); + } + + public function testExport() + { + $data = $this->overlay->export(); + + $this->assertEquals('config-file-a', $data['options']['cf-a']); + $this->assertEquals('alias-a', $data['options']['a-a']); + } + + /** + * @expectedException Exception + */ + public function testImport() + { + $data = $this->overlay->import(['a' => 'value']); + } + + public function testMaintainPriority() + { + // Get and re-add the 'cf' context. Its priority should not change. + $configFileContext = $this->overlay->getContext('cf'); + $this->overlay->addContext('cf', $configFileContext); + + // These asserts are the same as in testGetPriority + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + $this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testChangePriority() + { + // Increase the priority of the 'cf' context. Now, it should have a higher + // priority than the 'alias' context, but should still have a lower + // priority than the 'process' context. + $this->overlay->increasePriority('cf'); + + // These asserts are the same as in testGetPriority + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + + // This one has changed: the config-file value is now found instead + // of the alias value. + $this->assertEquals('config-file hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testPlaceholder() + { + $this->overlay->addPlaceholder('lower'); + + $higherContext = new Config(); + $higherContext->import(['priority-test' => 'higher']); + + $lowerContext = new Config(); + $lowerContext->import(['priority-test' => 'lower']); + + // Usually 'lower' would have the highest priority, since it is + // added last. However, our earlier call to 'addPlaceholder' reserves + // a spot for it, so the 'higher' context will end up with a higher + // priority. + $this->overlay->addContext('higher', $higherContext); + $this->overlay->addContext('lower', $lowerContext); + $this->assertEquals('higher', $this->overlay->get('priority-test', 'neither')); + + // Test to see that we can change the value of the 'higher' context, + // and the change will be reflected in the overlay. + $higherContext->set('priority-test', 'changed'); + $this->assertEquals('changed', $this->overlay->get('priority-test', 'neither')); + + // Test to see that the 'process' context still has the highest priority. + $this->overlay->set('priority-test', 'process'); + $higherContext->set('priority-test', 'ignored'); + $this->assertEquals('process', $this->overlay->get('priority-test', 'neither')); + } + + public function testDoesNotHave() + { + $context = $this->overlay->getContext('no-such-context'); + $data = $context->export(); + $this->assertEquals('[]', json_encode($data)); + + $this->assertTrue(!$this->overlay->has('no-such-key')); + $this->assertTrue(!$this->overlay->hasDefault('no-such-default')); + + $this->assertEquals('no-such-value', $this->overlay->get('no-such-key', 'no-such-value')); + + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigProcessorTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigProcessorTest.php new file mode 100644 index 00000000..ac645a28 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigProcessorTest.php @@ -0,0 +1,152 @@ + 'foo', + 'm' => [1], + ]; + $config2 = [ + 'b' => '${c}bar', + 'm' => [2], + ]; + $config3 = [ + 'a' => '${b}baz', + 'm' => [3], + ]; + + $processor = new ConfigProcessor(); + $processor->add($config1); + $processor->add($config2); + $processor->add($config3); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + } + + public function processorForConfigMergeTest($provideSourceNames) + { + $config1 = [ + 'm' => [ + 'x' => 'x-1', + 'y' => [ + 'r' => 'r-1', + 's' => 's-1', + 't' => 't-1', + ], + 'z' => 'z-1', + ], + ]; + $config2 = [ + 'm' => [ + 'w' => 'w-2', + 'y' => [ + 'q' => 'q-2', + 's' => 's-2', + ], + 'z' => 'z-2', + ], + ]; + $config3 = [ + 'm' => [ + 'v' => 'v-3', + 'y' => [ + 't' => 't-3', + 'u' => 'u-3', + ], + 'z' => 'z-3', + ], + ]; + + $processor = new ConfigProcessor(); + $testLoader = new TestLoader(); + + $testLoader->set($config1); + $testLoader->setSourceName($provideSourceNames ? 'c-1' : ''); + $processor->extend($testLoader); + + $testLoader->set($config2); + $testLoader->setSourceName($provideSourceNames ? 'c-2' : ''); + $processor->extend($testLoader); + + $testLoader->set($config3); + $testLoader->setSourceName($provideSourceNames ? 'c-3' : ''); + $processor->extend($testLoader); + + return $processor; + } + + public function testConfigProcessorMergeAssociative() + { + $processor = $this->processorForConfigMergeTest(false); + $data = $processor->export(); + $this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data)); + } + + public function testConfigProcessorMergeAssociativeWithSourceNames() + { + $processor = $this->processorForConfigMergeTest(true); + $sources = $processor->sources(); + $data = $processor->export(); + $this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data)); + $this->assertEquals('c-1', $sources['m']['x']); + $this->assertEquals('c-1', $sources['m']['y']['r']); + $this->assertEquals('c-2', $sources['m']['w']); + $this->assertEquals('c-2', $sources['m']['y']['s']); + $this->assertEquals('c-3', $sources['m']['z']); + $this->assertEquals('c-3', $sources['m']['y']['u']); + } + + public function testConfiProcessorSources() + { + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + + $sources = $processor->sources(); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + + $this->assertEquals('3', $data['m'][0]); + + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']); + $this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']); + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['m']); + } + + public function testConfiProcessorSourcesLoadInReverseOrder() + { + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + + $sources = $processor->sources(); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + + $this->assertEquals('1', $data['m'][0]); + + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']); + $this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['m']); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigTest.php new file mode 100644 index 00000000..f2ace0ce --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/ConfigTest.php @@ -0,0 +1,140 @@ +set('foo', 'bar'); + $data = $config->export(); + $this->assertEquals('{"foo":"bar"}', json_encode($data)); + } + + public function testCombine() + { + // Pointless tests just to ensure everything is covered. + $config = new Config(); + $config->set('foo', 'bar'); + $config->set('baz', 'boz'); + $config2 = new Config(); + $config2->set('foo', 'fu'); + $config2->set('new', 'blue'); + $config->combine($config2->export()); + $this->assertEquals('fu', $config->get('foo')); + $this->assertEquals('boz', $config->get('baz')); + $this->assertEquals('blue', $config->get('new')); + } + + public function testDefault() + { + $data = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'boz', + ]; + + $foo = ["foo" => "bar"]; + + $config = new Config($data); + + $config->setDefault('c', 'other'); + $config->setDefault('d', 'other'); + $config->setDefault('f', $foo); + + $this->assertEquals('foo', $config->get('a')); + $this->assertEquals('boz', $config->get('c')); + $this->assertEquals('other', $config->get('d')); + $this->assertEquals('other', $config->getDefault('c')); + $this->assertEquals('', $config->get('e')); + $this->assertEquals('bar', $config->get('f.foo')); + $this->assertEquals('{"foo":"bar"}', json_encode($config->get('f'))); + } + + public function testDefaultsArray() + { + $data = ['a' => 'foo', 'b' => 'bar', 'c' => 'boz',]; + $defaults = ['d' => 'foo', 'e' => 'bar', 'f' => 'boz',]; + + // Create reflection class to test private methods + $configClass = new \ReflectionClass("Consolidation\Config\Config"); + + // $defaults + $defaultsProperty = $configClass->getProperty("defaults"); + $defaultsProperty->setAccessible(true); + + // $getDefaults + $getDefaultsMethod = $configClass->getMethod("getDefaults"); + $getDefaultsMethod->setAccessible(true); + + // Test the config class + $config = new Config($data); + + // Set $config::defaults to an array to test getter and setter + $defaultsProperty->setValue($config, $defaults); + $this->assertTrue(is_array($defaultsProperty->getValue($config))); + $this->assertInstanceOf('Dflydev\DotAccessData\Data', + $getDefaultsMethod->invoke($config)); + + // Set $config::defaults to a string to test exception + $defaultsProperty->setValue($config, "foo.bar"); + $this->setExpectedException("Exception"); + $getDefaultsMethod->invoke($config); + } + + public function testConfigurationWithCrossFileReferences() + { + $config = new Config(); + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + + // Does not fail if configuration file cannot be found + $processor->extend($loader->load(__DIR__ . '/data/no-such-file.yml')); + + // We must capture the sources before exporting, as export + // dumps this information. + $sources = $processor->sources(); + + $config->import($processor->export()); + + $this->assertEquals(implode(',', $config->get('m')), '3'); + $this->assertEquals($config->get('a'), 'foobarbaz'); + + $this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml'); + $this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml'); + $this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml'); + } + + public function testConfigurationWithReverseOrderCrossFileReferences() + { + $config = new Config(); + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + + $sources = $processor->sources(); + $config->import($processor->export()); + + $this->assertEquals(implode(',', $config->get('m')), '1'); + + if (strpos($config->get('a'), '$') !== false) { + throw new \PHPUnit_Framework_SkippedTestError( + 'Evaluation of cross-file references in reverse order not supported.' + ); + } + $this->assertEquals($config->get('a'), 'foobarbaz'); + + $this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml'); + $this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml'); + $this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml'); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-1.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-1.yml new file mode 100644 index 00000000..e8f55a9d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-1.yml @@ -0,0 +1,3 @@ +c: foo +m: + - 1 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-2.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-2.yml new file mode 100644 index 00000000..baa7e63f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-2.yml @@ -0,0 +1,3 @@ +b: ${c}bar +m: + - 2 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-3.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-3.yml new file mode 100644 index 00000000..d5895642 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/data/config-3.yml @@ -0,0 +1,3 @@ +a: ${b}baz +m: + - 3 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/install-scenario b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/install-scenario new file mode 100755 index 00000000..d77d57d0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/install-scenario @@ -0,0 +1,23 @@ +#!/bin/bash + +SCENARIO=$1 +ACTION=${2-install} + +dir=dependencies/${SCENARIO} +if [ -z "$SCENARIO" ] ; then + SCENARIO=default + dir=. +fi + + +if [ ! -d "$dir" ] ; then + echo "Requested scenario '${SCENARIO}' does not exist." + exit 1 +fi + +echo "Switch to ${SCENARIO} scenario" + +set -ex + +composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts +composer -n --working-dir=$dir info diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/prep-dependencies b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/prep-dependencies new file mode 100755 index 00000000..d1898440 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/prep-dependencies @@ -0,0 +1,66 @@ +#!/bin/bash + +# +# This script is called automatically on every `composer update`. +# See "post-update-cmd" in the "scripts" section of composer.json. +# +# This script will create a derived composer.json / composer.lock +# pair for every test scenario. Test scenarios are defined in the +# "scenarios" file, which should be customized to suit the needs +# of the project. +# + +SELF_DIRNAME="`dirname -- "$0"`" +source ${SELF_DIRNAME}/scenarios + +echo +echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" +echo "::" +echo ":: Update dependencies for the following scenarios:" +echo "::" +echo ":: ${SCENARIOS}" +echo "::" +echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" +echo + +set -ex + +for SCENARIO in ${SCENARIOS} ; do + + dir=dependencies/${SCENARIO} + + # Define indirect variable names + stability_variable="stability_${SCENARIO}" + requirement_variable="requirement_${SCENARIO}" + platform_php_variable="platform_php_${SCENARIO}" + + echo "### Create $dir/composer.json for ${SCENARIO} scenario" + mkdir -p $dir + cp composer.json $dir + + # Then set our own platform php version if applicable (otherwise unset it) + composer -n --working-dir=$dir config platform.php "${!platform_php_variable---unset}" + + # Temporarily set our vendor directory to 'vendor' + composer -n --working-dir=$dir config vendor-dir vendor + + # Set an appropriate minimum stability for this version of Symfony + composer -n --working-dir=$dir config minimum-stability "${!stability_variable-stable}" + + # Add a constraint to limit the Symfony version + composer -n --working-dir=$dir require --dev --no-update "${!requirement_variable}" + + # Create the composer.lock file. Ignore the vendor directory created. + composer -n --working-dir=$dir update --no-scripts + + # Set the vendor directory to its final desired location. + composer -n --working-dir=$dir config vendor-dir '../../vendor' + + # The 'autoload' section specifies directory paths that are relative + # to the composer.json file. We will drop in some symlinks so that + # these paths will resolve as if the composer.json were in the root. + for target in $AUTOLOAD_DIRECTORIES ; do + ln -s -f ../../$target $dir + done + +done diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/scenarios b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/scenarios new file mode 100755 index 00000000..6a8f81b2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/scripts/scenarios @@ -0,0 +1,12 @@ +#!/bin/bash + +SCENARIOS="symfony2 symfony3 symfony4" + +AUTOLOAD_DIRECTORIES='src tests' + +platform_php_symfony2='5.4' +platform_php_symfony3='5.6' + +requirement_symfony2='symfony/console:^2.8' +requirement_symfony3='symfony/console:^3' +requirement_symfony4='symfony/console:^4' diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/ApplyConfigTestTarget.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/ApplyConfigTestTarget.php new file mode 100644 index 00000000..6dace2be --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/ApplyConfigTestTarget.php @@ -0,0 +1,43 @@ +dir = $dir; + return $this; + } + + /** + * A getter for the 'dir' property that we will use to + * determine if the setter was called. + */ + public function getDir() + { + return $this->dir; + } + + /** + * A bad setter that does not return $this. + */ + public function bad($value) + { + $this->value = $value; + } + + /** + * A getter for the bad setter. + */ + public function getBad() + { + return $this->value; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/MyFooCommand.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/MyFooCommand.php new file mode 100644 index 00000000..0487a024 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/MyFooCommand.php @@ -0,0 +1,47 @@ +setName('my:foo') + ->setDescription('My foo command.') + ->setHelp('This command tests command option injection by echoing its options') + ->addOption( + 'other', + null, + InputOption::VALUE_REQUIRED, + 'Some other option', + 'fish' + ) + ->addOption( + 'name', + null, + InputOption::VALUE_REQUIRED, + 'What is the name of the thing we are naming', + 'George' + ) + ->addOption( + 'dir', + null, + InputOption::VALUE_REQUIRED, + 'What is the base directory to use for this command', + '/default/path' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Enter my:foo'); + $output->writeln('dir: ' . $input->getOption('dir')); + $output->writeln('name: ' . $input->getOption('name')); + $output->writeln('other: ' . $input->getOption('other')); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/TestLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/TestLoader.php new file mode 100644 index 00000000..241e5120 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony2/tests/src/TestLoader.php @@ -0,0 +1,36 @@ +data = $data; + } + + public function setSourceName($name) + { + $this->sourceName = $name; + } + + public function export() + { + return $this->data; + } + + public function keys() + { + return array_keys($this->data); + } + + public function getSourceName() + { + return $this->sourceName; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src deleted file mode 120000 index 929cb3dc..00000000 --- a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src +++ /dev/null @@ -1 +0,0 @@ -../../src \ No newline at end of file diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Config.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Config.php new file mode 100644 index 00000000..25f714f2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Config.php @@ -0,0 +1,157 @@ +config = new Data($data); + $this->setDefaults(new Data()); + } + + /** + * {@inheritdoc} + */ + public function has($key) + { + return ($this->config->has($key)); + } + + /** + * {@inheritdoc} + */ + public function get($key, $defaultFallback = null) + { + if ($this->has($key)) { + return $this->config->get($key); + } + return $this->getDefault($key, $defaultFallback); + } + + /** + * {@inheritdoc} + */ + public function set($key, $value) + { + $this->config->set($key, $value); + return $this; + } + + /** + * {@inheritdoc} + */ + public function import($data) + { + return $this->replace($data); + } + + /** + * {@inheritdoc} + */ + public function replace($data) + { + $this->config = new Data($data); + return $this; + } + + /** + * {@inheritdoc} + */ + public function combine($data) + { + if (!empty($data)) { + $this->config->import($data, true); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function export() + { + return $this->config->export(); + } + + /** + * {@inheritdoc} + */ + public function hasDefault($key) + { + return $this->getDefaults()->has($key); + } + + /** + * {@inheritdoc} + */ + public function getDefault($key, $defaultFallback = null) + { + return $this->hasDefault($key) ? $this->getDefaults()->get($key) : $defaultFallback; + } + + /** + * {@inheritdoc} + */ + public function setDefault($key, $value) + { + $this->getDefaults()->set($key, $value); + return $this; + } + + /** + * Return the class $defaults property and ensure it's a Data object + * TODO: remove Data object validation in 2.0 + * + * @return Data + */ + protected function getDefaults() + { + // Ensure $this->defaults is a Data object (not an array) + if (!$this->defaults instanceof Data) { + $this->setDefaults($this->defaults); + } + return $this->defaults; + } + + /** + * Sets the $defaults class parameter + * TODO: remove support for array in 2.0 as this would currently break backward compatibility + * + * @param Data|array $defaults + * + * @throws \Exception + */ + protected function setDefaults($defaults) + { + if (is_array($defaults)) { + $this->defaults = new Data($defaults); + } elseif ($defaults instanceof Data) { + $this->defaults = $defaults; + } else { + throw new \Exception("Unknown type provided for \$defaults"); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/ConfigInterface.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/ConfigInterface.php new file mode 100644 index 00000000..5124ea1f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/ConfigInterface.php @@ -0,0 +1,105 @@ + default-value + */ + public function getGlobalOptionDefaultValues(); +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForCommand.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForCommand.php new file mode 100644 index 00000000..ce2646e1 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForCommand.php @@ -0,0 +1,127 @@ +config = $config; + } + + public function setApplication(Application $application) + { + $this->application = $application; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ConsoleEvents::COMMAND => 'injectConfiguration']; + } + + /** + * Before a Console command runs, inject configuration settings + * for this command into the default value of the options of + * this command. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function injectConfiguration(ConsoleCommandEvent $event) + { + $command = $event->getCommand(); + $this->injectConfigurationForGlobalOptions($event->getInput()); + $this->injectConfigurationForCommand($command, $event->getInput()); + + $targetOfHelpCommand = $this->getHelpCommandTarget($command, $event->getInput()); + if ($targetOfHelpCommand) { + $this->injectConfigurationForCommand($targetOfHelpCommand, $event->getInput()); + } + } + + protected function injectConfigurationForGlobalOptions($input) + { + if (!$this->application) { + return; + } + + $configGroup = new ConfigFallback($this->config, 'options'); + + $definition = $this->application->getDefinition(); + $options = $definition->getOptions(); + + return $this->injectConfigGroupIntoOptions($configGroup, $options, $input); + } + + protected function injectConfigurationForCommand($command, $input) + { + $commandName = $command->getName(); + $commandName = str_replace(':', '.', $commandName); + $configGroup = new ConfigFallback($this->config, $commandName, 'command.', '.options.'); + + $definition = $command->getDefinition(); + $options = $definition->getOptions(); + + return $this->injectConfigGroupIntoOptions($configGroup, $options, $input); + } + + protected function injectConfigGroupIntoOptions($configGroup, $options, $input) + { + foreach ($options as $option => $inputOption) { + $key = str_replace('.', '-', $option); + $value = $configGroup->get($key); + if ($value !== null) { + if (is_bool($value) && ($value == true)) { + $input->setOption($key, $value); + } elseif ($inputOption->acceptValue()) { + $inputOption->setDefault($value); + } + } + } + } + + protected function getHelpCommandTarget($command, $input) + { + if (($command->getName() != 'help') || (!isset($this->application))) { + return false; + } + + $this->fixInputForSymfony2($command, $input); + + // Symfony Console helpfully swaps 'command_name' and 'command' + // depending on whether the user entered `help foo` or `--help foo`. + // One of these is always `help`, and the other is the command we + // are actually interested in. + $nameOfCommandToDescribe = $input->getArgument('command_name'); + if ($nameOfCommandToDescribe == 'help') { + $nameOfCommandToDescribe = $input->getArgument('command'); + } + return $this->application->find($nameOfCommandToDescribe); + } + + protected function fixInputForSymfony2($command, $input) + { + // Symfony 3.x prepares $input for us; Symfony 2.x, on the other + // hand, passes it in prior to binding with the command definition, + // so we have to go to a little extra work. It may be inadvisable + // to do these steps for commands other than 'help'. + if (!$input->hasArgument('command_name')) { + $command->ignoreValidationErrors(); + $command->mergeApplicationDefinition(); + $input->bind($command->getDefinition()); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForSetters.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForSetters.php new file mode 100644 index 00000000..5ec87042 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Inject/ConfigForSetters.php @@ -0,0 +1,47 @@ +config = new ConfigMerge($config, $group, $prefix, $postfix); + } + + public function apply($object, $configurationKey) + { + $settings = $this->config->get($configurationKey); + foreach ($settings as $setterMethod => $args) { + $fn = [$object, $setterMethod]; + if (is_callable($fn)) { + $result = call_user_func_array($fn, (array)$args); + + // We require that $fn must only be used with setter methods. + // Setter methods are required to always return $this so that + // they may be chained. We will therefore throw an exception + // for any setter that returns something else. + if ($result != $object) { + $methodDescription = get_class($object) . "::$setterMethod"; + $propertyDescription = $this->config->describe($configurationKey); + throw new \Exception("$methodDescription did not return '\$this' when processing $propertyDescription."); + } + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoader.php new file mode 100644 index 00000000..ecc6f64f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoader.php @@ -0,0 +1,35 @@ +source; + } + + protected function setSourceName($source) + { + $this->source = $source; + return $this; + } + + public function export() + { + return $this->config; + } + + public function keys() + { + return array_keys($this->config); + } + + abstract public function load($path); +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoaderInterface.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoaderInterface.php new file mode 100644 index 00000000..9b155c1b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/ConfigLoaderInterface.php @@ -0,0 +1,29 @@ +expander = $expander ?: new Expander(); + } + + /** + * Extend the configuration to be processed with the + * configuration provided by the specified loader. + * + * @param ConfigLoaderInterface $loader + */ + public function extend(ConfigLoaderInterface $loader) + { + return $this->addFromSource($loader->export(), $loader->getSourceName()); + } + + /** + * Extend the configuration to be processed with + * the provided nested array. + * + * @param array $data + */ + public function add($data) + { + $this->unprocessedConfig[] = $data; + return $this; + } + + /** + * Extend the configuration to be processed with + * the provided nested array. Also record the name + * of the data source, if applicable. + * + * @param array $data + * @param string $source + */ + protected function addFromSource($data, $source = '') + { + if (empty($source)) { + return $this->add($data); + } + $this->unprocessedConfig[$source] = $data; + return $this; + } + + /** + * Process all of the configuration that has been collected, + * and return a nested array. + * + * @return array + */ + public function export($referenceArray = []) + { + if (!empty($this->unprocessedConfig)) { + $this->processedConfig = $this->process( + $this->processedConfig, + $this->fetchUnprocessed(), + $referenceArray + ); + } + return $this->processedConfig; + } + + /** + * To aid in debugging: return the source of each configuration item. + * n.b. Must call this function *before* export and save the result + * if persistence is desired. + */ + public function sources() + { + $sources = []; + foreach ($this->unprocessedConfig as $sourceName => $config) { + if (!empty($sourceName)) { + $configSources = ArrayUtil::fillRecursive($config, $sourceName); + $sources = ArrayUtil::mergeRecursiveDistinct($sources, $configSources); + } + } + return $sources; + } + + /** + * Get the configuration to be processed, and clear out the + * 'unprocessed' list. + * + * @return array + */ + protected function fetchUnprocessed() + { + $toBeProcessed = $this->unprocessedConfig; + $this->unprocessedConfig = []; + return $toBeProcessed; + } + + /** + * Use a map-reduce to evaluate the items to be processed, + * and merge them into the processed array. + * + * @param array $processed + * @param array $toBeProcessed + * @return array + */ + protected function process(array $processed, array $toBeProcessed, $referenceArray = []) + { + $toBeReduced = array_map([$this, 'preprocess'], $toBeProcessed); + $reduced = array_reduce($toBeReduced, [$this, 'reduceOne'], $processed); + return $this->evaluate($reduced, $referenceArray); + } + + /** + * Process a single configuration file from the 'to be processed' + * list. By default this is a no-op. Override this method to + * provide any desired configuration preprocessing, e.g. dot-notation + * expansion of the configuration keys, etc. + * + * @param array $config + * @return array + */ + protected function preprocess(array $config) + { + return $config; + } + + /** + * Evaluate one item in the 'to be evaluated' list, and then + * merge it into the processed configuration (the 'carry'). + * + * @param array $processed + * @param array $config + * @return array + */ + protected function reduceOne(array $processed, array $config) + { + return ArrayUtil::mergeRecursiveDistinct($processed, $config); + } + + /** + * Evaluate one configuration item. + * + * @param array $processed + * @param array $config + * @return array + */ + protected function evaluate(array $config, $referenceArray = []) + { + return $this->expander->expandArrayProperties( + $config, + $referenceArray + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/YamlConfigLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/YamlConfigLoader.php new file mode 100644 index 00000000..45705662 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Loader/YamlConfigLoader.php @@ -0,0 +1,26 @@ +setSourceName($path); + + // We silently skip any nonexistent config files, so that + // clients may simply `load` all of their candidates. + if (!file_exists($path)) { + $this->config = []; + return $this; + } + $this->config = (array) Yaml::parse(file_get_contents($path)); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ArrayUtil.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ArrayUtil.php new file mode 100644 index 00000000..a23f854e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ArrayUtil.php @@ -0,0 +1,75 @@ + &$value) { + $merged[$key] = self::mergeRecursiveValue($merged, $key, $value); + } + return $merged; + } + + /** + * Process the value in an mergeRecursiveDistinct - make a recursive + * call if needed. + */ + protected static function mergeRecursiveValue(&$merged, $key, $value) + { + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { + return self::mergeRecursiveDistinct($merged[$key], $value); + } + return $value; + } + + /** + * Fills all of the leaf-node values of a nested array with the + * provided replacement value. + */ + public static function fillRecursive(array $data, $fill) + { + $result = []; + foreach ($data as $key => $value) { + $result[$key] = $fill; + if (self::isAssociative($value)) { + $result[$key] = self::fillRecursive($value, $fill); + } + } + return $result; + } + + /** + * Return true if the provided parameter is an array, and at least + * one key is non-numeric. + */ + public static function isAssociative($testArray) + { + if (!is_array($testArray)) { + return false; + } + foreach (array_keys($testArray) as $key) { + if (!is_numeric($key)) { + return true; + } + } + return false; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigFallback.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigFallback.php new file mode 100644 index 00000000..9f9972f6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigFallback.php @@ -0,0 +1,51 @@ +getWithFallback($key, $this->group, $this->prefix, $this->postfix); + } + + /** + * Fetch an option value from a given key, or, if that specific key does + * not contain a value, then consult various fallback options until a + * value is found. + * + */ + protected function getWithFallback($key, $group, $prefix = '', $postfix = '.') + { + $configKey = "{$prefix}{$group}${postfix}{$key}"; + if ($this->config->has($configKey)) { + return $this->config->get($configKey); + } + if ($this->config->hasDefault($configKey)) { + return $this->config->getDefault($configKey); + } + $moreGeneralGroupname = $this->moreGeneralGroupName($group); + if ($moreGeneralGroupname) { + return $this->getWithFallback($key, $moreGeneralGroupname, $prefix, $postfix); + } + return null; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigGroup.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigGroup.php new file mode 100644 index 00000000..24b29dd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigGroup.php @@ -0,0 +1,61 @@ +config = $config; + $this->group = $group; + $this->prefix = $prefix; + $this->postfix = $postfix; + } + + /** + * Return a description of the configuration group (with prefix and postfix). + */ + public function describe($property) + { + return $this->prefix . $this->group . $this->postfix . $property; + } + + /** + * Get the requested configuration key from the most specific configuration + * group that contains it. + */ + abstract public function get($key); + + /** + * Given a group name, such as "foo.bar.baz", return the next configuration + * group in the fallback hierarchy, e.g. "foo.bar". + */ + protected function moreGeneralGroupName($group) + { + $result = preg_replace('#\.[^.]*$#', '', $group); + if ($result != $group) { + return $result; + } + return false; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigMerge.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigMerge.php new file mode 100644 index 00000000..65fccf72 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigMerge.php @@ -0,0 +1,34 @@ +getWithMerge($key, $this->group, $this->prefix, $this->postfix); + } + + /** + * Merge available configuration from each configuration group. + */ + public function getWithMerge($key, $group, $prefix = '', $postfix = '.') + { + $configKey = "{$prefix}{$group}${postfix}{$key}"; + $result = $this->config->get($configKey, []); + if (!is_array($result)) { + throw new \UnexpectedValueException($configKey . ' must be a list of settings to apply.'); + } + $moreGeneralGroupname = $this->moreGeneralGroupName($group); + if ($moreGeneralGroupname) { + $result += $this->getWithMerge($key, $moreGeneralGroupname, $prefix, $postfix); + } + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigOverlay.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigOverlay.php new file mode 100644 index 00000000..d1f12697 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/ConfigOverlay.php @@ -0,0 +1,203 @@ +contexts[self::DEFAULT_CONTEXT] = new Config(); + $this->contexts[self::PROCESS_CONTEXT] = new Config(); + } + + /** + * Add a named configuration object to the configuration overlay. + * Configuration objects added LAST have HIGHEST priority, with the + * exception of the fact that the process context always has the + * highest priority. + * + * If a context has already been added, its priority will not change. + */ + public function addContext($name, ConfigInterface $config) + { + $process = $this->contexts[self::PROCESS_CONTEXT]; + unset($this->contexts[self::PROCESS_CONTEXT]); + $this->contexts[$name] = $config; + $this->contexts[self::PROCESS_CONTEXT] = $process; + + return $this; + } + + /** + * Add a placeholder context that will be prioritized higher than + * existing contexts. This is done to ensure that contexts added + * later will maintain a higher priority if the placeholder context + * is later relaced with a different configuration set via addContext(). + * + * @param string $name + * @return $this + */ + public function addPlaceholder($name) + { + return $this->addContext($name, new Config()); + } + + /** + * Increase the priority of the named context such that it is higher + * in priority than any existing context except for the 'process' + * context. + * + * @param string $name + * @return $this + */ + public function increasePriority($name) + { + $config = $this->getContext($name); + unset($this->contexts[$name]); + return $this->addContext($name, $config); + } + + public function hasContext($name) + { + return isset($this->contexts[$name]); + } + + public function getContext($name) + { + if ($this->hasContext($name)) { + return $this->contexts[$name]; + } + return new Config(); + } + + public function removeContext($name) + { + unset($this->contexts[$name]); + } + + /** + * Determine if a non-default config value exists. + */ + public function findContext($key) + { + foreach (array_reverse($this->contexts) as $name => $config) { + if ($config->has($key)) { + return $config; + } + } + return false; + } + + /** + * @inheritdoc + */ + public function has($key) + { + return $this->findContext($key) != false; + } + + /** + * @inheritdoc + */ + public function get($key, $default = null) + { + $context = $this->findContext($key); + if ($context) { + return $context->get($key, $default); + } + return $default; + } + + /** + * @inheritdoc + */ + public function set($key, $value) + { + $this->contexts[self::PROCESS_CONTEXT]->set($key, $value); + return $this; + } + + /** + * @inheritdoc + */ + public function import($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + public function replace($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + public function combine($data) + { + $this->unsupported(__FUNCTION__); + } + + /** + * @inheritdoc + */ + protected function unsupported($fn) + { + throw new \Exception("The method '$fn' is not supported for the ConfigOverlay class."); + } + + /** + * @inheritdoc + */ + public function export() + { + $export = []; + foreach ($this->contexts as $name => $config) { + $export = array_merge_recursive($export, $config->export()); + } + return $export; + } + + /** + * @inheritdoc + */ + public function hasDefault($key) + { + return $this->contexts[self::DEFAULT_CONTEXT]->has($key); + } + + /** + * @inheritdoc + */ + public function getDefault($key, $default = null) + { + return $this->contexts[self::DEFAULT_CONTEXT]->get($key, $default); + } + + /** + * @inheritdoc + */ + public function setDefault($key, $value) + { + $this->contexts[self::DEFAULT_CONTEXT]->set($key, $value); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/EnvConfig.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/EnvConfig.php new file mode 100644 index 00000000..05f8d2a8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/src/Util/EnvConfig.php @@ -0,0 +1,96 @@ +prefix = strtoupper(rtrim($prefix, '_')) . '_'; + } + + /** + * @inheritdoc + */ + public function has($key) + { + return $this->get($key) !== null; + } + + /** + * @inheritdoc + */ + public function get($key, $defaultFallback = null) + { + $envKey = $this->prefix . strtoupper(strtr($key, '.-', '__')); + $envKey = str_replace($this->prefix . $this->prefix, $this->prefix, $envKey); + return getenv($envKey) ?: $defaultFallback; + } + + /** + * @inheritdoc + */ + public function set($key, $value) + { + throw new \Exception('Cannot call "set" on environmental configuration.'); + } + + /** + * @inheritdoc + */ + public function import($data) + { + // no-op + } + + /** + * @inheritdoc + */ + public function export() + { + return []; + } + + /** + * @inheritdoc + */ + public function hasDefault($key) + { + return false; + } + + /** + * @inheritdoc + */ + public function getDefault($key, $defaultFallback = null) + { + return $defaultFallback; + } + + /** + * @inheritdoc + */ + public function setDefault($key, $value) + { + throw new \Exception('Cannot call "setDefault" on environmental configuration.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests deleted file mode 120000 index c2ebfe53..00000000 --- a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests \ No newline at end of file diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForCommandTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForCommandTest.php new file mode 100644 index 00000000..41da3076 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForCommandTest.php @@ -0,0 +1,130 @@ + [ + 'global' => 'from-config', + ], + // Define some configuration settings for the options for + // the commands my:foo and my:bar. + 'command' => [ + 'my' => [ + // commands.my.options.* apply to all my:* commands. + 'options' => [ + 'dir' => '/etc/common', + 'priority' => 'normal', + ], + 'foo' => [ + // commands.my.foo.options.* apply only to the my:foo command. + 'options' => [ + 'name' => 'baz', + ], + ], + ], + ], + ]; + + $this->config = new Config($data); + } + + public function testInjection() + { + $command = new MyFooCommand(); + $input = new StringInput('my:foo'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +Enter my:foo +dir: /etc/common +name: baz +other: fish +EOT; + + $this->assertEquals(0, $status); + $this->assertEquals($expectedOutput, $output); + } + + public function testInjectionWithOverride() + { + $command = new MyFooCommand(); + $input = new StringInput('my:foo --name=Fred'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +Enter my:foo +dir: /etc/common +name: Fred +other: fish +EOT; + + $this->assertEquals(0, $status); + $this->assertEquals($expectedOutput, $output); + } + + public function testHelpDefaultInjection() + { + $command = new MyFooCommand(); + $input = new StringInput('help my:foo'); + + list($status, $output) = $this->runCommandViaApplication($command, $input); + + $expectedOutput = <<< EOT +What is the name of the thing we are naming [default: "baz"] +EOT; + + $this->assertEquals(0, $status); + $this->assertContains($expectedOutput, $output); + + $expectedOutput = <<< EOT +A certain global option. [default: "from-config"] +EOT; + + $this->assertContains($expectedOutput, $output); + } + + protected function runCommandViaApplication($command, $input) + { + $application = new Application('TestApplication', '0.0.0'); + $application->getDefinition() + ->addOption( + new InputOption('--global', null, InputOption::VALUE_REQUIRED, 'A certain global option.', 'hardcoded') + ); + + $output = new BufferedOutput(); + + $configInjector = new ConfigForCommand($this->config); + $configInjector->setApplication($application); + + $eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); + $eventDispatcher->addSubscriber($configInjector); + $application->setDispatcher($eventDispatcher); + + $application->setAutoExit(false); + $application->add($command); + + $statusCode = $application->run($input, $output); + $commandOutput = trim($output->fetch()); + + return [$statusCode, $commandOutput]; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForSettersTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForSettersTest.php new file mode 100644 index 00000000..422b0a00 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigForSettersTest.php @@ -0,0 +1,87 @@ + [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'dir' => '/override/dir', + ], + ], + ], + ], + ]; + $config = new Config($data); + + $applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.'); + + $testTarget = new ApplyConfigTestTarget(); + + $applicator->apply($testTarget, 'settings'); + + $this->assertEquals('/override/dir', $testTarget->getDir()); + $this->assertEquals(null, $testTarget->getBad()); + } + + public function testApplyBadConfig() + { + $data = [ + // Define some configuration settings for the configuration + // of some task \My\Tasks\Operations\Frobulate. + 'task' => [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'bad' => 'fire truck', + ], + ], + ], + ], + ]; + $config = new Config($data); + + $applicator = new ConfigForSetters($config, 'Operations.Frobulate', 'task.'); + + $testTarget = new ApplyConfigTestTarget(); + + $exceptionMessage = ''; + try + { + $applicator->apply($testTarget, 'settings'); + } + catch (\Exception $e) + { + $exceptionMessage = $e->getMessage(); + } + // We would prefer it if bad methods were never called; unfortunately, + // declaring the return type of a method cannot be done in a reliable + // way (via reflection) until php 7, so we allow these methods to be + // called for now. + $this->assertEquals('fire truck', $testTarget->getBad()); + $this->assertEquals('Consolidation\\TestUtils\\ApplyConfigTestTarget::bad did not return \'$this\' when processing task.Operations.Frobulate.settings.', $exceptionMessage); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigGroupTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigGroupTest.php new file mode 100644 index 00000000..21e470e5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigGroupTest.php @@ -0,0 +1,91 @@ + [ + 'my' => [ + // commands.my.options.* apply to all my:* commands. + 'options' => [ + 'path' => '/etc/common', + 'priority' => 'normal', + ], + 'foo' => [ + // commands.my.foo.options.* apply only to the my:foo command. + 'options' => [ + 'name' => 'baz', + ], + ], + 'bar' => [ + // Similarly, commands.my.bar.options is for the my:bar command. + 'options' => [ + 'priority' => 'high', + ], + ], + ], + ], + // Define some configuration settings for the configuration + // of some task \My\Tasks\Operations\Frobulate. + 'task' => [ + 'Operations' => [ + // task.Operations.settings apply to all tasks in + // any *.Tass.Operations namespace. + 'settings' => [ + 'dir' => '/base/dir', + ], + 'Frobulate' => [ + // task.Operations.Frobulate.settings applies only + // the Frobulate task. + 'settings' => [ + 'object' => 'fire truck', + ], + ], + ], + ], + ]; + + $this->config = new Config($data); + } + + public function testDotNotation() + { + // Test the test + $this->assertEquals('baz', $this->config->get('command.my.foo.options.name')); + } + + public function testFallback() + { + $fooFallback = new ConfigFallback($this->config, 'my.foo', 'command.', '.options.'); + $barFallback = new ConfigFallback($this->config, 'my.bar', 'command.', '.options.'); + + $this->assertEquals(null, $barFallback->get('name')); + $this->assertEquals('baz', $fooFallback->get('name')); + $this->assertEquals('high', $barFallback->get('priority')); + + $this->assertEquals('normal', $fooFallback->get('priority')); + $this->assertEquals('/etc/common', $barFallback->get('path')); + $this->assertEquals('/etc/common', $fooFallback->get('path')); + } + + public function testMerge() + { + $frobulateMerge = new ConfigMerge($this->config, 'Operations.Frobulate', 'task.'); + + $settings = $frobulateMerge->get('settings'); + $this->assertEquals('fire truck', $settings['object']); + $this->assertEquals('/base/dir', $settings['dir']); + $keys = array_keys($settings); + sort($keys); + $this->assertEquals('dir,object', implode(',', $keys)); + } +} + diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigLoaderTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigLoaderTest.php new file mode 100644 index 00000000..6dedb1f3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigLoaderTest.php @@ -0,0 +1,29 @@ +assertTrue(file_exists($path)); + + $loader->load($path); + + $configFile = basename($loader->getSourceName()); + $this->assertEquals('config-1.yml', $configFile); + + // Make sure that the data we loaded contained the expected keys + $keys = $loader->keys(); + sort($keys); + $keysString = implode(',', $keys); + $this->assertEquals('c,m', $keysString); + + $configData = $loader->export(); + $this->assertEquals('foo', $configData['c']); + $this->assertEquals('1', $configData['m'][0]); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigOverlayTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigOverlayTest.php new file mode 100644 index 00000000..f7faf748 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigOverlayTest.php @@ -0,0 +1,168 @@ +import([ + 'hidden-by-a' => 'alias hidden-by-a', + 'hidden-by-process' => 'alias hidden-by-process', + 'options' =>[ + 'a-a' => 'alias-a', + ], + 'command' => [ + 'foo' => [ + 'bar' => [ + 'command' => [ + 'options' => [ + 'a-b' => 'alias-b', + ], + ], + ], + ], + ], + ]); + + $configFileContext = new Config(); + $configFileContext->import([ + 'hidden-by-cf' => 'config-file hidden-by-cf', + 'hidden-by-a' => 'config-file hidden-by-a', + 'hidden-by-process' => 'config-file hidden-by-process', + 'options' =>[ + 'cf-a' => 'config-file-a', + ], + 'command' => [ + 'foo' => [ + 'bar' => [ + 'command' => [ + 'options' => [ + 'cf-b' => 'config-file-b', + ], + ], + ], + ], + ], + ]); + + $this->overlay = new ConfigOverlay(); + $this->overlay->set('hidden-by-process', 'process-h'); + $this->overlay->addContext('cf', $configFileContext); + $this->overlay->addContext('a', $aliasContext); + $this->overlay->setDefault('df-a', 'default'); + $this->overlay->setDefault('hidden-by-a', 'default hidden-by-a'); + $this->overlay->setDefault('hidden-by-cf', 'default hidden-by-cf'); + $this->overlay->setDefault('hidden-by-process', 'default hidden-by-process'); + } + + public function testGetPriority() + { + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + $this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testDefault() + { + $this->assertEquals('alias-a', $this->overlay->get('options.a-a')); + $this->assertEquals('alias-a', $this->overlay->get('options.a-a', 'ignored')); + $this->assertEquals('default', $this->overlay->getDefault('df-a', 'ignored')); + $this->assertEquals('nsv', $this->overlay->getDefault('a-a', 'nsv')); + + $this->overlay->setDefault('df-a', 'new value'); + $this->assertEquals('new value', $this->overlay->getDefault('df-a', 'ignored')); + } + + public function testExport() + { + $data = $this->overlay->export(); + + $this->assertEquals('config-file-a', $data['options']['cf-a']); + $this->assertEquals('alias-a', $data['options']['a-a']); + } + + /** + * @expectedException Exception + */ + public function testImport() + { + $data = $this->overlay->import(['a' => 'value']); + } + + public function testMaintainPriority() + { + // Get and re-add the 'cf' context. Its priority should not change. + $configFileContext = $this->overlay->getContext('cf'); + $this->overlay->addContext('cf', $configFileContext); + + // These asserts are the same as in testGetPriority + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + $this->assertEquals('alias hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testChangePriority() + { + // Increase the priority of the 'cf' context. Now, it should have a higher + // priority than the 'alias' context, but should still have a lower + // priority than the 'process' context. + $this->overlay->increasePriority('cf'); + + // These asserts are the same as in testGetPriority + $this->assertEquals('process-h', $this->overlay->get('hidden-by-process')); + $this->assertEquals('config-file hidden-by-cf', $this->overlay->get('hidden-by-cf')); + + // This one has changed: the config-file value is now found instead + // of the alias value. + $this->assertEquals('config-file hidden-by-a', $this->overlay->get('hidden-by-a')); + } + + public function testPlaceholder() + { + $this->overlay->addPlaceholder('lower'); + + $higherContext = new Config(); + $higherContext->import(['priority-test' => 'higher']); + + $lowerContext = new Config(); + $lowerContext->import(['priority-test' => 'lower']); + + // Usually 'lower' would have the highest priority, since it is + // added last. However, our earlier call to 'addPlaceholder' reserves + // a spot for it, so the 'higher' context will end up with a higher + // priority. + $this->overlay->addContext('higher', $higherContext); + $this->overlay->addContext('lower', $lowerContext); + $this->assertEquals('higher', $this->overlay->get('priority-test', 'neither')); + + // Test to see that we can change the value of the 'higher' context, + // and the change will be reflected in the overlay. + $higherContext->set('priority-test', 'changed'); + $this->assertEquals('changed', $this->overlay->get('priority-test', 'neither')); + + // Test to see that the 'process' context still has the highest priority. + $this->overlay->set('priority-test', 'process'); + $higherContext->set('priority-test', 'ignored'); + $this->assertEquals('process', $this->overlay->get('priority-test', 'neither')); + } + + public function testDoesNotHave() + { + $context = $this->overlay->getContext('no-such-context'); + $data = $context->export(); + $this->assertEquals('[]', json_encode($data)); + + $this->assertTrue(!$this->overlay->has('no-such-key')); + $this->assertTrue(!$this->overlay->hasDefault('no-such-default')); + + $this->assertEquals('no-such-value', $this->overlay->get('no-such-key', 'no-such-value')); + + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigProcessorTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigProcessorTest.php new file mode 100644 index 00000000..ac645a28 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigProcessorTest.php @@ -0,0 +1,152 @@ + 'foo', + 'm' => [1], + ]; + $config2 = [ + 'b' => '${c}bar', + 'm' => [2], + ]; + $config3 = [ + 'a' => '${b}baz', + 'm' => [3], + ]; + + $processor = new ConfigProcessor(); + $processor->add($config1); + $processor->add($config2); + $processor->add($config3); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + } + + public function processorForConfigMergeTest($provideSourceNames) + { + $config1 = [ + 'm' => [ + 'x' => 'x-1', + 'y' => [ + 'r' => 'r-1', + 's' => 's-1', + 't' => 't-1', + ], + 'z' => 'z-1', + ], + ]; + $config2 = [ + 'm' => [ + 'w' => 'w-2', + 'y' => [ + 'q' => 'q-2', + 's' => 's-2', + ], + 'z' => 'z-2', + ], + ]; + $config3 = [ + 'm' => [ + 'v' => 'v-3', + 'y' => [ + 't' => 't-3', + 'u' => 'u-3', + ], + 'z' => 'z-3', + ], + ]; + + $processor = new ConfigProcessor(); + $testLoader = new TestLoader(); + + $testLoader->set($config1); + $testLoader->setSourceName($provideSourceNames ? 'c-1' : ''); + $processor->extend($testLoader); + + $testLoader->set($config2); + $testLoader->setSourceName($provideSourceNames ? 'c-2' : ''); + $processor->extend($testLoader); + + $testLoader->set($config3); + $testLoader->setSourceName($provideSourceNames ? 'c-3' : ''); + $processor->extend($testLoader); + + return $processor; + } + + public function testConfigProcessorMergeAssociative() + { + $processor = $this->processorForConfigMergeTest(false); + $data = $processor->export(); + $this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data)); + } + + public function testConfigProcessorMergeAssociativeWithSourceNames() + { + $processor = $this->processorForConfigMergeTest(true); + $sources = $processor->sources(); + $data = $processor->export(); + $this->assertEquals('{"m":{"x":"x-1","y":{"r":"r-1","s":"s-2","t":"t-3","q":"q-2","u":"u-3"},"z":"z-3","w":"w-2","v":"v-3"}}', json_encode($data)); + $this->assertEquals('c-1', $sources['m']['x']); + $this->assertEquals('c-1', $sources['m']['y']['r']); + $this->assertEquals('c-2', $sources['m']['w']); + $this->assertEquals('c-2', $sources['m']['y']['s']); + $this->assertEquals('c-3', $sources['m']['z']); + $this->assertEquals('c-3', $sources['m']['y']['u']); + } + + public function testConfiProcessorSources() + { + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + + $sources = $processor->sources(); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + + $this->assertEquals('3', $data['m'][0]); + + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']); + $this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']); + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['m']); + } + + public function testConfiProcessorSourcesLoadInReverseOrder() + { + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + + $sources = $processor->sources(); + + $data = $processor->export(); + $this->assertEquals('foo', $data['c']); + $this->assertEquals('foobar', $data['b']); + $this->assertEquals('foobarbaz', $data['a']); + + $this->assertEquals('1', $data['m'][0]); + + $this->assertEquals( __DIR__ . '/data/config-3.yml', $sources['a']); + $this->assertEquals( __DIR__ . '/data/config-2.yml', $sources['b']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['c']); + $this->assertEquals( __DIR__ . '/data/config-1.yml', $sources['m']); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigTest.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigTest.php new file mode 100644 index 00000000..f2ace0ce --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/ConfigTest.php @@ -0,0 +1,140 @@ +set('foo', 'bar'); + $data = $config->export(); + $this->assertEquals('{"foo":"bar"}', json_encode($data)); + } + + public function testCombine() + { + // Pointless tests just to ensure everything is covered. + $config = new Config(); + $config->set('foo', 'bar'); + $config->set('baz', 'boz'); + $config2 = new Config(); + $config2->set('foo', 'fu'); + $config2->set('new', 'blue'); + $config->combine($config2->export()); + $this->assertEquals('fu', $config->get('foo')); + $this->assertEquals('boz', $config->get('baz')); + $this->assertEquals('blue', $config->get('new')); + } + + public function testDefault() + { + $data = [ + 'a' => 'foo', + 'b' => 'bar', + 'c' => 'boz', + ]; + + $foo = ["foo" => "bar"]; + + $config = new Config($data); + + $config->setDefault('c', 'other'); + $config->setDefault('d', 'other'); + $config->setDefault('f', $foo); + + $this->assertEquals('foo', $config->get('a')); + $this->assertEquals('boz', $config->get('c')); + $this->assertEquals('other', $config->get('d')); + $this->assertEquals('other', $config->getDefault('c')); + $this->assertEquals('', $config->get('e')); + $this->assertEquals('bar', $config->get('f.foo')); + $this->assertEquals('{"foo":"bar"}', json_encode($config->get('f'))); + } + + public function testDefaultsArray() + { + $data = ['a' => 'foo', 'b' => 'bar', 'c' => 'boz',]; + $defaults = ['d' => 'foo', 'e' => 'bar', 'f' => 'boz',]; + + // Create reflection class to test private methods + $configClass = new \ReflectionClass("Consolidation\Config\Config"); + + // $defaults + $defaultsProperty = $configClass->getProperty("defaults"); + $defaultsProperty->setAccessible(true); + + // $getDefaults + $getDefaultsMethod = $configClass->getMethod("getDefaults"); + $getDefaultsMethod->setAccessible(true); + + // Test the config class + $config = new Config($data); + + // Set $config::defaults to an array to test getter and setter + $defaultsProperty->setValue($config, $defaults); + $this->assertTrue(is_array($defaultsProperty->getValue($config))); + $this->assertInstanceOf('Dflydev\DotAccessData\Data', + $getDefaultsMethod->invoke($config)); + + // Set $config::defaults to a string to test exception + $defaultsProperty->setValue($config, "foo.bar"); + $this->setExpectedException("Exception"); + $getDefaultsMethod->invoke($config); + } + + public function testConfigurationWithCrossFileReferences() + { + $config = new Config(); + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + + // Does not fail if configuration file cannot be found + $processor->extend($loader->load(__DIR__ . '/data/no-such-file.yml')); + + // We must capture the sources before exporting, as export + // dumps this information. + $sources = $processor->sources(); + + $config->import($processor->export()); + + $this->assertEquals(implode(',', $config->get('m')), '3'); + $this->assertEquals($config->get('a'), 'foobarbaz'); + + $this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml'); + $this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml'); + $this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml'); + } + + public function testConfigurationWithReverseOrderCrossFileReferences() + { + $config = new Config(); + $processor = new ConfigProcessor(); + $loader = new YamlConfigLoader(); + $processor->extend($loader->load(__DIR__ . '/data/config-3.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-2.yml')); + $processor->extend($loader->load(__DIR__ . '/data/config-1.yml')); + + $sources = $processor->sources(); + $config->import($processor->export()); + + $this->assertEquals(implode(',', $config->get('m')), '1'); + + if (strpos($config->get('a'), '$') !== false) { + throw new \PHPUnit_Framework_SkippedTestError( + 'Evaluation of cross-file references in reverse order not supported.' + ); + } + $this->assertEquals($config->get('a'), 'foobarbaz'); + + $this->assertEquals($sources['a'], __DIR__ . '/data/config-3.yml'); + $this->assertEquals($sources['b'], __DIR__ . '/data/config-2.yml'); + $this->assertEquals($sources['c'], __DIR__ . '/data/config-1.yml'); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-1.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-1.yml new file mode 100644 index 00000000..e8f55a9d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-1.yml @@ -0,0 +1,3 @@ +c: foo +m: + - 1 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-2.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-2.yml new file mode 100644 index 00000000..baa7e63f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-2.yml @@ -0,0 +1,3 @@ +b: ${c}bar +m: + - 2 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-3.yml b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-3.yml new file mode 100644 index 00000000..d5895642 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/data/config-3.yml @@ -0,0 +1,3 @@ +a: ${b}baz +m: + - 3 diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/install-scenario b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/install-scenario new file mode 100755 index 00000000..d77d57d0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/install-scenario @@ -0,0 +1,23 @@ +#!/bin/bash + +SCENARIO=$1 +ACTION=${2-install} + +dir=dependencies/${SCENARIO} +if [ -z "$SCENARIO" ] ; then + SCENARIO=default + dir=. +fi + + +if [ ! -d "$dir" ] ; then + echo "Requested scenario '${SCENARIO}' does not exist." + exit 1 +fi + +echo "Switch to ${SCENARIO} scenario" + +set -ex + +composer -n --working-dir=$dir ${ACTION} --prefer-dist --no-scripts +composer -n --working-dir=$dir info diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/prep-dependencies b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/prep-dependencies new file mode 100755 index 00000000..d1898440 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/prep-dependencies @@ -0,0 +1,66 @@ +#!/bin/bash + +# +# This script is called automatically on every `composer update`. +# See "post-update-cmd" in the "scripts" section of composer.json. +# +# This script will create a derived composer.json / composer.lock +# pair for every test scenario. Test scenarios are defined in the +# "scenarios" file, which should be customized to suit the needs +# of the project. +# + +SELF_DIRNAME="`dirname -- "$0"`" +source ${SELF_DIRNAME}/scenarios + +echo +echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" +echo "::" +echo ":: Update dependencies for the following scenarios:" +echo "::" +echo ":: ${SCENARIOS}" +echo "::" +echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" +echo + +set -ex + +for SCENARIO in ${SCENARIOS} ; do + + dir=dependencies/${SCENARIO} + + # Define indirect variable names + stability_variable="stability_${SCENARIO}" + requirement_variable="requirement_${SCENARIO}" + platform_php_variable="platform_php_${SCENARIO}" + + echo "### Create $dir/composer.json for ${SCENARIO} scenario" + mkdir -p $dir + cp composer.json $dir + + # Then set our own platform php version if applicable (otherwise unset it) + composer -n --working-dir=$dir config platform.php "${!platform_php_variable---unset}" + + # Temporarily set our vendor directory to 'vendor' + composer -n --working-dir=$dir config vendor-dir vendor + + # Set an appropriate minimum stability for this version of Symfony + composer -n --working-dir=$dir config minimum-stability "${!stability_variable-stable}" + + # Add a constraint to limit the Symfony version + composer -n --working-dir=$dir require --dev --no-update "${!requirement_variable}" + + # Create the composer.lock file. Ignore the vendor directory created. + composer -n --working-dir=$dir update --no-scripts + + # Set the vendor directory to its final desired location. + composer -n --working-dir=$dir config vendor-dir '../../vendor' + + # The 'autoload' section specifies directory paths that are relative + # to the composer.json file. We will drop in some symlinks so that + # these paths will resolve as if the composer.json were in the root. + for target in $AUTOLOAD_DIRECTORIES ; do + ln -s -f ../../$target $dir + done + +done diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/scenarios b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/scenarios new file mode 100755 index 00000000..6a8f81b2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/scripts/scenarios @@ -0,0 +1,12 @@ +#!/bin/bash + +SCENARIOS="symfony2 symfony3 symfony4" + +AUTOLOAD_DIRECTORIES='src tests' + +platform_php_symfony2='5.4' +platform_php_symfony3='5.6' + +requirement_symfony2='symfony/console:^2.8' +requirement_symfony3='symfony/console:^3' +requirement_symfony4='symfony/console:^4' diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/ApplyConfigTestTarget.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/ApplyConfigTestTarget.php new file mode 100644 index 00000000..6dace2be --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/ApplyConfigTestTarget.php @@ -0,0 +1,43 @@ +dir = $dir; + return $this; + } + + /** + * A getter for the 'dir' property that we will use to + * determine if the setter was called. + */ + public function getDir() + { + return $this->dir; + } + + /** + * A bad setter that does not return $this. + */ + public function bad($value) + { + $this->value = $value; + } + + /** + * A getter for the bad setter. + */ + public function getBad() + { + return $this->value; + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/MyFooCommand.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/MyFooCommand.php new file mode 100644 index 00000000..0487a024 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/MyFooCommand.php @@ -0,0 +1,47 @@ +setName('my:foo') + ->setDescription('My foo command.') + ->setHelp('This command tests command option injection by echoing its options') + ->addOption( + 'other', + null, + InputOption::VALUE_REQUIRED, + 'Some other option', + 'fish' + ) + ->addOption( + 'name', + null, + InputOption::VALUE_REQUIRED, + 'What is the name of the thing we are naming', + 'George' + ) + ->addOption( + 'dir', + null, + InputOption::VALUE_REQUIRED, + 'What is the base directory to use for this command', + '/default/path' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Enter my:foo'); + $output->writeln('dir: ' . $input->getOption('dir')); + $output->writeln('name: ' . $input->getOption('name')); + $output->writeln('other: ' . $input->getOption('other')); + } +} diff --git a/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/TestLoader.php b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/TestLoader.php new file mode 100644 index 00000000..241e5120 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/config/scenarios/symfony4/tests/src/TestLoader.php @@ -0,0 +1,36 @@ +data = $data; + } + + public function setSourceName($name) + { + $this->sourceName = $name; + } + + public function export() + { + return $this->data; + } + + public function keys() + { + return array_keys($this->data); + } + + public function getSourceName() + { + return $this->sourceName; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src deleted file mode 120000 index 929cb3dc..00000000 --- a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src +++ /dev/null @@ -1 +0,0 @@ -../../src \ No newline at end of file diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Application.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Application.php new file mode 100644 index 00000000..19d4725f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Application.php @@ -0,0 +1,73 @@ +getDefinition() + ->addOption( + new InputOption('--simulate', null, InputOption::VALUE_NONE, 'Run in simulated mode (show what would have happened).') + ); + $this->getDefinition() + ->addOption( + new InputOption('--progress-delay', null, InputOption::VALUE_REQUIRED, 'Number of seconds before progress bar is displayed in long-running task collections. Default: 2s.', Config::DEFAULT_PROGRESS_DELAY) + ); + + $this->getDefinition() + ->addOption( + new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', []) + ); + } + + /** + * @param string $roboFile + * @param string $roboClass + */ + public function addInitRoboFileCommand($roboFile, $roboClass) + { + $createRoboFile = new Command('init'); + $createRoboFile->setDescription("Intitalizes basic RoboFile in current dir"); + $createRoboFile->setCode(function () use ($roboClass, $roboFile) { + $output = Robo::output(); + $output->writeln(" ~~~ Welcome to Robo! ~~~~ "); + $output->writeln(" ". basename($roboFile) ." will be created in the current directory "); + file_put_contents( + $roboFile, + 'writeln(" Edit this file to add your commands! "); + }); + $this->add($createRoboFile); + } + + /** + * Add self update command, do nothing if null is provided + * + * @param string $repository GitHub Repository for self update + */ + public function addSelfUpdateCommand($repository = null) + { + if (!$repository) { + return; + } + $selfUpdateCommand = new SelfUpdateCommand($this->getName(), $this->getVersion(), $repository); + $this->add($selfUpdateCommand); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CallableTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CallableTask.php new file mode 100644 index 00000000..ae9c54fc --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CallableTask.php @@ -0,0 +1,62 @@ +fn = $fn; + $this->reference = $reference; + } + + /** + * @return \Robo\Result + */ + public function run() + { + $result = call_user_func($this->fn, $this->getState()); + // If the function returns no result, then count it + // as a success. + if (!isset($result)) { + $result = Result::success($this->reference); + } + // If the function returns a result, it must either return + // a \Robo\Result or an exit code. In the later case, we + // convert it to a \Robo\Result. + if (!$result instanceof Result) { + $result = new Result($this->reference, $result); + } + + return $result; + } + + public function getState() + { + if ($this->reference instanceof StateAwareInterface) { + return $this->reference->getState(); + } + return new Data(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Collection.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Collection.php new file mode 100644 index 00000000..607435a4 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Collection.php @@ -0,0 +1,769 @@ +resetState(); + } + + public function setProgressBarAutoDisplayInterval($interval) + { + if (!$this->progressIndicator) { + return; + } + return $this->progressIndicator->setProgressBarAutoDisplayInterval($interval); + } + + /** + * {@inheritdoc} + */ + public function add(TaskInterface $task, $name = self::UNNAMEDTASK) + { + $task = new CompletionWrapper($this, $task); + $this->addToTaskList($name, $task); + return $this; + } + + /** + * {@inheritdoc} + */ + public function addCode(callable $code, $name = self::UNNAMEDTASK) + { + return $this->add(new CallableTask($code, $this), $name); + } + + /** + * {@inheritdoc} + */ + public function addIterable($iterable, callable $code) + { + $callbackTask = (new IterationTask($iterable, $code, $this))->inflect($this); + return $this->add($callbackTask); + } + + /** + * {@inheritdoc} + */ + public function rollback(TaskInterface $rollbackTask) + { + // Rollback tasks always try as hard as they can, and never report failures. + $rollbackTask = $this->ignoreErrorsTaskWrapper($rollbackTask); + return $this->wrapAndRegisterRollback($rollbackTask); + } + + /** + * {@inheritdoc} + */ + public function rollbackCode(callable $rollbackCode) + { + // Rollback tasks always try as hard as they can, and never report failures. + $rollbackTask = $this->ignoreErrorsCodeWrapper($rollbackCode); + return $this->wrapAndRegisterRollback($rollbackTask); + } + + /** + * {@inheritdoc} + */ + public function completion(TaskInterface $completionTask) + { + $collection = $this; + $completionRegistrationTask = new CallableTask( + function () use ($collection, $completionTask) { + + $collection->registerCompletion($completionTask); + }, + $this + ); + $this->addToTaskList(self::UNNAMEDTASK, $completionRegistrationTask); + return $this; + } + + /** + * {@inheritdoc} + */ + public function completionCode(callable $completionTask) + { + $completionTask = new CallableTask($completionTask, $this); + return $this->completion($completionTask); + } + + /** + * {@inheritdoc} + */ + public function before($name, $task, $nameOfTaskToAdd = self::UNNAMEDTASK) + { + return $this->addBeforeOrAfter(__FUNCTION__, $name, $task, $nameOfTaskToAdd); + } + + /** + * {@inheritdoc} + */ + public function after($name, $task, $nameOfTaskToAdd = self::UNNAMEDTASK) + { + return $this->addBeforeOrAfter(__FUNCTION__, $name, $task, $nameOfTaskToAdd); + } + + /** + * {@inheritdoc} + */ + public function progressMessage($text, $context = [], $level = LogLevel::NOTICE) + { + $context += ['name' => 'Progress']; + $context += TaskInfo::getTaskContext($this); + return $this->addCode( + function () use ($level, $text, $context) { + $context += $this->getState()->getData(); + $this->printTaskOutput($level, $text, $context); + } + ); + } + + /** + * @param \Robo\Contract\TaskInterface $rollbackTask + * + * @return $this + */ + protected function wrapAndRegisterRollback(TaskInterface $rollbackTask) + { + $collection = $this; + $rollbackRegistrationTask = new CallableTask( + function () use ($collection, $rollbackTask) { + $collection->registerRollback($rollbackTask); + }, + $this + ); + $this->addToTaskList(self::UNNAMEDTASK, $rollbackRegistrationTask); + return $this; + } + + /** + * Add either a 'before' or 'after' function or task. + * + * @param string $method + * @param string $name + * @param callable|TaskInterface $task + * @param string $nameOfTaskToAdd + * + * @return $this + */ + protected function addBeforeOrAfter($method, $name, $task, $nameOfTaskToAdd) + { + if (is_callable($task)) { + $task = new CallableTask($task, $this); + } + $existingTask = $this->namedTask($name); + $fn = [$existingTask, $method]; + call_user_func($fn, $task, $nameOfTaskToAdd); + return $this; + } + + /** + * Wrap the provided task in a wrapper that will ignore + * any errors or exceptions that may be produced. This + * is useful, for example, in adding optional cleanup tasks + * at the beginning of a task collection, to remove previous + * results which may or may not exist. + * + * TODO: Provide some way to specify which sort of errors + * are ignored, so that 'file not found' may be ignored, + * but 'permission denied' reported? + * + * @param \Robo\Contract\TaskInterface $task + * + * @return \Robo\Collection\CallableTask + */ + public function ignoreErrorsTaskWrapper(TaskInterface $task) + { + // If the task is a stack-based task, then tell it + // to try to run all of its operations, even if some + // of them fail. + if ($task instanceof StackBasedTask) { + $task->stopOnFail(false); + } + $ignoreErrorsInTask = function () use ($task) { + $data = []; + try { + $result = $this->runSubtask($task); + $message = $result->getMessage(); + $data = $result->getData(); + $data['exitcode'] = $result->getExitCode(); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + return Result::success($task, $message, $data); + }; + // Wrap our ignore errors callable in a task. + return new CallableTask($ignoreErrorsInTask, $this); + } + + /** + * @param callable $task + * + * @return \Robo\Collection\CallableTask + */ + public function ignoreErrorsCodeWrapper(callable $task) + { + return $this->ignoreErrorsTaskWrapper(new CallableTask($task, $this)); + } + + /** + * Return the list of task names added to this collection. + * + * @return array + */ + public function taskNames() + { + return array_keys($this->taskList); + } + + /** + * Test to see if a specified task name exists. + * n.b. before() and after() require that the named + * task exist; use this function to test first, if + * unsure. + * + * @param string $name + * + * @return bool + */ + public function hasTask($name) + { + return array_key_exists($name, $this->taskList); + } + + /** + * Find an existing named task. + * + * @param string $name + * The name of the task to insert before. The named task MUST exist. + * + * @return Element + * The task group for the named task. Generally this is only + * used to call 'before()' and 'after()'. + */ + protected function namedTask($name) + { + if (!$this->hasTask($name)) { + throw new \RuntimeException("Could not find task named $name"); + } + return $this->taskList[$name]; + } + + /** + * Add a list of tasks to our task collection. + * + * @param TaskInterface[] $tasks + * An array of tasks to run with rollback protection + * + * @return $this + */ + public function addTaskList(array $tasks) + { + foreach ($tasks as $name => $task) { + $this->add($task, $name); + } + return $this; + } + + /** + * Add the provided task to our task list. + * + * @param string $name + * @param \Robo\Contract\TaskInterface $task + * + * @return \Robo\Collection\Collection + */ + protected function addToTaskList($name, TaskInterface $task) + { + // All tasks are stored in a task group so that we have a place + // to hang 'before' and 'after' tasks. + $taskGroup = new Element($task); + return $this->addCollectionElementToTaskList($name, $taskGroup); + } + + /** + * @param int|string $name + * @param \Robo\Collection\Element $taskGroup + * + * @return $this + */ + protected function addCollectionElementToTaskList($name, Element $taskGroup) + { + // If a task name is not provided, then we'll let php pick + // the array index. + if (Result::isUnnamed($name)) { + $this->taskList[] = $taskGroup; + return $this; + } + // If we are replacing an existing task with the + // same name, ensure that our new task is added to + // the end. + $this->taskList[$name] = $taskGroup; + return $this; + } + + /** + * Set the parent collection. This is necessary so that nested + * collections' rollback and completion tasks can be added to the + * top-level collection, ensuring that the rollbacks for a collection + * will run if any later task fails. + * + * @param \Robo\Collection\NestedCollectionInterface $parentCollection + * + * @return $this + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->parentCollection = $parentCollection; + return $this; + } + + /** + * Get the appropriate parent collection to use + * + * @return CollectionInterface + */ + public function getParentCollection() + { + return $this->parentCollection ? $this->parentCollection : $this; + } + + /** + * Register a rollback task to run if there is any failure. + * + * Clients are free to add tasks to the rollback stack as + * desired; however, usually it is preferable to call + * Collection::rollback() instead. With that function, + * the rollback function will only be called if all of the + * tasks added before it complete successfully, AND some later + * task fails. + * + * One example of a good use-case for registering a callback + * function directly is to add a task that sends notification + * when a task fails. + * + * @param TaskInterface $rollbackTask + * The rollback task to run on failure. + */ + public function registerRollback(TaskInterface $rollbackTask) + { + if ($this->parentCollection) { + return $this->parentCollection->registerRollback($rollbackTask); + } + if ($rollbackTask) { + $this->rollbackStack[] = $rollbackTask; + } + } + + /** + * Register a completion task to run once all other tasks finish. + * Completion tasks run whether or not a rollback operation was + * triggered. They do not trigger rollbacks if they fail. + * + * The typical use-case for a completion function is to clean up + * temporary objects (e.g. temporary folders). The preferred + * way to do that, though, is to use Temporary::wrap(). + * + * On failures, completion tasks will run after all rollback tasks. + * If one task collection is nested inside another task collection, + * then the nested collection's completion tasks will run as soon as + * the nested task completes; they are not deferred to the end of + * the containing collection's execution. + * + * @param TaskInterface $completionTask + * The completion task to run at the end of all other operations. + */ + public function registerCompletion(TaskInterface $completionTask) + { + if ($this->parentCollection) { + return $this->parentCollection->registerCompletion($completionTask); + } + if ($completionTask) { + // Completion tasks always try as hard as they can, and never report failures. + $completionTask = $this->ignoreErrorsTaskWrapper($completionTask); + $this->completionStack[] = $completionTask; + } + } + + /** + * Return the count of steps in this collection + * + * @return int + */ + public function progressIndicatorSteps() + { + $steps = 0; + foreach ($this->taskList as $name => $taskGroup) { + $steps += $taskGroup->progressIndicatorSteps(); + } + return $steps; + } + + /** + * A Collection of tasks can provide a command via `getCommand()` + * if it contains a single task, and that task implements CommandInterface. + * + * @return string + * + * @throws \Robo\Exception\TaskException + */ + public function getCommand() + { + if (empty($this->taskList)) { + return ''; + } + + if (count($this->taskList) > 1) { + // TODO: We could potentially iterate over the items in the collection + // and concatenate the result of getCommand() from each one, and fail + // only if we encounter a command that is not a CommandInterface. + throw new TaskException($this, "getCommand() does not work on arbitrary collections of tasks."); + } + + $taskElement = reset($this->taskList); + $task = $taskElement->getTask(); + $task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + if ($task instanceof CommandInterface) { + return $task->getCommand(); + } + + throw new TaskException($task, get_class($task) . " does not implement CommandInterface, so can't be used to provide a command"); + } + + /** + * Run our tasks, and roll back if necessary. + * + * @return \Robo\Result + */ + public function run() + { + $result = $this->runWithoutCompletion(); + $this->complete(); + return $result; + } + + /** + * @return \Robo\Result + */ + private function runWithoutCompletion() + { + $result = Result::success($this); + + if (empty($this->taskList)) { + return $result; + } + + $this->startProgressIndicator(); + if ($result->wasSuccessful()) { + foreach ($this->taskList as $name => $taskGroup) { + $taskList = $taskGroup->getTaskList(); + $result = $this->runTaskList($name, $taskList, $result); + if (!$result->wasSuccessful()) { + $this->fail(); + return $result; + } + } + $this->taskList = []; + } + $this->stopProgressIndicator(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * Run every task in a list, but only up to the first failure. + * Return the failing result, or success if all tasks run. + * + * @param string $name + * @param TaskInterface[] $taskList + * @param \Robo\Result $result + * + * @return \Robo\Result + * + * @throws \Robo\Exception\TaskExitException + */ + private function runTaskList($name, array $taskList, Result $result) + { + try { + foreach ($taskList as $taskName => $task) { + $taskResult = $this->runSubtask($task); + $this->advanceProgressIndicator(); + // If the current task returns an error code, then stop + // execution and signal a rollback. + if (!$taskResult->wasSuccessful()) { + return $taskResult; + } + // We accumulate our results into a field so that tasks that + // have a reference to the collection may examine and modify + // the incremental results, if they wish. + $key = Result::isUnnamed($taskName) ? $name : $taskName; + $result->accumulate($key, $taskResult); + // The result message will be the message of the last task executed. + $result->setMessage($taskResult->getMessage()); + } + } catch (TaskExitException $exitException) { + $this->fail(); + throw $exitException; + } catch (\Exception $e) { + // Tasks typically should not throw, but if one does, we will + // convert it into an error and roll back. + return Result::fromException($task, $e, $result->getData()); + } + return $result; + } + + /** + * Force the rollback functions to run + * + * @return $this + */ + public function fail() + { + $this->disableProgressIndicator(); + $this->runRollbackTasks(); + $this->complete(); + return $this; + } + + /** + * Force the completion functions to run + * + * @return $this + */ + public function complete() + { + $this->detatchProgressIndicator(); + $this->runTaskListIgnoringFailures($this->completionStack); + $this->reset(); + return $this; + } + + /** + * Reset this collection, removing all tasks. + * + * @return $this + */ + public function reset() + { + $this->taskList = []; + $this->completionStack = []; + $this->rollbackStack = []; + return $this; + } + + /** + * Run all of our rollback tasks. + * + * Note that Collection does not implement RollbackInterface, but + * it may still be used as a task inside another task collection + * (i.e. you can nest task collections, if desired). + */ + protected function runRollbackTasks() + { + $this->runTaskListIgnoringFailures($this->rollbackStack); + // Erase our rollback stack once we have finished rolling + // everything back. This will allow us to potentially use + // a command collection more than once (e.g. to retry a + // failed operation after doing some error recovery). + $this->rollbackStack = []; + } + + /** + * @param TaskInterface|NestedCollectionInterface|WrappedTaskInterface $task + * + * @return \Robo\Result + */ + protected function runSubtask($task) + { + $original = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->setParentCollectionForTask($original, $this->getParentCollection()); + if ($original instanceof InflectionInterface) { + $original->inflect($this); + } + if ($original instanceof StateAwareInterface) { + $original->setState($this->getState()); + } + $this->doDeferredInitialization($original); + $taskResult = $task->run(); + $taskResult = Result::ensureResult($task, $taskResult); + $this->doStateUpdates($original, $taskResult); + return $taskResult; + } + + protected function doStateUpdates($task, Data $taskResult) + { + $this->updateState($taskResult); + $key = spl_object_hash($task); + if (array_key_exists($key, $this->messageStoreKeys)) { + $state = $this->getState(); + list($stateKey, $sourceKey) = $this->messageStoreKeys[$key]; + $value = empty($sourceKey) ? $taskResult->getMessage() : $taskResult[$sourceKey]; + $state[$stateKey] = $value; + } + } + + public function storeState($task, $key, $source = '') + { + $this->messageStoreKeys[spl_object_hash($task)] = [$key, $source]; + + return $this; + } + + public function deferTaskConfiguration($task, $functionName, $stateKey) + { + return $this->defer( + $task, + function ($task, $state) use ($functionName, $stateKey) { + $fn = [$task, $functionName]; + $value = $state[$stateKey]; + $fn($value); + } + ); + } + + /** + * Defer execution of a callback function until just before a task + * runs. Use this time to provide more settings for the task, e.g. from + * the collection's shared state, which is populated with the results + * of previous test runs. + */ + public function defer($task, $callback) + { + $this->deferredCallbacks[spl_object_hash($task)][] = $callback; + + return $this; + } + + protected function doDeferredInitialization($task) + { + // If the task is a state consumer, then call its receiveState method + if ($task instanceof \Robo\State\Consumer) { + $task->receiveState($this->getState()); + } + + // Check and see if there are any deferred callbacks for this task. + $key = spl_object_hash($task); + if (!array_key_exists($key, $this->deferredCallbacks)) { + return; + } + + // Call all of the deferred callbacks + foreach ($this->deferredCallbacks[$key] as $fn) { + $fn($task, $this->getState()); + } + } + + /** + * @param TaskInterface|NestedCollectionInterface|WrappedTaskInterface $task + * @param $parentCollection + */ + protected function setParentCollectionForTask($task, $parentCollection) + { + if ($task instanceof NestedCollectionInterface) { + $task->setParentCollection($parentCollection); + } + } + + /** + * Run all of the tasks in a provided list, ignoring failures. + * This is used to roll back or complete. + * + * @param TaskInterface[] $taskList + */ + protected function runTaskListIgnoringFailures(array $taskList) + { + foreach ($taskList as $task) { + try { + $this->runSubtask($task); + } catch (\Exception $e) { + // Ignore rollback failures. + } + } + } + + /** + * Give all of our tasks to the provided collection builder. + * + * @param CollectionBuilder $builder + */ + public function transferTasks($builder) + { + foreach ($this->taskList as $name => $taskGroup) { + // TODO: We are abandoning all of our before and after tasks here. + // At the moment, transferTasks is only called under conditions where + // there will be none of these, but care should be taken if that changes. + $task = $taskGroup->getTask(); + $builder->addTaskToCollection($task); + } + $this->reset(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionBuilder.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionBuilder.php new file mode 100644 index 00000000..3e037b01 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionBuilder.php @@ -0,0 +1,571 @@ +collectionBuilder() + * ->taskFilesystemStack() + * ->mkdir('g') + * ->touch('g/g.txt') + * ->rollback( + * $this->taskDeleteDir('g') + * ) + * ->taskFilesystemStack() + * ->mkdir('g/h') + * ->touch('g/h/h.txt') + * ->taskFilesystemStack() + * ->mkdir('g/h/i/c') + * ->touch('g/h/i/i.txt') + * ->run() + * ?> + * + * In the example above, the `taskDeleteDir` will be called if + * ``` + */ +class CollectionBuilder extends BaseTask implements NestedCollectionInterface, WrappedTaskInterface, CommandInterface, StateAwareInterface +{ + use StateAwareTrait; + + /** + * @var \Robo\Tasks + */ + protected $commandFile; + + /** + * @var CollectionInterface + */ + protected $collection; + + /** + * @var TaskInterface + */ + protected $currentTask; + + /** + * @var bool + */ + protected $simulated; + + /** + * @param \Robo\Tasks $commandFile + */ + public function __construct($commandFile) + { + $this->commandFile = $commandFile; + $this->resetState(); + } + + public static function create($container, $commandFile) + { + $builder = new self($commandFile); + + $builder->setLogger($container->get('logger')); + $builder->setProgressIndicator($container->get('progressIndicator')); + $builder->setConfig($container->get('config')); + $builder->setOutputAdapter($container->get('outputAdapter')); + + return $builder; + } + + /** + * @param bool $simulated + * + * @return $this + */ + public function simulated($simulated = true) + { + $this->simulated = $simulated; + return $this; + } + + /** + * @return bool + */ + public function isSimulated() + { + if (!isset($this->simulated)) { + $this->simulated = $this->getConfig()->get(Config::SIMULATE); + } + return $this->simulated; + } + + /** + * Create a temporary directory to work in. When the collection + * completes or rolls back, the temporary directory will be deleted. + * Returns the path to the location where the directory will be + * created. + * + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return string + */ + public function tmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + // n.b. Any task that the builder is asked to create is + // automatically added to the builder's collection, and + // wrapped in the builder object. Therefore, the result + // of any call to `taskFoo()` from within the builder will + // always be `$this`. + return $this->taskTmpDir($prefix, $base, $includeRandomPart)->getPath(); + } + + /** + * Create a working directory to hold results. A temporary directory + * is first created to hold the intermediate results. After the + * builder finishes, the work directory is moved into its final location; + * any results already in place will be moved out of the way and + * then deleted. + * + * @param string $finalDestination The path where the working directory + * will be moved once the task collection completes. + * + * @return string + */ + public function workDir($finalDestination) + { + // Creating the work dir task in this context adds it to our task collection. + return $this->taskWorkDir($finalDestination)->getPath(); + } + + public function addTask(TaskInterface $task) + { + $this->getCollection()->add($task); + return $this; + } + + /** + * Add arbitrary code to execute as a task. + * + * @see \Robo\Collection\CollectionInterface::addCode + * + * @param callable $code + * @param int|string $name + * @return $this + */ + public function addCode(callable $code, $name = \Robo\Collection\CollectionInterface::UNNAMEDTASK) + { + $this->getCollection()->addCode($code, $name); + return $this; + } + + /** + * Add a list of tasks to our task collection. + * + * @param TaskInterface[] $tasks + * An array of tasks to run with rollback protection + * + * @return $this + */ + public function addTaskList(array $tasks) + { + $this->getCollection()->addTaskList($tasks); + return $this; + } + + public function rollback(TaskInterface $task) + { + // Ensure that we have a collection if we are going to add + // a rollback function. + $this->getCollection()->rollback($task); + return $this; + } + + public function rollbackCode(callable $rollbackCode) + { + $this->getCollection()->rollbackCode($rollbackCode); + return $this; + } + + public function completion(TaskInterface $task) + { + $this->getCollection()->completion($task); + return $this; + } + + public function completionCode(callable $completionCode) + { + $this->getCollection()->completionCode($completionCode); + return $this; + } + + /** + * @param string $text + * @param array $context + * @param string $level + * + * @return $this + */ + public function progressMessage($text, $context = [], $level = LogLevel::NOTICE) + { + $this->getCollection()->progressMessage($text, $context, $level); + return $this; + } + + /** + * @param \Robo\Collection\NestedCollectionInterface $parentCollection + * + * @return $this + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->getCollection()->setParentCollection($parentCollection); + return $this; + } + + /** + * Called by the factory method of each task; adds the current + * task to the task builder. + * + * TODO: protected + * + * @param TaskInterface $task + * + * @return $this + */ + public function addTaskToCollection($task) + { + // Postpone creation of the collection until the second time + // we are called. At that time, $this->currentTask will already + // be populated. We call 'getCollection()' so that it will + // create the collection and add the current task to it. + // Note, however, that if our only tasks implements NestedCollectionInterface, + // then we should force this builder to use a collection. + if (!$this->collection && (isset($this->currentTask) || ($task instanceof NestedCollectionInterface))) { + $this->getCollection(); + } + $this->currentTask = $task; + if ($this->collection) { + $this->collection->add($task); + } + return $this; + } + + public function getState() + { + $collection = $this->getCollection(); + return $collection->getState(); + } + + public function storeState($key, $source = '') + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + public function deferTaskConfiguration($functionName, $stateKey) + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + public function defer($callback) + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + protected function callCollectionStateFuntion($functionName, $args) + { + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + + array_unshift($args, $currentTask); + $collection = $this->getCollection(); + $fn = [$collection, $functionName]; + + call_user_func_array($fn, $args); + return $this; + } + + public function setVerbosityThreshold($verbosityThreshold) + { + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + if ($currentTask) { + $currentTask->setVerbosityThreshold($verbosityThreshold); + return $this; + } + parent::setVerbosityThreshold($verbosityThreshold); + return $this; + } + + + /** + * Return the current task for this collection builder. + * TODO: Not needed? + * + * @return \Robo\Contract\TaskInterface + */ + public function getCollectionBuilderCurrentTask() + { + return $this->currentTask; + } + + /** + * Create a new builder with its own task collection + * + * @return CollectionBuilder + */ + public function newBuilder() + { + $collectionBuilder = new self($this->commandFile); + $collectionBuilder->inflect($this); + $collectionBuilder->simulated($this->isSimulated()); + $collectionBuilder->setVerbosityThreshold($this->verbosityThreshold()); + $collectionBuilder->setState($this->getState()); + + return $collectionBuilder; + } + + /** + * Calling the task builder with methods of the current + * task calls through to that method of the task. + * + * There is extra complexity in this function that could be + * simplified if we attached the 'LoadAllTasks' and custom tasks + * to the collection builder instead of the RoboFile. While that + * change would be a better design overall, it would require that + * the user do a lot more work to set up and use custom tasks. + * We therefore take on some additional complexity here in order + * to allow users to maintain their tasks in their RoboFile, which + * is much more convenient. + * + * Calls to $this->collectionBuilder()->taskFoo() cannot be made + * directly because all of the task methods are protected. These + * calls will therefore end up here. If the method name begins + * with 'task', then it is eligible to be used with the builder. + * + * When we call getBuiltTask, below, it will use the builder attached + * to the commandfile to build the task. However, this is not what we + * want: the task needs to be built from THIS collection builder, so that + * it will be affected by whatever state is active in this builder. + * To do this, we have two choices: 1) save and restore the builder + * in the commandfile, or 2) clone the commandfile and set this builder + * on the copy. 1) is vulnerable to failure in multithreaded environments + * (currently not supported), while 2) might cause confusion if there + * is shared state maintained in the commandfile, which is in the + * domain of the user. + * + * Note that even though we are setting up the commandFile to + * use this builder, getBuiltTask always creates a new builder + * (which is constructed using all of the settings from the + * commandFile's builder), and the new task is added to that. + * We therefore need to transfer the newly built task into this + * builder. The temporary builder is discarded. + * + * @param string $fn + * @param array $args + * + * @return $this|mixed + */ + public function __call($fn, $args) + { + if (preg_match('#^task[A-Z]#', $fn) && (method_exists($this->commandFile, 'getBuiltTask'))) { + $saveBuilder = $this->commandFile->getBuilder(); + $this->commandFile->setBuilder($this); + $temporaryBuilder = $this->commandFile->getBuiltTask($fn, $args); + $this->commandFile->setBuilder($saveBuilder); + if (!$temporaryBuilder) { + throw new \BadMethodCallException("No such method $fn: task does not exist in " . get_class($this->commandFile)); + } + $temporaryBuilder->getCollection()->transferTasks($this); + return $this; + } + if (!isset($this->currentTask)) { + throw new \BadMethodCallException("No such method $fn: current task undefined in collection builder."); + } + // If the method called is a method of the current task, + // then call through to the current task's setter method. + $result = call_user_func_array([$this->currentTask, $fn], $args); + + // If something other than a setter method is called, then return its result. + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + if (isset($result) && ($result !== $currentTask)) { + return $result; + } + + return $this; + } + + /** + * Construct the desired task and add it to this builder. + * + * @param string|object $name + * @param array $args + * + * @return \Robo\Collection\CollectionBuilder + */ + public function build($name, $args) + { + $reflection = new ReflectionClass($name); + $task = $reflection->newInstanceArgs($args); + if (!$task) { + throw new RuntimeException("Can not construct task $name"); + } + $task = $this->fixTask($task, $args); + $this->configureTask($name, $task); + return $this->addTaskToCollection($task); + } + + /** + * @param InflectionInterface $task + * @param array $args + * + * @return \Robo\Collection\CompletionWrapper|\Robo\Task\Simulator + */ + protected function fixTask($task, $args) + { + if ($task instanceof InflectionInterface) { + $task->inflect($this); + } + if ($task instanceof BuilderAwareInterface) { + $task->setBuilder($this); + } + if ($task instanceof VerbosityThresholdInterface) { + $task->setVerbosityThreshold($this->verbosityThreshold()); + } + + // Do not wrap our wrappers. + if ($task instanceof CompletionWrapper || $task instanceof Simulator) { + return $task; + } + + // Remember whether or not this is a task before + // it gets wrapped in any decorator. + $isTask = $task instanceof TaskInterface; + $isCollection = $task instanceof NestedCollectionInterface; + + // If the task implements CompletionInterface, ensure + // that its 'complete' method is called when the application + // terminates -- but only if its 'run' method is called + // first. If the task is added to a collection, then the + // task will be unwrapped via its `original` method, and + // it will be re-wrapped with a new completion wrapper for + // its new collection. + if ($task instanceof CompletionInterface) { + $task = new CompletionWrapper(Temporary::getCollection(), $task); + } + + // If we are in simulated mode, then wrap any task in + // a TaskSimulator. + if ($isTask && !$isCollection && ($this->isSimulated())) { + $task = new \Robo\Task\Simulator($task, $args); + $task->inflect($this); + } + + return $task; + } + + /** + * Check to see if there are any setter methods defined in configuration + * for this task. + */ + protected function configureTask($taskClass, $task) + { + $taskClass = static::configClassIdentifier($taskClass); + $configurationApplier = new ConfigForSetters($this->getConfig(), $taskClass, 'task.'); + $configurationApplier->apply($task, 'settings'); + + // TODO: If we counted each instance of $taskClass that was called from + // this builder, then we could also apply configuration from + // "task.{$taskClass}[$N].settings" + + // TODO: If the builder knew what the current command name was, + // then we could also search for task configuration under + // command-specific keys such as "command.{$commandname}.task.{$taskClass}.settings". + } + + /** + * When we run the collection builder, run everything in the collection. + * + * @return \Robo\Result + */ + public function run() + { + $this->startTimer(); + $result = $this->runTasks(); + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + $result->mergeData($this->getState()->getData()); + return $result; + } + + /** + * If there is a single task, run it; if there is a collection, run + * all of its tasks. + * + * @return \Robo\Result + */ + protected function runTasks() + { + if (!$this->collection && $this->currentTask) { + $result = $this->currentTask->run(); + return Result::ensureResult($this->currentTask, $result); + } + return $this->getCollection()->run(); + } + + /** + * @return string + */ + public function getCommand() + { + if (!$this->collection && $this->currentTask) { + $task = $this->currentTask; + $task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + if ($task instanceof CommandInterface) { + return $task->getCommand(); + } + } + + return $this->getCollection()->getCommand(); + } + + /** + * @return \Robo\Collection\Collection + */ + public function original() + { + return $this->getCollection(); + } + + /** + * Return the collection of tasks associated with this builder. + * + * @return CollectionInterface + */ + public function getCollection() + { + if (!isset($this->collection)) { + $this->collection = new Collection(); + $this->collection->inflect($this); + $this->collection->setState($this->getState()); + $this->collection->setProgressBarAutoDisplayInterval($this->getConfig()->get(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL)); + + if (isset($this->currentTask)) { + $this->collection->add($this->currentTask); + } + } + return $this->collection; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionInterface.php new file mode 100644 index 00000000..173ca169 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CollectionInterface.php @@ -0,0 +1,151 @@ +run(); + } catch (\Exception $e) { + return Result::fromException($result, $e); + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CompletionWrapper.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CompletionWrapper.php new file mode 100644 index 00000000..3e81bd91 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/CompletionWrapper.php @@ -0,0 +1,106 @@ +collection = $collection; + $this->task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->rollbackTask = $rollbackTask; + } + + /** + * {@inheritdoc} + */ + public function original() + { + return $this->task; + } + + /** + * Before running this task, register its rollback and completion + * handlers on its collection. The reason this class exists is to + * defer registration of rollback and completion tasks until 'run()' time. + * + * @return \Robo\Result + */ + public function run() + { + if ($this->rollbackTask) { + $this->collection->registerRollback($this->rollbackTask); + } + if ($this->task instanceof RollbackInterface) { + $this->collection->registerRollback(new CallableTask([$this->task, 'rollback'], $this->task)); + } + if ($this->task instanceof CompletionInterface) { + $this->collection->registerCompletion(new CallableTask([$this->task, 'complete'], $this->task)); + } + + return $this->task->run(); + } + + /** + * Make this wrapper object act like the class it wraps. + * + * @param string $function + * @param array $args + * + * @return mixed + */ + public function __call($function, $args) + { + return call_user_func_array(array($this->task, $function), $args); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Element.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Element.php new file mode 100644 index 00000000..b67b56bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Element.php @@ -0,0 +1,116 @@ +task = $task; + } + + /** + * @param mixed $before + * @param string $name + */ + public function before($before, $name) + { + if ($name) { + $this->before[$name] = $before; + } else { + $this->before[] = $before; + } + } + + /** + * @param mixed $after + * @param string $name + */ + public function after($after, $name) + { + if ($name) { + $this->after[$name] = $after; + } else { + $this->after[] = $after; + } + } + + /** + * @return array + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return array + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function getTask() + { + return $this->task; + } + + /** + * @return array + */ + public function getTaskList() + { + return array_merge($this->getBefore(), [$this->getTask()], $this->getAfter()); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + $steps = 0; + foreach ($this->getTaskList() as $task) { + if ($task instanceof WrappedTaskInterface) { + $task = $task->original(); + } + // If the task is a ProgressIndicatorAwareInterface, then it + // will advance the progress indicator a number of times. + if ($task instanceof ProgressIndicatorAwareInterface) { + $steps += $task->progressIndicatorSteps(); + } + // We also advance the progress indicator once regardless + // of whether it is progress-indicator aware or not. + $steps++; + } + return $steps; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/NestedCollectionInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/NestedCollectionInterface.php new file mode 100644 index 00000000..5e32cf37 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/NestedCollectionInterface.php @@ -0,0 +1,12 @@ +iterable = $iterable; + } + + /** + * @param string $message + * @param array $context + * + * @return $this + */ + public function iterationMessage($message, $context = []) + { + $this->message = $message; + $this->context = $context + ['name' => 'Progress']; + return $this; + } + + /** + * @param int|string $key + * @param mixed $value + */ + protected function showIterationMessage($key, $value) + { + if ($this->message) { + $context = ['key' => $key, 'value' => $value]; + $context += $this->context; + $context += TaskInfo::getTaskContext($this); + $this->printTaskInfo($this->message, $context); + } + } + + /** + * @param callable $fn + * + * @return $this + */ + public function withEachKeyValueCall(callable $fn) + { + $this->functionStack[] = $fn; + return $this; + } + + /** + * @param callable $fn + * + * @return \Robo\Collection\TaskForEach + */ + public function call(callable $fn) + { + return $this->withEachKeyValueCall( + function ($key, $value) use ($fn) { + return call_user_func($fn, $value); + } + ); + } + + /** + * @param callable $fn + * + * @return \Robo\Collection\TaskForEach + */ + public function withBuilder(callable $fn) + { + $this->countingStack[] = + function ($key, $value) use ($fn) { + // Create a new builder for every iteration + $builder = $this->collectionBuilder(); + // The user function should build task operations using + // the $key / $value parameters; we will call run() on + // the builder thus constructed. + call_user_func($fn, $builder, $key, $value); + return $builder->getCollection()->progressIndicatorSteps(); + }; + return $this->withEachKeyValueCall( + function ($key, $value) use ($fn) { + // Create a new builder for every iteration + $builder = $this->collectionBuilder() + ->setParentCollection($this->parentCollection); + // The user function should build task operations using + // the $key / $value parameters; we will call run() on + // the builder thus constructed. + call_user_func($fn, $builder, $key, $value); + return $builder->run(); + } + ); + } + + /** + * {@inheritdoc} + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->parentCollection = $parentCollection; + return $this; + } + + /** + * {@inheritdoc} + */ + public function progressIndicatorSteps() + { + $multiplier = count($this->functionStack); + if (!empty($this->countingStack)) { + $value = reset($this->iterable); + $key = key($this->iterable); + foreach ($this->countingStack as $fn) { + $multiplier += call_user_func($fn, $key, $value); + } + } + return count($this->iterable) * $multiplier; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $finalResult = Result::success($this); + $this->startProgressIndicator(); + foreach ($this->iterable as $key => $value) { + $this->showIterationMessage($key, $value); + try { + foreach ($this->functionStack as $fn) { + $result = call_user_func($fn, $key, $value); + $this->advanceProgressIndicator(); + if (!isset($result)) { + $result = Result::success($this); + } + // If the function returns a result, it must either return + // a \Robo\Result or an exit code. In the later case, we + // convert it to a \Robo\Result. + if (!$result instanceof Result) { + $result = new Result($this, $result); + } + if (!$result->wasSuccessful()) { + return $result; + } + $finalResult = $result->merge($finalResult); + } + } catch (\Exception $e) { + return Result::fromException($result, $e); + } + } + $this->stopProgressIndicator(); + return $finalResult; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Temporary.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Temporary.php new file mode 100644 index 00000000..dad25e34 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/Temporary.php @@ -0,0 +1,57 @@ +get('collection'); + register_shutdown_function(function () { + static::complete(); + }); + } + + return static::$collection; + } + + /** + * Call the complete method of all of the registered objects. + */ + public static function complete() + { + // Run the collection of tasks. This will also run the + // completion tasks. + $collection = static::getCollection(); + $collection->run(); + // Make sure that our completion functions do not run twice. + $collection->reset(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/loadTasks.php new file mode 100644 index 00000000..03f68823 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Collection/loadTasks.php @@ -0,0 +1,17 @@ +task(TaskForEach::class, $collection); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/BuilderAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/BuilderAwareTrait.php new file mode 100644 index 00000000..915ff008 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/BuilderAwareTrait.php @@ -0,0 +1,45 @@ +builder = $builder; + + return $this; + } + + /** + * @see \Robo\Contract\BuilderAwareInterface::getBuilder() + * + * @return \Robo\Collection\CollectionBuilder + */ + public function getBuilder() + { + return $this->builder; + } + + /** + * @return \Robo\Collection\CollectionBuilder + */ + protected function collectionBuilder() + { + return $this->getBuilder()->newBuilder(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandArguments.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandArguments.php new file mode 100644 index 00000000..12c2e89f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandArguments.php @@ -0,0 +1,130 @@ +args($arg); + } + + /** + * Pass methods parameters as arguments to executable. Argument values + * are automatically escaped. + * + * @param string|string[] $args + * + * @return $this + */ + public function args($args) + { + if (!is_array($args)) { + $args = func_get_args(); + } + $this->arguments .= ' ' . implode(' ', array_map('static::escape', $args)); + return $this; + } + + /** + * Pass the provided string in its raw (as provided) form as an argument to executable. + * + * @param string $arg + * + * @return $this + */ + public function rawArg($arg) + { + $this->arguments .= " $arg"; + + return $this; + } + + /** + * Escape the provided value, unless it contains only alphanumeric + * plus a few other basic characters. + * + * @param string $value + * + * @return string + */ + public static function escape($value) + { + if (preg_match('/^[a-zA-Z0-9\/\.@~_-]+$/', $value)) { + return $value; + } + return ProcessUtils::escapeArgument($value); + } + + /** + * Pass option to executable. Options are prefixed with `--` , value can be provided in second parameter. + * Option values are automatically escaped. + * + * @param string $option + * @param string $value + * @param string $separator + * + * @return $this + */ + public function option($option, $value = null, $separator = ' ') + { + if ($option !== null and strpos($option, '-') !== 0) { + $option = "--$option"; + } + $this->arguments .= null == $option ? '' : " " . $option; + $this->arguments .= null == $value ? '' : $separator . static::escape($value); + return $this; + } + + /** + * Pass multiple options to executable. The associative array contains + * the key:value pairs that become `--key value`, for each item in the array. + * Values are automatically escaped. + */ + public function options(array $options, $separator = ' ') + { + foreach ($options as $option => $value) { + $this->option($option, $value, $separator); + } + return $this; + } + + /** + * Pass an option with multiple values to executable. Value can be a string or array. + * Option values are automatically escaped. + * + * @param string $option + * @param string|array $value + * @param string $separator + * + * @return $this + */ + public function optionList($option, $value = array(), $separator = ' ') + { + if (is_array($value)) { + foreach ($value as $item) { + $this->optionList($option, $item, $separator); + } + } else { + $this->option($option, $value, $separator); + } + + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandReceiver.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandReceiver.php new file mode 100644 index 00000000..03b20fce --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/CommandReceiver.php @@ -0,0 +1,30 @@ +getCommand(); + } else { + throw new TaskException($this, get_class($command) . " does not implement CommandInterface, so can't be passed into this task"); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ConfigAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ConfigAwareTrait.php new file mode 100644 index 00000000..d6d45788 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ConfigAwareTrait.php @@ -0,0 +1,109 @@ +config = $config; + + return $this; + } + + /** + * Get the config management object. + * + * @return ConfigInterface + * + * @see \Robo\Contract\ConfigAwareInterface::getConfig() + */ + public function getConfig() + { + return $this->config; + } + + /** + * Any class that uses ConfigAwareTrait SHOULD override this method + * , and define a prefix for its configuration items. This is usually + * done in a base class. When used, this method should return a string + * that ends with a "."; see BaseTask::configPrefix(). + * + * @return string + */ + protected static function configPrefix() + { + return ''; + } + + protected static function configClassIdentifier($classname) + { + $configIdentifier = strtr($classname, '\\', '.'); + $configIdentifier = preg_replace('#^(.*\.Task\.|\.)#', '', $configIdentifier); + + return $configIdentifier; + } + + protected static function configPostfix() + { + return ''; + } + + /** + * @param string $key + * + * @return string + */ + private static function getClassKey($key) + { + $configPrefix = static::configPrefix(); // task. + $configClass = static::configClassIdentifier(get_called_class()); // PARTIAL_NAMESPACE.CLASSNAME + $configPostFix = static::configPostfix(); // .settings + + return sprintf('%s%s%s.%s', $configPrefix, $configClass, $configPostFix, $key); + } + + /** + * @param string $key + * @param mixed $value + * @param Config|null $config + */ + public static function configure($key, $value, $config = null) + { + if (!$config) { + $config = Robo::config(); + } + $config->setDefault(static::getClassKey($key), $value); + } + + /** + * @param string $key + * @param mixed|null $default + * + * @return mixed|null + */ + protected function getConfigValue($key, $default = null) + { + if (!$this->getConfig()) { + return $default; + } + return $this->getConfig()->get(static::getClassKey($key), $default); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/DynamicParams.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/DynamicParams.php new file mode 100644 index 00000000..28a1d150 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/DynamicParams.php @@ -0,0 +1,45 @@ +$property))) { + $this->$property = !$this->$property; + return $this; + } + + // append item to array + if (is_array($this->$property)) { + if (is_array($args[0])) { + $this->$property = $args[0]; + } else { + array_push($this->$property, $args[0]); + } + return $this; + } + + $this->$property = $args[0]; + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecCommand.php new file mode 100644 index 00000000..c3e6c3af --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecCommand.php @@ -0,0 +1,148 @@ +execTimer)) { + $this->execTimer = new TimeKeeper(); + } + return $this->execTimer; + } + + /** + * Look for a "{$cmd}.phar" in the current working + * directory; return a string to exec it if it is + * found. Otherwise, look for an executable command + * of the same name via findExecutable. + * + * @param string $cmd + * + * @return bool|string + */ + protected function findExecutablePhar($cmd) + { + if (file_exists("{$cmd}.phar")) { + return "php {$cmd}.phar"; + } + return $this->findExecutable($cmd); + } + + /** + * Return the best path to the executable program + * with the provided name. Favor vendor/bin in the + * current project. If not found there, use + * whatever is on the $PATH. + * + * @param string $cmd + * + * @return bool|string + */ + protected function findExecutable($cmd) + { + $pathToCmd = $this->searchForExecutable($cmd); + if ($pathToCmd) { + return $this->useCallOnWindows($pathToCmd); + } + return false; + } + + /** + * @param string $cmd + * + * @return string + */ + private function searchForExecutable($cmd) + { + $projectBin = $this->findProjectBin(); + + $localComposerInstallation = $projectBin . DIRECTORY_SEPARATOR . $cmd; + if (file_exists($localComposerInstallation)) { + return $localComposerInstallation; + } + $finder = new ExecutableFinder(); + return $finder->find($cmd, null, []); + } + + /** + * @return bool|string + */ + protected function findProjectBin() + { + $cwd = getcwd(); + $candidates = [ __DIR__ . '/../../vendor/bin', __DIR__ . '/../../bin', $cwd . '/vendor/bin' ]; + + // If this project is inside a vendor directory, give highest priority + // to that directory. + $vendorDirContainingUs = realpath(__DIR__ . '/../../../..'); + if (is_dir($vendorDirContainingUs) && (basename($vendorDirContainingUs) == 'vendor')) { + array_unshift($candidates, $vendorDirContainingUs . '/bin'); + } + + foreach ($candidates as $dir) { + if (is_dir("$dir")) { + return realpath($dir); + } + } + return false; + } + + /** + * Wrap Windows executables in 'call' per 7a88757d + * + * @param string $cmd + * + * @return string + */ + protected function useCallOnWindows($cmd) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if (file_exists("{$cmd}.bat")) { + $cmd = "{$cmd}.bat"; + } + return "call $cmd"; + } + return $cmd; + } + + protected function getCommandDescription() + { + return $this->process->getCommandLine(); + } + + /** + * @param string $command + * + * @return \Robo\Result + */ + protected function executeCommand($command) + { + // TODO: Symfony 4 requires that we supply the working directory. + $result_data = $this->execute(new Process($command, getcwd())); + return new Result( + $this, + $result_data->getExitCode(), + $result_data->getMessage(), + $result_data->getData() + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecOneCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecOneCommand.php new file mode 100644 index 00000000..60137514 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ExecOneCommand.php @@ -0,0 +1,12 @@ +interactive() based on posix_isatty(). + * + * @return $this + */ + public function detectInteractive() + { + // If the caller did not explicity set the 'interactive' mode, + // and output should be produced by this task (verbosityMeetsThreshold), + // then we will automatically set interactive mode based on whether + // or not output was redirected when robo was executed. + if (!isset($this->interactive) && function_exists('posix_isatty') && $this->verbosityMeetsThreshold()) { + $this->interactive = posix_isatty(STDOUT); + } + + return $this; + } + + /** + * Executes command in background mode (asynchronously) + * + * @return $this + */ + public function background($arg = true) + { + $this->background = $arg; + return $this; + } + + /** + * Stop command if it runs longer then $timeout in seconds + * + * @param int $timeout + * + * @return $this + */ + public function timeout($timeout) + { + $this->timeout = $timeout; + return $this; + } + + /** + * Stops command if it does not output something for a while + * + * @param int $timeout + * + * @return $this + */ + public function idleTimeout($timeout) + { + $this->idleTimeout = $timeout; + return $this; + } + + /** + * Set a single environment variable, or multiple. + */ + public function env($env, $value = null) + { + if (!is_array($env)) { + $env = [$env => ($value ? $value : true)]; + } + return $this->envVars($env); + } + + /** + * Sets the environment variables for the command + * + * @param array $env + * + * @return $this + */ + public function envVars(array $env) + { + $this->env = $env; + return $this; + } + + /** + * Pass an input to the process. Can be resource created with fopen() or string + * + * @param resource|string $input + * + * @return $this + */ + public function setInput($input) + { + $this->input = $input; + return $this; + } + + /** + * Attach tty to process for interactive input + * + * @param $interactive bool + * + * @return $this + */ + public function interactive($interactive = true) + { + $this->interactive = $interactive; + return $this; + } + + + /** + * Is command printing its output to screen + * + * @return bool + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * Changes working directory of command + * + * @param string $dir + * + * @return $this + */ + public function dir($dir) + { + $this->workingDirectory = $dir; + return $this; + } + + /** + * Shortcut for setting isPrinted() and isMetadataPrinted() to false. + * + * @param bool $arg + * + * @return $this + */ + public function silent($arg) + { + if (is_bool($arg)) { + $this->isPrinted = !$arg; + $this->isMetadataPrinted = !$arg; + } + return $this; + } + + /** + * Should command output be printed + * + * @param bool $arg + * + * @return $this + * + * @deprecated + */ + public function printed($arg) + { + $this->logger->warning("printed() is deprecated. Please use printOutput()."); + return $this->printOutput($arg); + } + + /** + * Should command output be printed + * + * @param bool $arg + * + * @return $this + */ + public function printOutput($arg) + { + if (is_bool($arg)) { + $this->isPrinted = $arg; + } + return $this; + } + + /** + * Should command metadata be printed. I,e., command and timer. + * + * @param bool $arg + * + * @return $this + */ + public function printMetadata($arg) + { + if (is_bool($arg)) { + $this->isMetadataPrinted = $arg; + } + return $this; + } + + /** + * @param Process $process + * @param callable $output_callback + * + * @return \Robo\ResultData + */ + protected function execute($process, $output_callback = null) + { + $this->process = $process; + + if (!$output_callback) { + $output_callback = function ($type, $buffer) { + $progressWasVisible = $this->hideTaskProgress(); + $this->writeMessage($buffer); + $this->showTaskProgress($progressWasVisible); + }; + } + + $this->detectInteractive(); + + if ($this->isMetadataPrinted) { + $this->printAction(); + } + $this->process->setTimeout($this->timeout); + $this->process->setIdleTimeout($this->idleTimeout); + if ($this->workingDirectory) { + $this->process->setWorkingDirectory($this->workingDirectory); + } + if ($this->input) { + $this->process->setInput($this->input); + } + + if ($this->interactive && $this->isPrinted) { + $this->process->setTty(true); + } + + if (isset($this->env)) { + $this->process->setEnv($this->env); + } + + if (!$this->background && !$this->isPrinted) { + $this->startTimer(); + $this->process->run(); + $this->stopTimer(); + $output = rtrim($this->process->getOutput()); + return new ResultData( + $this->process->getExitCode(), + $output, + $this->getResultData() + ); + } + + if (!$this->background && $this->isPrinted) { + $this->startTimer(); + $this->process->run($output_callback); + $this->stopTimer(); + return new ResultData( + $this->process->getExitCode(), + $this->process->getOutput(), + $this->getResultData() + ); + } + + try { + $this->process->start(); + } catch (\Exception $e) { + return new ResultData( + $this->process->getExitCode(), + $e->getMessage(), + $this->getResultData() + ); + } + return new ResultData($this->process->getExitCode()); + } + + /** + * + */ + protected function stop() + { + if ($this->background && isset($this->process) && $this->process->isRunning()) { + $this->process->stop(); + $this->printTaskInfo( + "Stopped {command}", + ['command' => $this->getCommandDescription()] + ); + } + } + + /** + * @param array $context + */ + protected function printAction($context = []) + { + $command = $this->getCommandDescription(); + $formatted_command = $this->formatCommandDisplay($command); + + $dir = $this->workingDirectory ? " in {dir}" : ""; + $this->printTaskInfo("Running {command}$dir", [ + 'command' => $formatted_command, + 'dir' => $this->workingDirectory + ] + $context); + } + + /** + * @param $command + * + * @return mixed + */ + protected function formatCommandDisplay($command) + { + $formatted_command = str_replace("&&", "&&\n", $command); + $formatted_command = str_replace("||", "||\n", $formatted_command); + + return $formatted_command; + } + + /** + * Gets the data array to be passed to Result(). + * + * @return array + * The data array passed to Result(). + */ + protected function getResultData() + { + if ($this->isMetadataPrinted) { + return ['time' => $this->getExecutionTime()]; + } + + return []; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/IO.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/IO.php new file mode 100644 index 00000000..d6c77bff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/IO.php @@ -0,0 +1,171 @@ +io) { + $this->io = new SymfonyStyle($this->input(), $this->output()); + } + return $this->io; + } + + /** + * @param string $nonDecorated + * @param string $decorated + * + * @return string + */ + protected function decorationCharacter($nonDecorated, $decorated) + { + if (!$this->output()->isDecorated() || (strncasecmp(PHP_OS, 'WIN', 3) == 0)) { + return $nonDecorated; + } + return $decorated; + } + + /** + * @param string $text + */ + protected function say($text) + { + $char = $this->decorationCharacter('>', '➜'); + $this->writeln("$char $text"); + } + + /** + * @param string $text + * @param int $length + * @param string $color + */ + protected function yell($text, $length = 40, $color = 'green') + { + $char = $this->decorationCharacter(' ', '➜'); + $format = "$char %s"; + $this->formattedOutput($text, $length, $format); + } + + /** + * @param string $text + * @param int $length + * @param string $format + */ + protected function formattedOutput($text, $length, $format) + { + $lines = explode("\n", trim($text, "\n")); + $maxLineLength = array_reduce(array_map('strlen', $lines), 'max'); + $length = max($length, $maxLineLength); + $len = $length + 2; + $space = str_repeat(' ', $len); + $this->writeln(sprintf($format, $space)); + foreach ($lines as $line) { + $line = str_pad($line, $length, ' ', STR_PAD_BOTH); + $this->writeln(sprintf($format, " $line ")); + } + $this->writeln(sprintf($format, $space)); + } + + /** + * @param string $question + * @param bool $hideAnswer + * + * @return string + */ + protected function ask($question, $hideAnswer = false) + { + if ($hideAnswer) { + return $this->askHidden($question); + } + return $this->doAsk(new Question($this->formatQuestion($question))); + } + + /** + * @param string $question + * + * @return string + */ + protected function askHidden($question) + { + $question = new Question($this->formatQuestion($question)); + $question->setHidden(true); + return $this->doAsk($question); + } + + /** + * @param string $question + * @param string $default + * + * @return string + */ + protected function askDefault($question, $default) + { + return $this->doAsk(new Question($this->formatQuestion("$question [$default]"), $default)); + } + + /** + * @param string $question + * + * @return string + */ + protected function confirm($question) + { + return $this->doAsk(new ConfirmationQuestion($this->formatQuestion($question . ' (y/n)'), false)); + } + + /** + * @param \Symfony\Component\Console\Question\Question $question + * + * @return string + */ + protected function doAsk(Question $question) + { + return $this->getDialog()->ask($this->input(), $this->output(), $question); + } + + /** + * @param string $message + * + * @return string + */ + protected function formatQuestion($message) + { + return "? $message "; + } + + /** + * @return \Symfony\Component\Console\Helper\QuestionHelper + */ + protected function getDialog() + { + return new QuestionHelper(); + } + + /** + * @param $text + */ + protected function writeln($text) + { + $this->output()->writeln($text); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InflectionTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InflectionTrait.php new file mode 100644 index 00000000..8bc4e831 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InflectionTrait.php @@ -0,0 +1,21 @@ +injectDependencies($this); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InputAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InputAwareTrait.php new file mode 100644 index 00000000..bae58c17 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/InputAwareTrait.php @@ -0,0 +1,51 @@ +input = $input; + + return $this; + } + + /** + * @return \Symfony\Component\Console\Input\InputInterface + */ + protected function input() + { + if (!isset($this->input)) { + $this->setInput(new ArgvInput()); + } + return $this->input; + } + + /** + * Backwards compatibility. + * + * @return \Symfony\Component\Console\Input\InputInterface + * + * @deprecated + */ + protected function getInput() + { + return $this->input(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAdapter.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAdapter.php new file mode 100644 index 00000000..b8e795f2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAdapter.php @@ -0,0 +1,38 @@ + OutputInterface::VERBOSITY_NORMAL, + VerbosityThresholdInterface::VERBOSITY_VERBOSE => OutputInterface::VERBOSITY_VERBOSE, + VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE, + VerbosityThresholdInterface::VERBOSITY_DEBUG => OutputInterface::VERBOSITY_DEBUG, + ]; + + public function verbosityMeetsThreshold($verbosityThreshold) + { + if (!isset($this->verbosityMap[$verbosityThreshold])) { + return true; + } + $verbosityThreshold = $this->verbosityMap[$verbosityThreshold]; + $verbosity = $this->output()->getVerbosity(); + + return $verbosity >= $verbosityThreshold; + } + + public function writeMessage($message) + { + $this->output()->write($message); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAwareTrait.php new file mode 100644 index 00000000..48082cb3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/OutputAwareTrait.php @@ -0,0 +1,51 @@ +output = $output; + + return $this; + } + + /** + * @return \Symfony\Component\Console\Output\OutputInterface + */ + protected function output() + { + if (!isset($this->output)) { + $this->setOutput(new NullOutput()); + } + return $this->output; + } + + /** + * Backwards compatibility + * + * @return \Symfony\Component\Console\Output\OutputInterface + * + * @deprecated + */ + protected function getOutput() + { + return $this->output(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessExecutor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessExecutor.php new file mode 100644 index 00000000..f78a4775 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessExecutor.php @@ -0,0 +1,51 @@ +process = $process; + } + + public static function create($container, $process) + { + $processExecutor = new self($process); + + $processExecutor->setLogger($container->get('logger')); + $processExecutor->setProgressIndicator($container->get('progressIndicator')); + $processExecutor->setConfig($container->get('config')); + $processExecutor->setOutputAdapter($container->get('outputAdapter')); + + return $processExecutor; + } + + /** + * @return string + */ + protected function getCommandDescription() + { + return $this->process->getCommandLine(); + } + + public function run() + { + return $this->execute($this->process); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessUtils.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessUtils.php new file mode 100644 index 00000000..7dc4e553 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProcessUtils.php @@ -0,0 +1,79 @@ + + */ + +namespace Robo\Common; + +use Symfony\Component\Process\Exception\InvalidArgumentException; + +/** + * ProcessUtils is a bunch of utility methods. We want to allow Robo 1.x + * to work with Symfony 4.x while remaining backwards compatibility. This + * requires us to replace some deprecated functionality removed in Symfony. + */ +class ProcessUtils +{ + /** + * This class should not be instantiated. + */ + private function __construct() + { + } + + /** + * Escapes a string to be used as a shell argument. + * + * @param string $argument The argument that will be escaped + * + * @return string The escaped argument + * + * @deprecated since version 3.3, to be removed in 4.0. Use a command line array or give env vars to the `Process::start/run()` method instead. + */ + public static function escapeArgument($argument) + { + @trigger_error('The '.__METHOD__.'() method is a copy of a method that was deprecated by Symfony 3.3 and removed in Symfony 4; it will be removed in Robo 2.0.', E_USER_DEPRECATED); + + //Fix for PHP bug #43784 escapeshellarg removes % from given string + //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows + //@see https://bugs.php.net/bug.php?id=43784 + //@see https://bugs.php.net/bug.php?id=49446 + if ('\\' === DIRECTORY_SEPARATOR) { + if ('' === $argument) { + return escapeshellarg($argument); + } + + $escapedArgument = ''; + $quote = false; + foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' === $part) { + $escapedArgument .= '\\"'; + } elseif (self::isSurroundedBy($part, '%')) { + // Avoid environment variable expansion + $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%'; + } else { + // escape trailing backslash + if ('\\' === substr($part, -1)) { + $part .= '\\'; + } + $quote = true; + $escapedArgument .= $part; + } + } + if ($quote) { + $escapedArgument = '"'.$escapedArgument.'"'; + } + + return $escapedArgument; + } + + return "'".str_replace("'", "'\\''", $argument)."'"; + } + + private static function isSurroundedBy($arg, $char) + { + return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicator.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicator.php new file mode 100644 index 00000000..050250e5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicator.php @@ -0,0 +1,201 @@ +progressBar = $progressBar; + $this->output = $output; + } + + /** + * @param int $interval + */ + public function setProgressBarAutoDisplayInterval($interval) + { + if ($this->progressIndicatorRunning) { + return; + } + $this->autoDisplayInterval = $interval; + } + + /** + * @return bool + */ + public function hideProgressIndicator() + { + $result = $this->progressBarDisplayed; + if ($this->progressIndicatorRunning && $this->progressBarDisplayed) { + $this->progressBar->clear(); + // Hack: progress indicator does not reset cursor to beginning of line on 'clear' + $this->output->write("\x0D"); + $this->progressBarDisplayed = false; + } + return $result; + } + + public function showProgressIndicator() + { + if ($this->progressIndicatorRunning && !$this->progressBarDisplayed && isset($this->progressBar)) { + $this->progressBar->display(); + $this->progressBarDisplayed = true; + $this->advanceProgressIndicatorCachedSteps(); + } + } + + /** + * @param bool $visible + */ + public function restoreProgressIndicator($visible) + { + if ($visible) { + $this->showProgressIndicator(); + } + } + + /** + * @param int $totalSteps + * @param \Robo\Contract\TaskInterface $owner + */ + public function startProgressIndicator($totalSteps, $owner) + { + if (!isset($this->progressBar)) { + return; + } + + $this->progressIndicatorRunning = true; + if (!isset($this->owner)) { + $this->owner = $owner; + $this->startTimer(); + $this->totalSteps = $totalSteps; + $this->autoShowProgressIndicator(); + } + } + + public function autoShowProgressIndicator() + { + if (($this->autoDisplayInterval < 0) || !isset($this->progressBar) || !$this->output->isDecorated()) { + return; + } + if ($this->autoDisplayInterval <= $this->getExecutionTime()) { + $this->autoDisplayInterval = -1; + $this->progressBar->start($this->totalSteps); + $this->showProgressIndicator(); + } + } + + /** + * @return bool + */ + public function inProgress() + { + return $this->progressIndicatorRunning; + } + + /** + * @param \Robo\Contract\TaskInterface $owner + */ + public function stopProgressIndicator($owner) + { + if ($this->progressIndicatorRunning && ($this->owner === $owner)) { + $this->cleanup(); + } + } + + protected function cleanup() + { + $this->progressIndicatorRunning = false; + $this->owner = null; + if ($this->progressBarDisplayed) { + $this->progressBar->finish(); + // Hack: progress indicator does not always finish cleanly + $this->output->writeln(''); + $this->progressBarDisplayed = false; + } + $this->stopTimer(); + } + + /** + * Erase progress indicator and ensure it never returns. Used + * only during error handlers. + */ + public function disableProgressIndicator() + { + $this->cleanup(); + // ProgressIndicator is shared, so this permanently removes + // the program's ability to display progress bars. + $this->progressBar = null; + } + + /** + * @param int $steps + */ + public function advanceProgressIndicator($steps = 1) + { + $this->cachedSteps += $steps; + if ($this->progressIndicatorRunning) { + $this->autoShowProgressIndicator(); + // We only want to call `advance` if the progress bar is visible, + // because it always displays itself when it is advanced. + if ($this->progressBarDisplayed) { + return $this->advanceProgressIndicatorCachedSteps(); + } + } + } + + protected function advanceProgressIndicatorCachedSteps() + { + $this->progressBar->advance($this->cachedSteps); + $this->cachedSteps = 0; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicatorAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicatorAwareTrait.php new file mode 100644 index 00000000..060e039a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ProgressIndicatorAwareTrait.php @@ -0,0 +1,135 @@ +progressIndicator = $progressIndicator; + + return $this; + } + + /** + * @return null|bool + */ + protected function hideProgressIndicator() + { + if (!$this->progressIndicator) { + return; + } + return $this->progressIndicator->hideProgressIndicator(); + } + + protected function showProgressIndicator() + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->showProgressIndicator(); + } + + /** + * @param bool $visible + */ + protected function restoreProgressIndicator($visible) + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->restoreProgressIndicator($visible); + } + + /** + * @return int + */ + protected function getTotalExecutionTime() + { + if (!$this->progressIndicator) { + return 0; + } + return $this->progressIndicator->getExecutionTime(); + } + + protected function startProgressIndicator() + { + $this->startTimer(); + if ($this instanceof VerbosityThresholdInterface + && !$this->verbosityMeetsThreshold()) { + return; + } + if (!$this->progressIndicator) { + return; + } + $totalSteps = $this->progressIndicatorSteps(); + $this->progressIndicator->startProgressIndicator($totalSteps, $this); + } + + /** + * @return bool + */ + protected function inProgress() + { + if (!$this->progressIndicator) { + return false; + } + return $this->progressIndicator->inProgress(); + } + + protected function stopProgressIndicator() + { + $this->stopTimer(); + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->stopProgressIndicator($this); + } + + protected function disableProgressIndicator() + { + $this->stopTimer(); + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->disableProgressIndicator(); + } + + protected function detatchProgressIndicator() + { + $this->setProgressIndicator(null); + } + + /** + * @param int $steps + */ + protected function advanceProgressIndicator($steps = 1) + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->advanceProgressIndicator($steps); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ResourceExistenceChecker.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ResourceExistenceChecker.php new file mode 100644 index 00000000..233f90a9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/ResourceExistenceChecker.php @@ -0,0 +1,116 @@ +printTaskError(sprintf('Invalid glob "%s"!', $resource), $this); + $success = false; + continue; + } + foreach ($glob as $resource) { + if (!$this->checkResource($resource, $type)) { + $success = false; + } + } + } + return $success; + } + + /** + * Checks a single resource, file or directory. + * + * It will print an error as well on the console. + * + * @param string $resource File or folder. + * @param string $type "file", "dir", "fileAndDir" + * + * @return bool + */ + protected function checkResource($resource, $type) + { + switch ($type) { + case 'file': + if (!$this->isFile($resource)) { + $this->printTaskError(sprintf('File "%s" does not exist!', $resource), $this); + return false; + } + return true; + case 'dir': + if (!$this->isDir($resource)) { + $this->printTaskError(sprintf('Directory "%s" does not exist!', $resource), $this); + return false; + } + return true; + case 'fileAndDir': + if (!$this->isDir($resource) && !$this->isFile($resource)) { + $this->printTaskError(sprintf('File or directory "%s" does not exist!', $resource), $this); + return false; + } + return true; + } + } + + /** + * Convenience method to check the often uses "source => target" file / folder arrays. + * + * @param string|array $resources + */ + protected function checkSourceAndTargetResource($resources) + { + if (is_string($resources)) { + $resources = [$resources]; + } + $sources = []; + $targets = []; + foreach ($resources as $source => $target) { + $sources[] = $source; + $target[] = $target; + } + $this->checkResources($sources); + $this->checkResources($targets); + } + + /** + * Wrapper method around phps is_dir() + * + * @param string $directory + * + * @return bool + */ + protected function isDir($directory) + { + return is_dir($directory); + } + + /** + * Wrapper method around phps file_exists() + * + * @param string $file + * + * @return bool + */ + protected function isFile($file) + { + return file_exists($file); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TaskIO.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TaskIO.php new file mode 100644 index 00000000..49b5ccd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TaskIO.php @@ -0,0 +1,237 @@ +logger should always be set in Robo core tasks. + if ($this->logger) { + return $this->logger; + } + + // TODO: Remove call to Robo::logger() once maintaining backwards + // compatibility with legacy external Robo tasks is no longer desired. + if (!Robo::logger()) { + return null; + } + + static $gaveDeprecationWarning = false; + if (!$gaveDeprecationWarning) { + trigger_error('No logger set for ' . get_class($this) . '. Use $this->task(Foo::class) rather than new Foo() in loadTasks to ensure the builder can initialize task the task, or use $this->collectionBuilder()->taskFoo() if creating one task from within another.', E_USER_DEPRECATED); + $gaveDeprecationWarning = true; + } + return Robo::logger(); + } + + /** + * Print information about a task in progress. + * + * With the Symfony Console logger, NOTICE is displayed at VERBOSITY_VERBOSE + * and INFO is displayed at VERBOSITY_VERY_VERBOSE. + * + * Robo overrides the default such that NOTICE is displayed at + * VERBOSITY_NORMAL and INFO is displayed at VERBOSITY_VERBOSE. + * + * n.b. We should probably have printTaskNotice for our ordinary + * output, and use printTaskInfo for less interesting messages. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskInfo($text, $context = null) + { + // The 'note' style is used for both 'notice' and 'info' log levels; + // However, 'notice' is printed at VERBOSITY_NORMAL, whereas 'info' + // is only printed at VERBOSITY_VERBOSE. + $this->printTaskOutput(LogLevel::NOTICE, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that some part of the task succeeded. + * + * With the Symfony Console logger, success messages are remapped to NOTICE, + * and displayed in VERBOSITY_VERBOSE. When used with the Robo logger, + * success messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskSuccess($text, $context = null) + { + // Not all loggers will recognize ConsoleLogLevel::SUCCESS. + // We therefore log as LogLevel::NOTICE, and apply a '_level' + // override in the context so that this message will be + // logged as SUCCESS if that log level is recognized. + $context['_level'] = ConsoleLogLevel::SUCCESS; + $this->printTaskOutput(LogLevel::NOTICE, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that there is something wrong, but + * execution can continue. + * + * Warning messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskWarning($text, $context = null) + { + $this->printTaskOutput(LogLevel::WARNING, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that some operation in the task failed, + * and the task cannot continue. + * + * Error messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskError($text, $context = null) + { + $this->printTaskOutput(LogLevel::ERROR, $text, $this->getTaskContext($context)); + } + + /** + * Provide debugging notification. These messages are only + * displayed if the log level is VERBOSITY_DEBUG. + * + * @param string$text + * @param null|array $context + */ + protected function printTaskDebug($text, $context = null) + { + $this->printTaskOutput(LogLevel::DEBUG, $text, $this->getTaskContext($context)); + } + + /** + * @param string $level + * One of the \Psr\Log\LogLevel constant + * @param string $text + * @param null|array $context + */ + protected function printTaskOutput($level, $text, $context) + { + if (!$this->verbosityMeetsThreshold()) { + return; + } + $logger = $this->logger(); + if (!$logger) { + return; + } + // Hide the progress indicator, if it is visible. + $inProgress = $this->hideTaskProgress(); + $logger->log($level, $text, $this->getTaskContext($context)); + // After we have printed our log message, redraw the progress indicator. + $this->showTaskProgress($inProgress); + } + + /** + * @return bool + */ + protected function hideTaskProgress() + { + $inProgress = false; + if ($this instanceof ProgressIndicatorAwareInterface) { + $inProgress = $this->inProgress(); + } + + // If a progress indicator is running on this task, then we mush + // hide it before we print anything, or its display will be overwritten. + if ($inProgress) { + $inProgress = $this->hideProgressIndicator(); + } + return $inProgress; + } + + /** + * @param $inProgress + */ + protected function showTaskProgress($inProgress) + { + if ($inProgress) { + $this->restoreProgressIndicator($inProgress); + } + } + + /** + * Format a quantity of bytes. + * + * @param int $size + * @param int $precision + * + * @return string + */ + protected function formatBytes($size, $precision = 2) + { + if ($size === 0) { + return 0; + } + $base = log($size, 1024); + $suffixes = array('', 'k', 'M', 'G', 'T'); + return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + } + + /** + * Get the formatted task name for use in task output. + * This is placed in the task context under 'name', and + * used as the log label by Robo\Common\RoboLogStyle, + * which is inserted at the head of log messages by + * Robo\Common\CustomLogStyle::formatMessage(). + * + * @param null|object $task + * + * @return string + */ + protected function getPrintedTaskName($task = null) + { + if (!$task) { + $task = $this; + } + return TaskInfo::formatTaskName($task); + } + + /** + * @param null|array $context + * + * @return array with context information + */ + protected function getTaskContext($context = null) + { + if (!$context) { + $context = []; + } + if (!is_array($context)) { + $context = ['task' => $context]; + } + if (!array_key_exists('task', $context)) { + $context['task'] = $this; + } + + return $context + TaskInfo::getTaskContext($context['task']); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TimeKeeper.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TimeKeeper.php new file mode 100644 index 00000000..1cd3e334 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/TimeKeeper.php @@ -0,0 +1,69 @@ +startedAt) { + return; + } + // Get time in seconds as a float, accurate to the microsecond. + $this->startedAt = microtime(true); + } + + public function stop() + { + $this->finishedAt = microtime(true); + } + + /** + * @return float|null + */ + public function elapsed() + { + $finished = $this->finishedAt ? $this->finishedAt : microtime(true); + if ($finished - $this->startedAt <= 0) { + return null; + } + return $finished - $this->startedAt; + } + + /** + * Format a duration into a human-readable time + * + * @param float $duration Duration in seconds, with fractional component + * + * @return string + */ + public static function formatDuration($duration) + { + if ($duration >= self::DAY * 2) { + return gmdate('z \d\a\y\s H:i:s', $duration); + } + if ($duration > self::DAY) { + return gmdate('\1 \d\a\y H:i:s', $duration); + } + if ($duration > self::HOUR) { + return gmdate("H:i:s", $duration); + } + if ($duration > self::MINUTE) { + return gmdate("i:s", $duration); + } + return round($duration, 3).'s'; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/Timer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/Timer.php new file mode 100644 index 00000000..955eb5bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/Timer.php @@ -0,0 +1,37 @@ +timer)) { + $this->timer = new TimeKeeper(); + } + $this->timer->start(); + } + + protected function stopTimer() + { + if (!isset($this->timer)) { + return; + } + $this->timer->stop(); + } + + /** + * @return float|null + */ + protected function getExecutionTime() + { + if (!isset($this->timer)) { + return null; + } + return $this->timer->elapsed(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/VerbosityThresholdTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/VerbosityThresholdTrait.php new file mode 100644 index 00000000..2fc51c22 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Common/VerbosityThresholdTrait.php @@ -0,0 +1,79 @@ +verbosityThreshold = $verbosityThreshold; + return $this; + } + + public function verbosityThreshold() + { + return $this->verbosityThreshold; + } + + public function setOutputAdapter(OutputAdapterInterface $outputAdapter) + { + $this->outputAdapter = $outputAdapter; + } + + /** + * @return OutputAdapterInterface + */ + public function outputAdapter() + { + return $this->outputAdapter; + } + + public function hasOutputAdapter() + { + return isset($this->outputAdapter); + } + + public function verbosityMeetsThreshold() + { + if ($this->hasOutputAdapter()) { + return $this->outputAdapter()->verbosityMeetsThreshold($this->verbosityThreshold()); + } + return true; + } + + /** + * Print a message if the selected verbosity level is over this task's + * verbosity threshhold. + */ + public function writeMessage($message) + { + if (!$this->verbosityMeetsThreshold()) { + return; + } + $this->outputAdapter()->writeMessage($message); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config.php new file mode 100644 index 00000000..9e9370d8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config.php @@ -0,0 +1,9 @@ +defaults = $this->getGlobalOptionDefaultValues(); + } + + /** + * Return an associative array containing all of the global configuration + * options and their default values. + * + * @return array + */ + public function getGlobalOptionDefaultValues() + { + $globalOptions = + [ + self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL => self::DEFAULT_PROGRESS_DELAY, + self::SIMULATE => false, + ]; + return $this->trimPrefixFromGlobalOptions($globalOptions); + } + + /** + * Remove the 'options.' prefix from the global options list. + */ + protected function trimPrefixFromGlobalOptions($globalOptions) + { + $result = []; + foreach ($globalOptions as $option => $value) { + $option = str_replace('options.', '', $option); + $result[$option] = $value; + } + return $result; + } + + /** + * @deprecated Use $config->get(Config::SIMULATE) + * + * @return bool + */ + public function isSimulated() + { + return $this->get(self::SIMULATE); + } + + /** + * @deprecated Use $config->set(Config::SIMULATE, true) + * + * @param bool $simulated + * + * @return $this + */ + public function setSimulated($simulated = true) + { + return $this->set(self::SIMULATE, $simulated); + } + + /** + * @deprecated Use $config->get(Config::INTERACTIVE) + * + * @return bool + */ + public function isInteractive() + { + return $this->get(self::INTERACTIVE); + } + + /** + * @deprecated Use $config->set(Config::INTERACTIVE, true) + * + * @param bool $interactive + * + * @return $this + */ + public function setInteractive($interactive = true) + { + return $this->set(self::INTERACTIVE, $interactive); + } + + /** + * @deprecated Use $config->get(Config::DECORATED) + * + * @return bool + */ + public function isDecorated() + { + return $this->get(self::DECORATED); + } + + /** + * @deprecated Use $config->set(Config::DECORATED, true) + * + * @param bool $decorated + * + * @return $this + */ + public function setDecorated($decorated = true) + { + return $this->set(self::DECORATED, $decorated); + } + + /** + * @deprecated Use $config->set(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval) + * + * @param int $interval + * + * @return $this + */ + public function setProgressBarAutoDisplayInterval($interval) + { + return $this->set(self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config/GlobalOptionDefaultValuesInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config/GlobalOptionDefaultValuesInterface.php new file mode 100644 index 00000000..f7639455 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Config/GlobalOptionDefaultValuesInterface.php @@ -0,0 +1,17 @@ +inflect($this) + * ->initializer() + * ->... + * + * Instead of: + * + * (new SomeTask($args)) + * ->setLogger($this->logger) + * ->initializer() + * ->... + * + * The reason `inflect` is better than the more explicit alternative is + * that subclasses of BaseTask that implement a new FooAwareInterface + * can override injectDependencies() as explained below, and add more + * dependencies that can be injected as needed. + * + * @param \Robo\Contract\InflectionInterface $parent + */ + public function inflect(InflectionInterface $parent); + + /** + * Take all dependencies availble to this task and inject any that are + * needed into the provided task. The general pattern is that, for every + * FooAwareInterface that this class implements, it should test to see + * if the child also implements the same interface, and if so, should call + * $child->setFoo($this->foo). + * + * The benefits of this are pretty large. Any time an object that implements + * InflectionInterface is created, just call `$child->inflect($this)`, and + * any available optional dependencies will be hooked up via setter injection. + * + * The required dependencies of an object should be provided via constructor + * injection, not inflection. + * + * @param InflectionInterface $child An object created by this class that + * should have its dependencies injected. + * + * @see https://mwop.net/blog/2016-04-26-on-locators.html + */ + public function injectDependencies(InflectionInterface $child); +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Contract/OutputAdapterInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Contract/OutputAdapterInterface.php new file mode 100644 index 00000000..948d384c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Contract/OutputAdapterInterface.php @@ -0,0 +1,11 @@ +prefix = 'options'; + } + + /** + * Add a reference to the Symfony Console application object. + */ + public function setApplication($application) + { + $this->application = $application; + return $this; + } + + /** + * Stipulate the prefix to use for option injection. + * @param string $prefix + */ + public function setGlobalOptionsPrefix($prefix) + { + $this->prefix = $prefix; + return $this; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ConsoleEvents::COMMAND => 'handleCommandEvent']; + } + + /** + * Run all of our individual operations when a command event is received. + */ + public function handleCommandEvent(ConsoleCommandEvent $event) + { + $this->setGlobalOptions($event); + $this->setConfigurationValues($event); + } + + /** + * Before a Console command runs, examine the global + * commandline options from the event Input, and set + * configuration values as appropriate. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function setGlobalOptions(ConsoleCommandEvent $event) + { + $config = $this->getConfig(); + $input = $event->getInput(); + + $globalOptions = $config->get($this->prefix, []); + if ($config instanceof \Consolidation\Config\GlobalOptionDefaultValuesInterface) { + $globalOptions += $config->getGlobalOptionDefaultValues(); + } + + $globalOptions += $this->applicationOptionDefaultValues(); + + // Set any config value that has a defined global option (e.g. --simulate) + foreach ($globalOptions as $option => $default) { + $value = $input->hasOption($option) ? $input->getOption($option) : null; + // Unfortunately, the `?:` operator does not differentate between `0` and `null` + if (!isset($value)) { + $value = $default; + } + $config->set($this->prefix . '.' . $option, $value); + } + } + + /** + * Examine the commandline --define / -D options, and apply the provided + * values to the active configuration. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function setConfigurationValues(ConsoleCommandEvent $event) + { + $config = $this->getConfig(); + $input = $event->getInput(); + + // Also set any `-D config.key=value` options from the commandline. + if ($input->hasOption('define')) { + $configDefinitions = $input->getOption('define'); + foreach ($configDefinitions as $value) { + list($key, $value) = $this->splitConfigKeyValue($value); + $config->set($key, $value); + } + } + } + + /** + * Split up the key=value config setting into its component parts. If + * the input string contains no '=' character, then the value will be 'true'. + * + * @param string $value + * @return array + */ + protected function splitConfigKeyValue($value) + { + $parts = explode('=', $value, 2); + $parts[] = true; + return $parts; + } + + /** + * Get default option values from the Symfony Console application, if + * it is available. + */ + protected function applicationOptionDefaultValues() + { + if (!$this->application) { + return []; + } + + $result = []; + foreach ($this->application->getDefinition()->getOptions() as $key => $option) { + $result[$key] = $option->acceptValue() ? $option->getDefault() : null; + } + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/LoadAllTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/LoadAllTasks.php new file mode 100644 index 00000000..3183d5b6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/LoadAllTasks.php @@ -0,0 +1,39 @@ +getTask(); + if ($task instanceof VerbosityThresholdInterface && !$task->verbosityMeetsThreshold()) { + return; + } + if (!$result->wasSuccessful()) { + return $this->printError($result); + } else { + return $this->printSuccess($result); + } + } + + /** + * Log that we are about to abort due to an error being encountered + * in 'stop on fail' mode. + * + * @param \Robo\Result $result + */ + public function printStopOnFail($result) + { + $this->printMessage(LogLevel::NOTICE, 'Stopping on fail. Exiting....'); + $this->printMessage(LogLevel::ERROR, 'Exit Code: {code}', ['code' => $result->getExitCode()]); + } + + /** + * Log the result of a Robo task that returned an error. + * + * @param \Robo\Result $result + * + * @return bool + */ + protected function printError(Result $result) + { + $task = $result->getTask(); + $context = $result->getContext() + ['timer-label' => 'Time', '_style' => []]; + $context['_style']['message'] = ''; + + $printOutput = true; + if ($task instanceof PrintedInterface) { + $printOutput = !$task->getPrinted(); + } + if ($printOutput) { + $this->printMessage(LogLevel::ERROR, "{message}", $context); + } + $this->printMessage(LogLevel::ERROR, 'Exit code {code}', $context); + return true; + } + + /** + * Log the result of a Robo task that was successful. + * + * @param \Robo\Result $result + * + * @return bool + */ + protected function printSuccess(Result $result) + { + $task = $result->getTask(); + $context = $result->getContext() + ['timer-label' => 'in']; + $time = $result->getExecutionTime(); + if ($time) { + $this->printMessage(ConsoleLogLevel::SUCCESS, 'Done', $context); + } + return false; + } + + /** + * @param string $level + * @param string $message + * @param array $context + */ + protected function printMessage($level, $message, $context = []) + { + $inProgress = $this->hideProgressIndicator(); + $this->logger->log($level, $message, $context); + if ($inProgress) { + $this->restoreProgressIndicator($inProgress); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogLevel.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogLevel.php new file mode 100644 index 00000000..d7d5eb0a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogLevel.php @@ -0,0 +1,11 @@ +labelStyles += [ + RoboLogLevel::SIMULATED_ACTION => self::TASK_STYLE_SIMULATED, + ]; + $this->messageStyles += [ + RoboLogLevel::SIMULATED_ACTION => '', + ]; + } + + /** + * Log style customization for Robo: replace the log level with + * the task name. + * + * @param string $level + * @param string $message + * @param array $context + * + * @return string + */ + protected function formatMessageByLevel($level, $message, $context) + { + $label = $level; + if (array_key_exists('name', $context)) { + $label = $context['name']; + } + return $this->formatMessage($label, $message, $context, $this->labelStyles[$level], $this->messageStyles[$level]); + } + + /** + * Log style customization for Robo: add the time indicator to the + * end of the log message if it exists in the context. + * + * @param string $label + * @param string $message + * @param array $context + * @param string $taskNameStyle + * @param string $messageStyle + * + * @return string + */ + protected function formatMessage($label, $message, $context, $taskNameStyle, $messageStyle = '') + { + $message = parent::formatMessage($label, $message, $context, $taskNameStyle, $messageStyle); + + if (array_key_exists('time', $context) && !empty($context['time']) && array_key_exists('timer-label', $context)) { + $duration = TimeKeeper::formatDuration($context['time']); + $message .= ' ' . $context['timer-label'] . ' ' . $this->wrapFormatString($duration, 'fg=yellow'); + } + + return $message; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogger.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogger.php new file mode 100644 index 00000000..75cf23f7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Log/RoboLogger.php @@ -0,0 +1,29 @@ + OutputInterface::VERBOSITY_NORMAL, // Default is "verbose" + LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, // Default is "verbose" + LogLevel::INFO => OutputInterface::VERBOSITY_VERBOSE, // Default is "very verbose" + ]; + parent::__construct($output, $roboVerbosityOverrides); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Result.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Result.php new file mode 100644 index 00000000..7d779352 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Result.php @@ -0,0 +1,258 @@ +task = $task; + $this->printResult(); + + if (self::$stopOnFail) { + $this->stopOnFail(); + } + } + + /** + * Tasks should always return a Result. However, they are also + * allowed to return NULL or an array to indicate success. + */ + public static function ensureResult($task, $result) + { + if ($result instanceof Result) { + return $result; + } + if (!isset($result)) { + return static::success($task); + } + if ($result instanceof Data) { + return static::success($task, $result->getMessage(), $result->getData()); + } + if ($result instanceof ResultData) { + return new Result($task, $result->getExitCode(), $result->getMessage(), $result->getData()); + } + if (is_array($result)) { + return static::success($task, '', $result); + } + throw new \Exception(sprintf('Task %s returned a %s instead of a \Robo\Result.', get_class($task), get_class($result))); + } + + protected function printResult() + { + // For historic reasons, the Result constructor is responsible + // for printing task results. + // TODO: Make IO the responsibility of some other class. Maintaining + // existing behavior for backwards compatibility. This is undesirable + // in the long run, though, as it can result in unwanted repeated input + // in task collections et. al. + $resultPrinter = Robo::resultPrinter(); + if ($resultPrinter) { + if ($resultPrinter->printResult($this)) { + $this->alreadyPrinted(); + } + } + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $extension + * @param string $service + * + * @return \Robo\Result + */ + public static function errorMissingExtension(TaskInterface $task, $extension, $service) + { + $messageTpl = 'PHP extension required for %s. Please enable %s'; + $message = sprintf($messageTpl, $service, $extension); + + return self::error($task, $message); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $class + * @param string $package + * + * @return \Robo\Result + */ + public static function errorMissingPackage(TaskInterface $task, $class, $package) + { + $messageTpl = 'Class %s not found. Please install %s Composer package'; + $message = sprintf($messageTpl, $class, $package); + + return self::error($task, $message); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $message + * @param array $data + * + * @return \Robo\Result + */ + public static function error(TaskInterface $task, $message, $data = []) + { + return new self($task, self::EXITCODE_ERROR, $message, $data); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param \Exception $e + * @param array $data + * + * @return \Robo\Result + */ + public static function fromException(TaskInterface $task, \Exception $e, $data = []) + { + $exitCode = $e->getCode(); + if (!$exitCode) { + $exitCode = self::EXITCODE_ERROR; + } + return new self($task, $exitCode, $e->getMessage(), $data); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $message + * @param array $data + * + * @return \Robo\Result + */ + public static function success(TaskInterface $task, $message = '', $data = []) + { + return new self($task, self::EXITCODE_OK, $message, $data); + } + + /** + * Return a context useful for logging messages. + * + * @return array + */ + public function getContext() + { + $task = $this->getTask(); + + return TaskInfo::getTaskContext($task) + [ + 'code' => $this->getExitCode(), + 'data' => $this->getArrayCopy(), + 'time' => $this->getExecutionTime(), + 'message' => $this->getMessage(), + ]; + } + + /** + * Add the results from the most recent task to the accumulated + * results from all tasks that have run so far, merging data + * as necessary. + * + * @param int|string $key + * @param \Robo\Result $taskResult + */ + public function accumulate($key, Result $taskResult) + { + // If the task is unnamed, then all of its data elements + // just get merged in at the top-level of the final Result object. + if (static::isUnnamed($key)) { + $this->merge($taskResult); + } elseif (isset($this[$key])) { + // There can only be one task with a given name; however, if + // there are tasks added 'before' or 'after' the named task, + // then the results from these will be stored under the same + // name unless they are given a name of their own when added. + $current = $this[$key]; + $this[$key] = $taskResult->merge($current); + } else { + $this[$key] = $taskResult; + } + } + + /** + * We assume that named values (e.g. for associative array keys) + * are non-numeric; numeric keys are presumed to simply be the + * index of an array, and therefore insignificant. + * + * @param int|string $key + * + * @return bool + */ + public static function isUnnamed($key) + { + return is_numeric($key); + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function getTask() + { + return $this->task; + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function cloneTask() + { + $reflect = new \ReflectionClass(get_class($this->task)); + return $reflect->newInstanceArgs(func_get_args()); + } + + /** + * @return bool + * + * @deprecated since 1.0. + * + * @see wasSuccessful() + */ + public function __invoke() + { + trigger_error(__METHOD__ . ' is deprecated: use wasSuccessful() instead.', E_USER_DEPRECATED); + return $this->wasSuccessful(); + } + + /** + * @return $this + */ + public function stopOnFail() + { + if (!$this->wasSuccessful()) { + $resultPrinter = Robo::resultPrinter(); + if ($resultPrinter) { + $resultPrinter->printStopOnFail($this); + } + $this->exitEarly($this->getExitCode()); + } + return $this; + } + + /** + * @param int $status + * + * @throws \Robo\Exception\TaskExitException + */ + private function exitEarly($status) + { + throw new TaskExitException($this->getTask(), $this->getMessage(), $status); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/ResultData.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/ResultData.php new file mode 100644 index 00000000..90baf6e9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/ResultData.php @@ -0,0 +1,110 @@ +exitCode = $exitCode; + parent::__construct($message, $data); + } + + /** + * @param string $message + * @param array $data + * + * @return \Robo\ResultData + */ + public static function message($message, $data = []) + { + return new self(self::EXITCODE_OK, $message, $data); + } + + /** + * @param string $message + * @param array $data + * + * @return \Robo\ResultData + */ + public static function cancelled($message = '', $data = []) + { + return new ResultData(self::EXITCODE_USER_CANCEL, $message, $data); + } + + /** + * @return int + */ + public function getExitCode() + { + return $this->exitCode; + } + + /** + * @return null|string + */ + public function getOutputData() + { + if (!empty($this->message) && !isset($this['already-printed']) && isset($this['provide-outputdata'])) { + return $this->message; + } + } + + /** + * Indicate that the message in this data has already been displayed. + */ + public function alreadyPrinted() + { + $this['already-printed'] = true; + } + + /** + * Opt-in to providing the result message as the output data + */ + public function provideOutputdata() + { + $this['provide-outputdata'] = true; + } + + /** + * @return bool + */ + public function wasSuccessful() + { + return $this->exitCode === self::EXITCODE_OK; + } + + /** + * @return bool + */ + public function wasCancelled() + { + return $this->exitCode == self::EXITCODE_USER_CANCEL; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Robo.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Robo.php new file mode 100644 index 00000000..0f427707 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Robo.php @@ -0,0 +1,394 @@ +setSelfUpdateRepository($repository); + $statusCode = $runner->execute($argv, $appName, $appVersion, $output); + return $statusCode; + } + + /** + * Sets a new global container. + * + * @param ContainerInterface $container + * A new container instance to replace the current. + */ + public static function setContainer(ContainerInterface $container) + { + static::$container = $container; + } + + /** + * Unsets the global container. + */ + public static function unsetContainer() + { + static::$container = null; + } + + /** + * Returns the currently active global container. + * + * @return \League\Container\ContainerInterface + * + * @throws \RuntimeException + */ + public static function getContainer() + { + if (static::$container === null) { + throw new \RuntimeException('container is not initialized yet. \Robo\Robo::setContainer() must be called with a real container.'); + } + return static::$container; + } + + /** + * Returns TRUE if the container has been initialized, FALSE otherwise. + * + * @return bool + */ + public static function hasContainer() + { + return static::$container !== null; + } + + /** + * Create a config object and load it from the provided paths. + */ + public static function createConfiguration($paths) + { + $config = new \Robo\Config\Config(); + static::loadConfiguration($paths, $config); + return $config; + } + + /** + * Use a simple config loader to load configuration values from specified paths + */ + public static function loadConfiguration($paths, $config = null) + { + if ($config == null) { + $config = static::config(); + } + $loader = new YamlConfigLoader(); + $processor = new ConfigProcessor(); + $processor->add($config->export()); + foreach ($paths as $path) { + $processor->extend($loader->load($path)); + } + $config->import($processor->export()); + } + + /** + * Create a container and initiailze it. If you wish to *change* + * anything defined in the container, then you should call + * \Robo::configureContainer() instead of this function. + * + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * @param null|\Robo\Application $app + * @param null|ConfigInterface $config + * + * @return \League\Container\Container|\League\Container\ContainerInterface + */ + public static function createDefaultContainer($input = null, $output = null, $app = null, $config = null) + { + // Do not allow this function to be called more than once. + if (static::hasContainer()) { + return static::getContainer(); + } + + if (!$app) { + $app = static::createDefaultApplication(); + } + + if (!$config) { + $config = new \Robo\Config\Config(); + } + + // Set up our dependency injection container. + $container = new Container(); + static::configureContainer($container, $app, $config, $input, $output); + + // Set the application dispatcher + $app->setDispatcher($container->get('eventDispatcher')); + + return $container; + } + + /** + * Initialize a container with all of the default Robo services. + * IMPORTANT: after calling this method, clients MUST call: + * + * $dispatcher = $container->get('eventDispatcher'); + * $app->setDispatcher($dispatcher); + * + * Any modification to the container should be done prior to fetching + * objects from it. + * + * It is recommended to use \Robo::createDefaultContainer() + * instead, which does all required setup for the caller, but has + * the limitation that the container it creates can only be + * extended, not modified. + * + * @param \League\Container\ContainerInterface $container + * @param \Symfony\Component\Console\Application $app + * @param ConfigInterface $config + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + */ + public static function configureContainer(ContainerInterface $container, SymfonyApplication $app, ConfigInterface $config, $input = null, $output = null) + { + // Self-referential container refernce for the inflector + $container->add('container', $container); + static::setContainer($container); + + // Create default input and output objects if they were not provided + if (!$input) { + $input = new StringInput(''); + } + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + $config->set(Config::DECORATED, $output->isDecorated()); + $config->set(Config::INTERACTIVE, $input->isInteractive()); + + $container->share('application', $app); + $container->share('config', $config); + $container->share('input', $input); + $container->share('output', $output); + $container->share('outputAdapter', \Robo\Common\OutputAdapter::class); + + // Register logging and related services. + $container->share('logStyler', \Robo\Log\RoboLogStyle::class); + $container->share('logger', \Robo\Log\RoboLogger::class) + ->withArgument('output') + ->withMethodCall('setLogOutputStyler', ['logStyler']); + $container->add('progressBar', \Symfony\Component\Console\Helper\ProgressBar::class) + ->withArgument('output'); + $container->share('progressIndicator', \Robo\Common\ProgressIndicator::class) + ->withArgument('progressBar') + ->withArgument('output'); + $container->share('resultPrinter', \Robo\Log\ResultPrinter::class); + $container->add('simulator', \Robo\Task\Simulator::class); + $container->share('globalOptionsEventListener', \Robo\GlobalOptionsEventListener::class) + ->withMethodCall('setApplication', ['application']); + $container->share('injectConfigEventListener', \Consolidation\Config\Inject\ConfigForCommand::class) + ->withArgument('config') + ->withMethodCall('setApplication', ['application']); + $container->share('collectionProcessHook', \Robo\Collection\CollectionProcessHook::class); + $container->share('alterOptionsCommandEvent', \Consolidation\AnnotatedCommand\Options\AlterOptionsCommandEvent::class) + ->withArgument('application'); + $container->share('hookManager', \Consolidation\AnnotatedCommand\Hooks\HookManager::class) + ->withMethodCall('addCommandEvent', ['alterOptionsCommandEvent']) + ->withMethodCall('addCommandEvent', ['injectConfigEventListener']) + ->withMethodCall('addCommandEvent', ['globalOptionsEventListener']) + ->withMethodCall('addResultProcessor', ['collectionProcessHook', '*']); + $container->share('eventDispatcher', \Symfony\Component\EventDispatcher\EventDispatcher::class) + ->withMethodCall('addSubscriber', ['hookManager']); + $container->share('formatterManager', \Consolidation\OutputFormatters\FormatterManager::class) + ->withMethodCall('addDefaultFormatters', []) + ->withMethodCall('addDefaultSimplifiers', []); + $container->share('prepareTerminalWidthOption', \Consolidation\AnnotatedCommand\Options\PrepareTerminalWidthOption::class) + ->withMethodCall('setApplication', ['application']); + $container->share('commandProcessor', \Consolidation\AnnotatedCommand\CommandProcessor::class) + ->withArgument('hookManager') + ->withMethodCall('setFormatterManager', ['formatterManager']) + ->withMethodCall('addPrepareFormatter', ['prepareTerminalWidthOption']) + ->withMethodCall( + 'setDisplayErrorFunction', + [ + function ($output, $message) use ($container) { + $logger = $container->get('logger'); + $logger->error($message); + } + ] + ); + $container->share('commandFactory', \Consolidation\AnnotatedCommand\AnnotatedCommandFactory::class) + ->withMethodCall('setCommandProcessor', ['commandProcessor']); + + // Deprecated: favor using collection builders to direct use of collections. + $container->add('collection', \Robo\Collection\Collection::class); + // Deprecated: use CollectionBuilder::create() instead -- or, better + // yet, BuilderAwareInterface::collectionBuilder() if available. + $container->add('collectionBuilder', \Robo\Collection\CollectionBuilder::class); + + static::addInflectors($container); + + // Make sure the application is appropriately initialized. + $app->setAutoExit(false); + } + + /** + * @param null|string $appName + * @param null|string $appVersion + * + * @return \Robo\Application + */ + public static function createDefaultApplication($appName = null, $appVersion = null) + { + $appName = $appName ?: self::APPLICATION_NAME; + $appVersion = $appVersion ?: self::VERSION; + + $app = new \Robo\Application($appName, $appVersion); + $app->setAutoExit(false); + return $app; + } + + /** + * Add the Robo League\Container inflectors to the container + * + * @param \League\Container\ContainerInterface $container + */ + public static function addInflectors($container) + { + // Register our various inflectors. + $container->inflector(\Robo\Contract\ConfigAwareInterface::class) + ->invokeMethod('setConfig', ['config']); + $container->inflector(\Psr\Log\LoggerAwareInterface::class) + ->invokeMethod('setLogger', ['logger']); + $container->inflector(\League\Container\ContainerAwareInterface::class) + ->invokeMethod('setContainer', ['container']); + $container->inflector(\Symfony\Component\Console\Input\InputAwareInterface::class) + ->invokeMethod('setInput', ['input']); + $container->inflector(\Robo\Contract\OutputAwareInterface::class) + ->invokeMethod('setOutput', ['output']); + $container->inflector(\Robo\Contract\ProgressIndicatorAwareInterface::class) + ->invokeMethod('setProgressIndicator', ['progressIndicator']); + $container->inflector(\Consolidation\AnnotatedCommand\Events\CustomEventAwareInterface::class) + ->invokeMethod('setHookManager', ['hookManager']); + $container->inflector(\Robo\Contract\VerbosityThresholdInterface::class) + ->invokeMethod('setOutputAdapter', ['outputAdapter']); + } + + /** + * Retrieves a service from the container. + * + * Use this method if the desired service is not one of those with a dedicated + * accessor method below. If it is listed below, those methods are preferred + * as they can return useful type hints. + * + * @param string $id + * The ID of the service to retrieve. + * + * @return mixed + * The specified service. + */ + public static function service($id) + { + return static::getContainer()->get($id); + } + + /** + * Indicates if a service is defined in the container. + * + * @param string $id + * The ID of the service to check. + * + * @return bool + * TRUE if the specified service exists, FALSE otherwise. + */ + public static function hasService($id) + { + // Check hasContainer() first in order to always return a Boolean. + return static::hasContainer() && static::getContainer()->has($id); + } + + /** + * Return the result printer object. + * + * @return \Robo\Log\ResultPrinter + */ + public static function resultPrinter() + { + return static::service('resultPrinter'); + } + + /** + * @return ConfigInterface + */ + public static function config() + { + return static::service('config'); + } + + /** + * @return \Consolidation\Log\Logger + */ + public static function logger() + { + return static::service('logger'); + } + + /** + * @return \Robo\Application + */ + public static function application() + { + return static::service('application'); + } + + /** + * Return the output object. + * + * @return \Symfony\Component\Console\Output\OutputInterface + */ + public static function output() + { + return static::service('output'); + } + + /** + * Return the input object. + * + * @return \Symfony\Component\Console\Input\InputInterface + */ + public static function input() + { + return static::service('input'); + } + + public static function process(Process $process) + { + return ProcessExecutor::create(static::getContainer(), $process); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Runner.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Runner.php new file mode 100644 index 00000000..800ad281 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Runner.php @@ -0,0 +1,465 @@ +roboClass = $roboClass ? $roboClass : self::ROBOCLASS ; + $this->roboFile = $roboFile ? $roboFile : self::ROBOFILE; + $this->dir = getcwd(); + } + + protected function errorCondtion($msg, $errorType) + { + $this->errorConditions[$msg] = $errorType; + } + + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return bool + */ + protected function loadRoboFile($output) + { + // If we have not been provided an output object, make a temporary one. + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + + // If $this->roboClass is a single class that has not already + // been loaded, then we will try to obtain it from $this->roboFile. + // If $this->roboClass is an array, we presume all classes requested + // are available via the autoloader. + if (is_array($this->roboClass) || class_exists($this->roboClass)) { + return true; + } + if (!file_exists($this->dir)) { + $this->errorCondtion("Path `{$this->dir}` is invalid; please provide a valid absolute path to the Robofile to load.", 'red'); + return false; + } + + $realDir = realpath($this->dir); + + $roboFilePath = $realDir . DIRECTORY_SEPARATOR . $this->roboFile; + if (!file_exists($roboFilePath)) { + $requestedRoboFilePath = $this->dir . DIRECTORY_SEPARATOR . $this->roboFile; + $this->errorCondtion("Requested RoboFile `$requestedRoboFilePath` is invalid, please provide valid absolute path to load Robofile.", 'red'); + return false; + } + require_once $roboFilePath; + + if (!class_exists($this->roboClass)) { + $this->errorCondtion("Class {$this->roboClass} was not loaded.", 'red'); + return false; + } + return true; + } + + /** + * @param array $argv + * @param null|string $appName + * @param null|string $appVersion + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * + * @return int + */ + public function execute($argv, $appName = null, $appVersion = null, $output = null) + { + $argv = $this->shebang($argv); + $argv = $this->processRoboOptions($argv); + $app = null; + if ($appName && $appVersion) { + $app = Robo::createDefaultApplication($appName, $appVersion); + } + $commandFiles = $this->getRoboFileCommands($output); + return $this->run($argv, $output, $app, $commandFiles); + } + + /** + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * @param null|\Robo\Application $app + * @param array[] $commandFiles + * + * @return int + */ + public function run($input = null, $output = null, $app = null, $commandFiles = []) + { + // Create default input and output objects if they were not provided + if (!$input) { + $input = new StringInput(''); + } + if (is_array($input)) { + $input = new ArgvInput($input); + } + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + $this->setInput($input); + $this->setOutput($output); + + // If we were not provided a container, then create one + if (!$this->getContainer()) { + $userConfig = 'robo.yml'; + $roboAppConfig = dirname(__DIR__) . '/robo.yml'; + $config = Robo::createConfiguration([$userConfig, $roboAppConfig]); + $container = Robo::createDefaultContainer($input, $output, $app, $config); + $this->setContainer($container); + // Automatically register a shutdown function and + // an error handler when we provide the container. + $this->installRoboHandlers(); + } + + if (!$app) { + $app = Robo::application(); + } + if ($app instanceof \Robo\Application) { + $app->addSelfUpdateCommand($this->getSelfUpdateRepository()); + if (!isset($commandFiles)) { + $this->errorCondtion("Robo is not initialized here. Please run `robo init` to create a new RoboFile.", 'yellow'); + $app->addInitRoboFileCommand($this->roboFile, $this->roboClass); + $commandFiles = []; + } + } + $this->registerCommandClasses($app, $commandFiles); + + try { + $statusCode = $app->run($input, $output); + } catch (TaskExitException $e) { + $statusCode = $e->getCode() ?: 1; + } + + // If there were any error conditions in bootstrapping Robo, + // print them only if the requested command did not complete + // successfully. + if ($statusCode) { + foreach ($this->errorConditions as $msg => $color) { + $this->yell($msg, 40, $color); + } + } + return $statusCode; + } + + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return null|string + */ + protected function getRoboFileCommands($output) + { + if (!$this->loadRoboFile($output)) { + return; + } + return $this->roboClass; + } + + /** + * @param \Robo\Application $app + * @param array $commandClasses + */ + public function registerCommandClasses($app, $commandClasses) + { + foreach ((array)$commandClasses as $commandClass) { + $this->registerCommandClass($app, $commandClass); + } + } + + /** + * @param \Robo\Application $app + * @param string|BuilderAwareInterface|ContainerAwareInterface $commandClass + * + * @return mixed|void + */ + public function registerCommandClass($app, $commandClass) + { + $container = Robo::getContainer(); + $roboCommandFileInstance = $this->instantiateCommandClass($commandClass); + if (!$roboCommandFileInstance) { + return; + } + + // Register commands for all of the public methods in the RoboFile. + $commandFactory = $container->get('commandFactory'); + $commandList = $commandFactory->createCommandsFromClass($roboCommandFileInstance); + foreach ($commandList as $command) { + $app->add($command); + } + return $roboCommandFileInstance; + } + + /** + * @param string|BuilderAwareInterface|ContainerAwareInterface $commandClass + * + * @return null|object + */ + protected function instantiateCommandClass($commandClass) + { + $container = Robo::getContainer(); + + // Register the RoboFile with the container and then immediately + // fetch it; this ensures that all of the inflectors will run. + // If the command class is already an instantiated object, then + // just use it exactly as it was provided to us. + if (is_string($commandClass)) { + if (!class_exists($commandClass)) { + return; + } + $reflectionClass = new \ReflectionClass($commandClass); + if ($reflectionClass->isAbstract()) { + return; + } + + $commandFileName = "{$commandClass}Commands"; + $container->share($commandFileName, $commandClass); + $commandClass = $container->get($commandFileName); + } + // If the command class is a Builder Aware Interface, then + // ensure that it has a builder. Every command class needs + // its own collection builder, as they have references to each other. + if ($commandClass instanceof BuilderAwareInterface) { + $builder = CollectionBuilder::create($container, $commandClass); + $commandClass->setBuilder($builder); + } + if ($commandClass instanceof ContainerAwareInterface) { + $commandClass->setContainer($container); + } + return $commandClass; + } + + public function installRoboHandlers() + { + register_shutdown_function(array($this, 'shutdown')); + set_error_handler(array($this, 'handleError')); + } + + /** + * Process a shebang script, if one was used to launch this Runner. + * + * @param array $args + * + * @return array $args with shebang script removed + */ + protected function shebang($args) + { + // Option 1: Shebang line names Robo, but includes no parameters. + // #!/bin/env robo + // The robo class may contain multiple commands; the user may + // select which one to run, or even get a list of commands or + // run 'help' on any of the available commands as usual. + if ((count($args) > 1) && $this->isShebangFile($args[1])) { + return array_merge([$args[0]], array_slice($args, 2)); + } + // Option 2: Shebang line stipulates which command to run. + // #!/bin/env robo mycommand + // The robo class must contain a public method named 'mycommand'. + // This command will be executed every time. Arguments and options + // may be provided on the commandline as usual. + if ((count($args) > 2) && $this->isShebangFile($args[2])) { + return array_merge([$args[0]], explode(' ', $args[1]), array_slice($args, 3)); + } + return $args; + } + + /** + * Determine if the specified argument is a path to a shebang script. + * If so, load it. + * + * @param string $filepath file to check + * + * @return bool Returns TRUE if shebang script was processed + */ + protected function isShebangFile($filepath) + { + if (!is_file($filepath)) { + return false; + } + $fp = fopen($filepath, "r"); + if ($fp === false) { + return false; + } + $line = fgets($fp); + $result = $this->isShebangLine($line); + if ($result) { + while ($line = fgets($fp)) { + $line = trim($line); + if ($line == 'roboClass = $matches[1]; + eval($script); + $result = true; + } + } + } + } + fclose($fp); + + return $result; + } + + /** + * Test to see if the provided line is a robo 'shebang' line. + * + * @param string $line + * + * @return bool + */ + protected function isShebangLine($line) + { + return ((substr($line, 0, 2) == '#!') && (strstr($line, 'robo') !== false)); + } + + /** + * Check for Robo-specific arguments such as --load-from, process them, + * and remove them from the array. We have to process --load-from before + * we set up Symfony Console. + * + * @param array $argv + * + * @return array + */ + protected function processRoboOptions($argv) + { + // loading from other directory + $pos = $this->arraySearchBeginsWith('--load-from', $argv) ?: array_search('-f', $argv); + if ($pos === false) { + return $argv; + } + + $passThru = array_search('--', $argv); + if (($passThru !== false) && ($passThru < $pos)) { + return $argv; + } + + if (substr($argv[$pos], 0, 12) == '--load-from=') { + $this->dir = substr($argv[$pos], 12); + } elseif (isset($argv[$pos +1])) { + $this->dir = $argv[$pos +1]; + unset($argv[$pos +1]); + } + unset($argv[$pos]); + // Make adjustments if '--load-from' points at a file. + if (is_file($this->dir) || (substr($this->dir, -4) == '.php')) { + $this->roboFile = basename($this->dir); + $this->dir = dirname($this->dir); + $className = basename($this->roboFile, '.php'); + if ($className != $this->roboFile) { + $this->roboClass = $className; + } + } + // Convert directory to a real path, but only if the + // path exists. We do not want to lose the original + // directory if the user supplied a bad value. + $realDir = realpath($this->dir); + if ($realDir) { + chdir($realDir); + $this->dir = $realDir; + } + + return $argv; + } + + /** + * @param string $needle + * @param string[] $haystack + * + * @return bool|int + */ + protected function arraySearchBeginsWith($needle, $haystack) + { + for ($i = 0; $i < count($haystack); ++$i) { + if (substr($haystack[$i], 0, strlen($needle)) == $needle) { + return $i; + } + } + return false; + } + + public function shutdown() + { + $error = error_get_last(); + if (!is_array($error)) { + return; + } + $this->writeln(sprintf("ERROR: %s \nin %s:%d\n", $error['message'], $error['file'], $error['line'])); + } + + /** + * This is just a proxy error handler that checks the current error_reporting level. + * In case error_reporting is disabled the error is marked as handled, otherwise + * the normal internal error handling resumes. + * + * @return bool + */ + public function handleError() + { + if (error_reporting() === 0) { + return true; + } + return false; + } + + /** + * @return string + */ + public function getSelfUpdateRepository() + { + return $this->selfUpdateRepository; + } + + /** + * @param string $selfUpdateRepository + */ + public function setSelfUpdateRepository($selfUpdateRepository) + { + $this->selfUpdateRepository = $selfUpdateRepository; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/SelfUpdateCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/SelfUpdateCommand.php new file mode 100644 index 00000000..d07ee71f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/SelfUpdateCommand.php @@ -0,0 +1,152 @@ + + */ +class SelfUpdateCommand extends Command +{ + const SELF_UPDATE_COMMAND_NAME = 'self:update'; + + protected $gitHubRepository; + + protected $currentVersion; + + protected $applicationName; + + public function __construct($applicationName = null, $currentVersion = null, $gitHubRepository = null) + { + parent::__construct(self::SELF_UPDATE_COMMAND_NAME); + + $this->applicationName = $applicationName; + $this->currentVersion = $currentVersion; + $this->gitHubRepository = $gitHubRepository; + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setAliases(array('update')) + ->setDescription('Updates the robo.phar to the latest version.') + ->setHelp( + <<self-update command checks github for newer +versions of robo and if found, installs the latest. +EOT + ); + } + + protected function getLatestReleaseFromGithub() + { + $opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => [ + 'User-Agent: ' . $this->applicationName . ' (' . $this->gitHubRepository . ')' . ' Self-Update (PHP)' + ] + ] + ]; + + $context = stream_context_create($opts); + + $releases = file_get_contents('https://api.github.com/repos/' . $this->gitHubRepository . '/releases', false, $context); + $releases = json_decode($releases); + + if (! isset($releases[0])) { + throw new \Exception('API error - no release found at GitHub repository ' . $this->gitHubRepository); + } + + $version = $releases[0]->tag_name; + $url = $releases[0]->assets[0]->browser_download_url; + + return [ $version, $url ]; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if (empty(\Phar::running())) { + throw new \Exception(self::SELF_UPDATE_COMMAND_NAME . ' only works when running the phar version of ' . $this->applicationName . '.'); + } + + $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; + $programName = basename($localFilename); + $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar') . '-temp.phar'; + + // check for permissions in local filesystem before start connection process + if (! is_writable($tempDirectory = dirname($tempFilename))) { + throw new \Exception( + $programName . ' update failed: the "' . $tempDirectory . + '" directory used to download the temp file could not be written' + ); + } + + if (! is_writable($localFilename)) { + throw new \Exception( + $programName . ' update failed: the "' . $localFilename . '" file could not be written (execute with sudo)' + ); + } + + list( $latest, $downloadUrl ) = $this->getLatestReleaseFromGithub(); + + + if ($this->currentVersion == $latest) { + $output->writeln('No update available'); + return; + } + + $fs = new sfFilesystem(); + + $output->writeln('Downloading ' . $this->applicationName . ' (' . $this->gitHubRepository . ') ' . $latest); + + $fs->copy($downloadUrl, $tempFilename); + + $output->writeln('Download finished'); + + try { + \error_reporting(E_ALL); // supress notices + + @chmod($tempFilename, 0777 & ~umask()); + // test the phar validity + $phar = new \Phar($tempFilename); + // free the variable to unlock the file + unset($phar); + @rename($tempFilename, $localFilename); + $output->writeln('Successfully updated ' . $programName . ''); + $this->_exit(); + } catch (\Exception $e) { + @unlink($tempFilename); + if (! $e instanceof \UnexpectedValueException && ! $e instanceof \PharException) { + throw $e; + } + $output->writeln('The download is corrupted (' . $e->getMessage() . ').'); + $output->writeln('Please re-run the self-update command to try again.'); + } + } + + /** + * Stop execution + * + * This is a workaround to prevent warning of dispatcher after replacing + * the phar file. + * + * @return void + */ + protected function _exit() + { + exit; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/Consumer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/Consumer.php new file mode 100644 index 00000000..ab9c0e27 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/Consumer.php @@ -0,0 +1,12 @@ +message = $message; + parent::__construct($data); + } + + /** + * @return array + */ + public function getData() + { + return $this->getArrayCopy(); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @param string message + */ + public function setMessage($message) + { + $this->message = $message; + } + + /** + * Merge another result into this result. Data already + * existing in this result takes precedence over the + * data in the Result being merged. + * + * @param \Robo\ResultData $result + * + * @return $this + */ + public function merge(Data $result) + { + $mergedData = $this->getArrayCopy() + $result->getArrayCopy(); + $this->exchangeArray($mergedData); + return $this; + } + + /** + * Update the current data with the data provided in the parameter. + * Provided data takes precedence. + * + * @param \ArrayObject $update + * + * @return $this + */ + public function update(\ArrayObject $update) + { + $iterator = $update->getIterator(); + + while ($iterator->valid()) { + $this[$iterator->key()] = $iterator->current(); + $iterator->next(); + } + + return $this; + } + + /** + * Merge another result into this result. Data already + * existing in this result takes precedence over the + * data in the Result being merged. + * + * $data['message'] is handled specially, and is appended + * to $this->message if set. + * + * @param array $data + * + * @return array + */ + public function mergeData(array $data) + { + $mergedData = $this->getArrayCopy() + $data; + $this->exchangeArray($mergedData); + return $mergedData; + } + + /** + * @return bool + */ + public function hasExecutionTime() + { + return isset($this['time']); + } + + /** + * @return null|float + */ + public function getExecutionTime() + { + if (!$this->hasExecutionTime()) { + return null; + } + return $this['time']; + } + + /** + * Accumulate execution time + */ + public function accumulateExecutionTime($duration) + { + // Convert data arrays to scalar + if (is_array($duration)) { + $duration = isset($duration['time']) ? $duration['time'] : 0; + } + $this['time'] = $this->getExecutionTime() + $duration; + return $this->getExecutionTime(); + } + + /** + * Accumulate the message. + */ + public function accumulateMessage($message) + { + if (!empty($this->message)) { + $this->message .= "\n"; + } + $this->message .= $message; + return $this->getMessage(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/StateAwareInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/StateAwareInterface.php new file mode 100644 index 00000000..f86bccb8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/State/StateAwareInterface.php @@ -0,0 +1,30 @@ +state; + } + + /** + * {@inheritdoc} + */ + public function setState(Data $state) + { + $this->state = $state; + } + + /** + * {@inheritdoc} + */ + public function setStateValue($key, $value) + { + $this->state[$key] = $value; + } + + /** + * {@inheritdoc} + */ + public function updateState(Data $update) + { + $this->state->update($update); + } + + /** + * {@inheritdoc} + */ + public function resetState() + { + $this->state = new Data(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/ApiGen.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/ApiGen.php new file mode 100644 index 00000000..11ff764c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/ApiGen.php @@ -0,0 +1,518 @@ +taskApiGen('./vendor/apigen/apigen.phar') + * ->config('./apigen.neon') + * ->templateConfig('vendor/apigen/apigen/templates/bootstrap/config.neon') + * ->wipeout(true) + * ->run(); + * ?> + * ``` + */ +class ApiGen extends BaseTask implements CommandInterface +{ + use \Robo\Common\ExecOneCommand; + + const BOOL_NO = 'no'; + const BOOL_YES = 'yes'; + + /** + * @var string + */ + protected $command; + protected $operation = 'generate'; + + /** + * @param null|string $pathToApiGen + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToApiGen = null) + { + $this->command = $pathToApiGen; + $command_parts = []; + preg_match('/((?:.+)?apigen(?:\.phar)?) ?( \w+)? ?(.+)?/', $this->command, $command_parts); + if (count($command_parts) === 3) { + list(, $this->command, $this->operation) = $command_parts; + } + if (count($command_parts) === 4) { + list(, $this->command, $this->operation, $arg) = $command_parts; + $this->arg($arg); + } + if (!$this->command) { + $this->command = $this->findExecutablePhar('apigen'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "No apigen installation found"); + } + } + + /** + * Pass methods parameters as arguments to executable. Argument values + * are automatically escaped. + * + * @param string|string[] $args + * + * @return $this + */ + public function args($args) + { + if (!is_array($args)) { + $args = func_get_args(); + } + $args = array_map(function ($arg) { + if (preg_match('/^\w+$/', trim($arg)) === 1) { + $this->operation = $arg; + return null; + } + return $arg; + }, $args); + $args = array_filter($args); + $this->arguments .= ' ' . implode(' ', array_map('static::escape', $args)); + return $this; + } + + /** + * @param array|Traversable|string $arg a single object or something traversable + * + * @return array|Traversable the provided argument if it was already traversable, or the given + * argument returned as a one-element array + */ + protected static function forceTraversable($arg) + { + $traversable = $arg; + if (!is_array($traversable) && !($traversable instanceof \Traversable)) { + $traversable = array($traversable); + } + return $traversable; + } + + /** + * @param array|string $arg a single argument or an array of multiple string values + * + * @return string a comma-separated string of all of the provided arguments, suitable + * as a command-line "list" type argument for ApiGen + */ + protected static function asList($arg) + { + $normalized = is_array($arg) ? $arg : array($arg); + return implode(',', $normalized); + } + + /** + * @param bool|string $val an argument to be normalized + * @param string $default one of self::BOOL_YES or self::BOOK_NO if the provided + * value could not deterministically be converted to a + * yes or no value + * + * @return string the given value as a command-line "yes|no" type of argument for ApiGen, + * or the default value if none could be determined + */ + protected static function asTextBool($val, $default) + { + if ($val === self::BOOL_YES || $val === self::BOOL_NO) { + return $val; + } + if (!$val) { + return self::BOOL_NO; + } + if ($val === true) { + return self::BOOL_YES; + } + if (is_numeric($val) && $val != 0) { + return self::BOOL_YES; + } + if (strcasecmp($val[0], 'y') === 0) { + return self::BOOL_YES; + } + if (strcasecmp($val[0], 'n') === 0) { + return self::BOOL_NO; + } + // meh, good enough, let apigen sort it out + return $default; + } + + /** + * @param string $config + * + * @return $this + */ + public function config($config) + { + $this->option('config', $config); + return $this; + } + + /** + * @param array|string|Traversable $src one or more source values + * + * @return $this + */ + public function source($src) + { + foreach (self::forceTraversable($src) as $source) { + $this->option('source', $source); + } + return $this; + } + + /** + * @param string $dest + * + * @return $this + */ + public function destination($dest) + { + $this->option('destination', $dest); + return $this; + } + + /** + * @param array|string $exts one or more extensions + * + * @return $this + */ + public function extensions($exts) + { + $this->option('extensions', self::asList($exts)); + return $this; + } + + /** + * @param array|string $exclude one or more exclusions + * + * @return $this + */ + public function exclude($exclude) + { + foreach (self::forceTraversable($exclude) as $excl) { + $this->option('exclude', $excl); + } + return $this; + } + + /** + * @param array|string|Traversable $path one or more skip-doc-path values + * + * @return $this + */ + public function skipDocPath($path) + { + foreach (self::forceTraversable($path) as $skip) { + $this->option('skip-doc-path', $skip); + } + return $this; + } + + /** + * @param array|string|Traversable $prefix one or more skip-doc-prefix values + * + * @return $this + */ + public function skipDocPrefix($prefix) + { + foreach (self::forceTraversable($prefix) as $skip) { + $this->option('skip-doc-prefix', $skip); + } + return $this; + } + + /** + * @param array|string $charset one or more charsets + * + * @return $this + */ + public function charset($charset) + { + $this->option('charset', self::asList($charset)); + return $this; + } + + /** + * @param string $name + * + * @return $this + */ + public function mainProjectNamePrefix($name) + { + $this->option('main', $name); + return $this; + } + + /** + * @param string $title + * + * @return $this + */ + public function title($title) + { + $this->option('title', $title); + return $this; + } + + /** + * @param string $baseUrl + * + * @return $this + */ + public function baseUrl($baseUrl) + { + $this->option('base-url', $baseUrl); + return $this; + } + + /** + * @param string $id + * + * @return $this + */ + public function googleCseId($id) + { + $this->option('google-cse-id', $id); + return $this; + } + + /** + * @param string $trackingCode + * + * @return $this + */ + public function googleAnalytics($trackingCode) + { + $this->option('google-analytics', $trackingCode); + return $this; + } + + /** + * @param mixed $templateConfig + * + * @return $this + */ + public function templateConfig($templateConfig) + { + $this->option('template-config', $templateConfig); + return $this; + } + + /** + * @param array|string $tags one or more supported html tags + * + * @return $this + */ + public function allowedHtml($tags) + { + $this->option('allowed-html', self::asList($tags)); + return $this; + } + + /** + * @param string $groups + * + * @return $this + */ + public function groups($groups) + { + $this->option('groups', $groups); + return $this; + } + + /** + * @param array|string $types or more supported autocomplete types + * + * @return $this + */ + public function autocomplete($types) + { + $this->option('autocomplete', self::asList($types)); + return $this; + } + + /** + * @param array|string $levels one or more access levels + * + * @return $this + */ + public function accessLevels($levels) + { + $this->option('access-levels', self::asList($levels)); + return $this; + } + + /** + * @param boolean|string $internal 'yes' or true if internal, 'no' or false if not + * + * @return $this + */ + public function internal($internal) + { + $this->option('internal', self::asTextBool($internal, self::BOOL_NO)); + return $this; + } + + /** + * @param boolean|string $php 'yes' or true to generate documentation for internal php classes, + * 'no' or false otherwise + * + * @return $this + */ + public function php($php) + { + $this->option('php', self::asTextBool($php, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $tree 'yes' or true to generate a tree view of classes, 'no' or false otherwise + * + * @return $this + */ + public function tree($tree) + { + $this->option('tree', self::asTextBool($tree, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $dep 'yes' or true to generate documentation for deprecated classes, 'no' or false otherwise + * + * @return $this + */ + public function deprecated($dep) + { + $this->option('deprecated', self::asTextBool($dep, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $todo 'yes' or true to document tasks, 'no' or false otherwise + * + * @return $this + */ + public function todo($todo) + { + $this->option('todo', self::asTextBool($todo, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $src 'yes' or true to generate highlighted source code, 'no' or false otherwise + * + * @return $this + */ + public function sourceCode($src) + { + $this->option('source-code', self::asTextBool($src, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $zipped 'yes' or true to generate downloadable documentation, 'no' or false otherwise + * + * @return $this + */ + public function download($zipped) + { + $this->option('download', self::asTextBool($zipped, self::BOOL_NO)); + return $this; + } + + public function report($path) + { + $this->option('report', $path); + return $this; + } + + /** + * @param bool|string $wipeout 'yes' or true to clear out the destination directory, 'no' or false otherwise + * + * @return $this + */ + public function wipeout($wipeout) + { + $this->option('wipeout', self::asTextBool($wipeout, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $quiet 'yes' or true for quiet, 'no' or false otherwise + * + * @return $this + */ + public function quiet($quiet) + { + $this->option('quiet', self::asTextBool($quiet, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $bar 'yes' or true to display a progress bar, 'no' or false otherwise + * + * @return $this + */ + public function progressbar($bar) + { + $this->option('progressbar', self::asTextBool($bar, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $colors 'yes' or true colorize the output, 'no' or false otherwise + * + * @return $this + */ + public function colors($colors) + { + $this->option('colors', self::asTextBool($colors, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $check 'yes' or true to check for updates, 'no' or false otherwise + * + * @return $this + */ + public function updateCheck($check) + { + $this->option('update-check', self::asTextBool($check, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $debug 'yes' or true to enable debug mode, 'no' or false otherwise + * + * @return $this + */ + public function debug($debug) + { + $this->option('debug', self::asTextBool($debug, self::BOOL_NO)); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return "$this->command $this->operation$this->arguments"; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running ApiGen {args}', ['args' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/loadTasks.php new file mode 100644 index 00000000..e8cd372a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/ApiGen/loadTasks.php @@ -0,0 +1,15 @@ +task(ApiGen::class, $pathToApiGen); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Extract.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Extract.php new file mode 100644 index 00000000..a00a0baf --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Extract.php @@ -0,0 +1,279 @@ +taskExtract($archivePath) + * ->to($destination) + * ->preserveTopDirectory(false) // the default + * ->run(); + * ?> + * ``` + */ +class Extract extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $filename; + + /** + * @var string + */ + protected $to; + + /** + * @var bool + */ + private $preserveTopDirectory = false; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * Location to store extracted files. + * + * @param string $to + * + * @return $this + */ + public function to($to) + { + $this->to = $to; + return $this; + } + + /** + * @param bool $preserve + * + * @return $this + */ + public function preserveTopDirectory($preserve = true) + { + $this->preserveTopDirectory = $preserve; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!file_exists($this->filename)) { + $this->printTaskError("File {filename} does not exist", ['filename' => $this->filename]); + + return false; + } + if (!($mimetype = static::archiveType($this->filename))) { + $this->printTaskError("Could not determine type of archive for {filename}", ['filename' => $this->filename]); + + return false; + } + + // We will first extract to $extractLocation and then move to $this->to + $extractLocation = static::getTmpDir(); + @mkdir($extractLocation); + @mkdir(dirname($this->to)); + + $this->startTimer(); + + $this->printTaskInfo("Extracting {filename}", ['filename' => $this->filename]); + + $result = $this->extractAppropriateType($mimetype, $extractLocation); + if ($result->wasSuccessful()) { + $this->printTaskInfo("{filename} extracted", ['filename' => $this->filename]); + // Now, we want to move the extracted files to $this->to. There + // are two possibilities that we must consider: + // + // (1) Archived files were encapsulated in a folder with an arbitrary name + // (2) There was no encapsulating folder, and all the files in the archive + // were extracted into $extractLocation + // + // In the case of (1), we want to move and rename the encapsulating folder + // to $this->to. + // + // In the case of (2), we will just move and rename $extractLocation. + $filesInExtractLocation = glob("$extractLocation/*"); + $hasEncapsulatingFolder = ((count($filesInExtractLocation) == 1) && is_dir($filesInExtractLocation[0])); + if ($hasEncapsulatingFolder && !$this->preserveTopDirectory) { + $result = (new FilesystemStack()) + ->inflect($this) + ->rename($filesInExtractLocation[0], $this->to) + ->run(); + (new DeleteDir($extractLocation)) + ->inflect($this) + ->run(); + } else { + $result = (new FilesystemStack()) + ->inflect($this) + ->rename($extractLocation, $this->to) + ->run(); + } + } + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * @param string $mimetype + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractAppropriateType($mimetype, $extractLocation) + { + // Perform the extraction of a zip file. + if (($mimetype == 'application/zip') || ($mimetype == 'application/x-zip')) { + return $this->extractZip($extractLocation); + } + return $this->extractTar($extractLocation); + } + + /** + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractZip($extractLocation) + { + if (!extension_loaded('zlib')) { + return Result::errorMissingExtension($this, 'zlib', 'zip extracting'); + } + + $zip = new \ZipArchive(); + if (($status = $zip->open($this->filename)) !== true) { + return Result::error($this, "Could not open zip archive {$this->filename}"); + } + if (!$zip->extractTo($extractLocation)) { + return Result::error($this, "Could not extract zip archive {$this->filename}"); + } + $zip->close(); + + return Result::success($this); + } + + /** + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractTar($extractLocation) + { + if (!class_exists('Archive_Tar')) { + return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar'); + } + $tar_object = new \Archive_Tar($this->filename); + if (!$tar_object->extract($extractLocation)) { + return Result::error($this, "Could not extract tar archive {$this->filename}"); + } + + return Result::success($this); + } + + /** + * @param string $filename + * + * @return bool|string + */ + protected static function archiveType($filename) + { + $content_type = false; + if (class_exists('finfo')) { + $finfo = new \finfo(FILEINFO_MIME_TYPE); + $content_type = $finfo->file($filename); + // If finfo cannot determine the content type, then we will try other methods + if ($content_type == 'application/octet-stream') { + $content_type = false; + } + } + // Examing the file's magic header bytes. + if (!$content_type) { + if ($file = fopen($filename, 'rb')) { + $first = fread($file, 2); + fclose($file); + if ($first !== false) { + // Interpret the two bytes as a little endian 16-bit unsigned int. + $data = unpack('v', $first); + switch ($data[1]) { + case 0x8b1f: + // First two bytes of gzip files are 0x1f, 0x8b (little-endian). + // See http://www.gzip.org/zlib/rfc-gzip.html#header-trailer + $content_type = 'application/x-gzip'; + break; + + case 0x4b50: + // First two bytes of zip files are 0x50, 0x4b ('PK') (little-endian). + // See http://en.wikipedia.org/wiki/Zip_(file_format)#File_headers + $content_type = 'application/zip'; + break; + + case 0x5a42: + // First two bytes of bzip2 files are 0x5a, 0x42 ('BZ') (big-endian). + // See http://en.wikipedia.org/wiki/Bzip2#File_format + $content_type = 'application/x-bzip2'; + break; + } + } + } + } + // 3. Lastly if above methods didn't work, try to guess the mime type from + // the file extension. This is useful if the file has no identificable magic + // header bytes (for example tarballs). + if (!$content_type) { + // Remove querystring from the filename, if present. + $filename = basename(current(explode('?', $filename, 2))); + $extension_mimetype = array( + '.tar.gz' => 'application/x-gzip', + '.tgz' => 'application/x-gzip', + '.tar' => 'application/x-tar', + ); + foreach ($extension_mimetype as $extension => $ct) { + if (substr($filename, -strlen($extension)) === $extension) { + $content_type = $ct; + break; + } + } + } + + return $content_type; + } + + /** + * @return string + */ + protected static function getTmpDir() + { + return getcwd().'/tmp'.rand().time(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Pack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Pack.php new file mode 100644 index 00000000..0970f8e8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/Pack.php @@ -0,0 +1,257 @@ +taskPack( + * ) + * ->add('README') // Puts file 'README' in archive at the root + * ->add('project') // Puts entire contents of directory 'project' in archinve inside 'project' + * ->addFile('dir/file.txt', 'file.txt') // Takes 'file.txt' from cwd and puts it in archive inside 'dir'. + * ->run(); + * ?> + * ``` + */ +class Pack extends BaseTask implements PrintedInterface +{ + /** + * The list of items to be packed into the archive. + * + * @var array + */ + private $items = []; + + /** + * The full path to the archive to be created. + * + * @var string + */ + private $archiveFile; + + /** + * Construct the class. + * + * @param string $archiveFile The full path and name of the archive file to create. + * + * @since 1.0 + */ + public function __construct($archiveFile) + { + $this->archiveFile = $archiveFile; + } + + /** + * Satisfy the parent requirement. + * + * @return bool Always returns true. + * + * @since 1.0 + */ + public function getPrinted() + { + return true; + } + + /** + * @param string $archiveFile + * + * @return $this + */ + public function archiveFile($archiveFile) + { + $this->archiveFile = $archiveFile; + return $this; + } + + /** + * Add an item to the archive. Like file_exists(), the parameter + * may be a file or a directory. + * + * @var string + * Relative path and name of item to store in archive + * @var string + * Absolute or relative path to file or directory's location in filesystem + * + * @return $this + */ + public function addFile($placementLocation, $filesystemLocation) + { + $this->items[$placementLocation] = $filesystemLocation; + + return $this; + } + + /** + * Alias for addFile, in case anyone has angst about using + * addFile with a directory. + * + * @var string + * Relative path and name of directory to store in archive + * @var string + * Absolute or relative path to directory or directory's location in filesystem + * + * @return $this + */ + public function addDir($placementLocation, $filesystemLocation) + { + $this->addFile($placementLocation, $filesystemLocation); + + return $this; + } + + /** + * Add a file or directory, or list of same to the archive. + * + * @var string|array + * If given a string, should contain the relative filesystem path to the + * the item to store in archive; this will also be used as the item's + * path in the archive, so absolute paths should not be used here. + * If given an array, the key of each item should be the path to store + * in the archive, and the value should be the filesystem path to the + * item to store. + * @return $this + */ + public function add($item) + { + if (is_array($item)) { + $this->items = array_merge($this->items, $item); + } else { + $this->addFile($item, $item); + } + + return $this; + } + + /** + * Create a zip archive for distribution. + * + * @return \Robo\Result + * + * @since 1.0 + */ + public function run() + { + $this->startTimer(); + + // Use the file extension to determine what kind of archive to create. + $fileInfo = new \SplFileInfo($this->archiveFile); + $extension = strtolower($fileInfo->getExtension()); + if (empty($extension)) { + return Result::error($this, "Archive filename must use an extension (e.g. '.zip') to specify the kind of archive to create."); + } + + try { + // Inform the user which archive we are creating + $this->printTaskInfo("Creating archive {filename}", ['filename' => $this->archiveFile]); + if ($extension == 'zip') { + $result = $this->archiveZip($this->archiveFile, $this->items); + } else { + $result = $this->archiveTar($this->archiveFile, $this->items); + } + $this->printTaskSuccess("{filename} created.", ['filename' => $this->archiveFile]); + } catch (\Exception $e) { + $this->printTaskError("Could not create {filename}. {exception}", ['filename' => $this->archiveFile, 'exception' => $e->getMessage(), '_style' => ['exception' => '']]); + $result = Result::error($this, sprintf('Could not create %s. %s', $this->archiveFile, $e->getMessage())); + } + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * @param string $archiveFile + * @param array $items + * + * @return \Robo\Result + */ + protected function archiveTar($archiveFile, $items) + { + if (!class_exists('Archive_Tar')) { + return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar'); + } + + $tar_object = new \Archive_Tar($archiveFile); + foreach ($items as $placementLocation => $filesystemLocation) { + $p_remove_dir = $filesystemLocation; + $p_add_dir = $placementLocation; + if (is_file($filesystemLocation)) { + $p_remove_dir = dirname($filesystemLocation); + $p_add_dir = dirname($placementLocation); + if (basename($filesystemLocation) != basename($placementLocation)) { + return Result::error($this, "Tar archiver does not support renaming files during extraction; could not add $filesystemLocation as $placementLocation."); + } + } + + if (!$tar_object->addModify([$filesystemLocation], $p_add_dir, $p_remove_dir)) { + return Result::error($this, "Could not add $filesystemLocation to the archive."); + } + } + + return Result::success($this); + } + + /** + * @param string $archiveFile + * @param array $items + * + * @return \Robo\Result + */ + protected function archiveZip($archiveFile, $items) + { + if (!extension_loaded('zlib')) { + return Result::errorMissingExtension($this, 'zlib', 'zip packing'); + } + + $zip = new \ZipArchive($archiveFile, \ZipArchive::CREATE); + if (!$zip->open($archiveFile, \ZipArchive::CREATE)) { + return Result::error($this, "Could not create zip archive {$archiveFile}"); + } + $result = $this->addItemsToZip($zip, $items); + $zip->close(); + + return $result; + } + + /** + * @param \ZipArchive $zip + * @param array $items + * + * @return \Robo\Result + */ + protected function addItemsToZip($zip, $items) + { + foreach ($items as $placementLocation => $filesystemLocation) { + if (is_dir($filesystemLocation)) { + $finder = new Finder(); + $finder->files()->in($filesystemLocation)->ignoreDotFiles(false); + + foreach ($finder as $file) { + // Replace Windows slashes or resulting zip will have issues on *nixes. + $relativePathname = str_replace('\\', '/', $file->getRelativePathname()); + + if (!$zip->addFile($file->getRealpath(), "{$placementLocation}/{$relativePathname}")) { + return Result::error($this, "Could not add directory $filesystemLocation to the archive; error adding {$file->getRealpath()}."); + } + } + } elseif (is_file($filesystemLocation)) { + if (!$zip->addFile($filesystemLocation, $placementLocation)) { + return Result::error($this, "Could not add file $filesystemLocation to the archive."); + } + } else { + return Result::error($this, "Could not find $filesystemLocation for the archive."); + } + } + + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/loadTasks.php new file mode 100644 index 00000000..cf846fdf --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Archive/loadTasks.php @@ -0,0 +1,25 @@ +task(Pack::class, $filename); + } + + /** + * @param $filename + * + * @return Extract + */ + protected function taskExtract($filename) + { + return $this->task(Extract::class, $filename); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/CssPreprocessor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/CssPreprocessor.php new file mode 100644 index 00000000..a15d2078 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/CssPreprocessor.php @@ -0,0 +1,214 @@ +files = $input; + + $this->setDefaultCompiler(); + } + + protected function setDefaultCompiler() + { + if (isset($this->compilers[0])) { + //set first compiler as default + $this->compiler = $this->compilers[0]; + } + } + + /** + * Sets import directories + * Alias for setImportPaths + * @see CssPreprocessor::setImportPaths + * + * @param array|string $dirs + * + * @return $this + */ + public function importDir($dirs) + { + return $this->setImportPaths($dirs); + } + + /** + * Adds import directory + * + * @param string $dir + * + * @return $this + */ + public function addImportPath($dir) + { + if (!isset($this->compilerOptions['importDirs'])) { + $this->compilerOptions['importDirs'] = []; + } + + if (!in_array($dir, $this->compilerOptions['importDirs'], true)) { + $this->compilerOptions['importDirs'][] = $dir; + } + + return $this; + } + + /** + * Sets import directories + * + * @param array|string $dirs + * + * @return $this + */ + public function setImportPaths($dirs) + { + if (!is_array($dirs)) { + $dirs = [$dirs]; + } + + $this->compilerOptions['importDirs'] = $dirs; + + return $this; + } + + /** + * @param string $formatterName + * + * @return $this + */ + public function setFormatter($formatterName) + { + $this->compilerOptions['formatter'] = $formatterName; + + return $this; + } + + /** + * Sets the compiler. + * + * @param string $compiler + * @param array $options + * + * @return $this + */ + public function compiler($compiler, array $options = []) + { + $this->compiler = $compiler; + $this->compilerOptions = array_merge($this->compilerOptions, $options); + + return $this; + } + + /** + * Compiles file + * + * @param $file + * + * @return bool|mixed + */ + protected function compile($file) + { + if (is_callable($this->compiler)) { + return call_user_func($this->compiler, $file, $this->compilerOptions); + } + + if (method_exists($this, $this->compiler)) { + return $this->{$this->compiler}($file); + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!in_array($this->compiler, $this->compilers, true) + && !is_callable($this->compiler) + ) { + $message = sprintf('Invalid ' . static::FORMAT_NAME . ' compiler %s!', $this->compiler); + + return Result::error($this, $message); + } + + foreach ($this->files as $in => $out) { + if (!file_exists($in)) { + $message = sprintf('File %s not found.', $in); + + return Result::error($this, $message); + } + if (file_exists($out) && !is_writable($out)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + } + + foreach ($this->files as $in => $out) { + $css = $this->compile($in); + + if ($css instanceof Result) { + return $css; + } elseif (false === $css) { + $message = sprintf( + ucfirst(static::FORMAT_NAME) . ' compilation failed for %s.', + $in + ); + + return Result::error($this, $message); + } + + $dst = $out . '.part'; + $write_result = file_put_contents($dst, $css); + + if (false === $write_result) { + $message = sprintf('File write failed: %s', $out); + + @unlink($dst); + return Result::error($this, $message); + } + + // Cannot be cross-volume: should always succeed + @rename($dst, $out); + + $this->printTaskSuccess('Wrote CSS to {filename}', ['filename' => $out]); + } + + return Result::success($this, 'All ' . static::FORMAT_NAME . ' files compiled.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/ImageMinify.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/ImageMinify.php new file mode 100644 index 00000000..1aa62593 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/ImageMinify.php @@ -0,0 +1,716 @@ +taskImageMinify('assets/images/*') + * ->to('dist/images/') + * ->run(); + * ``` + * + * This will use the following minifiers: + * + * - PNG: optipng + * - GIF: gifsicle + * - JPG, JPEG: jpegtran + * - SVG: svgo + * + * When the minifier is specified the task will use that for all the input files. In that case + * it is useful to filter the files with the extension: + * + * ```php + * $this->taskImageMinify('assets/images/*.png') + * ->to('dist/images/') + * ->minifier('pngcrush'); + * ->run(); + * ``` + * + * The task supports the following minifiers: + * + * - optipng + * - pngquant + * - advpng + * - pngout + * - zopflipng + * - pngcrush + * - gifsicle + * - jpegoptim + * - jpeg-recompress + * - jpegtran + * - svgo (only minification, no downloading) + * + * You can also specifiy extra options for the minifiers: + * + * ```php + * $this->taskImageMinify('assets/images/*.jpg') + * ->to('dist/images/') + * ->minifier('jpegtran', ['-progressive' => null, '-copy' => 'none']) + * ->run(); + * ``` + * + * This will execute as: + * `jpegtran -copy none -progressive -optimize -outfile "dist/images/test.jpg" "/var/www/test/assets/images/test.jpg"` + */ +class ImageMinify extends BaseTask +{ + /** + * Destination directory for the minified images. + * + * @var string + */ + protected $to; + + /** + * Array of the source files. + * + * @var array + */ + protected $dirs = []; + + /** + * Symfony 2 filesystem. + * + * @var sfFilesystem + */ + protected $fs; + + /** + * Target directory for the downloaded binary executables. + * + * @var string + */ + protected $executableTargetDir; + + /** + * Array for the downloaded binary executables. + * + * @var array + */ + protected $executablePaths = []; + + /** + * Array for the individual results of all the files. + * + * @var array + */ + protected $results = []; + + /** + * Default minifier to use. + * + * @var string + */ + protected $minifier; + + /** + * Array for minifier options. + * + * @var array + */ + protected $minifierOptions = []; + + /** + * Supported minifiers. + * + * @var array + */ + protected $minifiers = [ + // Default 4 + 'optipng', + 'gifsicle', + 'jpegtran', + 'svgo', + // PNG + 'pngquant', + 'advpng', + 'pngout', + 'zopflipng', + 'pngcrush', + // JPG + 'jpegoptim', + 'jpeg-recompress', + ]; + + /** + * Binary repositories of Imagemin. + * + * @link https://github.com/imagemin + * + * @var array + */ + protected $imageminRepos = [ + // PNG + 'optipng' => 'https://github.com/imagemin/optipng-bin', + 'pngquant' => 'https://github.com/imagemin/pngquant-bin', + 'advpng' => 'https://github.com/imagemin/advpng-bin', + 'pngout' => 'https://github.com/imagemin/pngout-bin', + 'zopflipng' => 'https://github.com/imagemin/zopflipng-bin', + 'pngcrush' => 'https://github.com/imagemin/pngcrush-bin', + // Gif + 'gifsicle' => 'https://github.com/imagemin/gifsicle-bin', + // JPG + 'jpegtran' => 'https://github.com/imagemin/jpegtran-bin', + 'jpegoptim' => 'https://github.com/imagemin/jpegoptim-bin', + 'cjpeg' => 'https://github.com/imagemin/mozjpeg-bin', // note: we do not support this minifier because it creates JPG from non-JPG files + 'jpeg-recompress' => 'https://github.com/imagemin/jpeg-recompress-bin', + // WebP + 'cwebp' => 'https://github.com/imagemin/cwebp-bin', // note: we do not support this minifier because it creates WebP from non-WebP files + ]; + + public function __construct($dirs) + { + is_array($dirs) + ? $this->dirs = $dirs + : $this->dirs[] = $dirs; + + $this->fs = new sfFilesystem(); + + // guess the best path for the executables based on __DIR__ + if (($pos = strpos(__DIR__, 'consolidation/robo')) !== false) { + // the executables should be stored in vendor/bin + $this->executableTargetDir = substr(__DIR__, 0, $pos).'bin'; + } + + // check if the executables are already available + foreach ($this->imageminRepos as $exec => $url) { + $path = $this->executableTargetDir.'/'.$exec; + // if this is Windows add a .exe extension + if (substr($this->getOS(), 0, 3) == 'win') { + $path .= '.exe'; + } + if (is_file($path)) { + $this->executablePaths[$exec] = $path; + } + } + } + + /** + * {@inheritdoc} + */ + public function run() + { + // find the files + $files = $this->findFiles($this->dirs); + + // minify the files + $result = $this->minify($files); + // check if there was an error + if ($result instanceof Result) { + return $result; + } + + $amount = (count($files) == 1 ? 'image' : 'images'); + $message = "Minified {filecount} out of {filetotal} $amount into {destination}"; + $context = ['filecount' => count($this->results['success']), 'filetotal' => count($files), 'destination' => $this->to]; + + if (count($this->results['success']) == count($files)) { + $this->printTaskSuccess($message, $context); + + return Result::success($this, $message, $context); + } else { + return Result::error($this, $message, $context); + } + } + + /** + * Sets the target directory where the files will be copied to. + * + * @param string $target + * + * @return $this + */ + public function to($target) + { + $this->to = rtrim($target, '/'); + + return $this; + } + + /** + * Sets the minifier. + * + * @param string $minifier + * @param array $options + * + * @return $this + */ + public function minifier($minifier, array $options = []) + { + $this->minifier = $minifier; + $this->minifierOptions = array_merge($this->minifierOptions, $options); + + return $this; + } + + /** + * @param array $dirs + * + * @return array|\Robo\Result + * + * @throws \Robo\Exception\TaskException + */ + protected function findFiles($dirs) + { + $files = array(); + + // find the files + foreach ($dirs as $k => $v) { + // reset finder + $finder = new Finder(); + + $dir = $k; + $to = $v; + // check if target was given with the to() method instead of key/value pairs + if (is_int($k)) { + $dir = $v; + if (isset($this->to)) { + $to = $this->to; + } else { + throw new TaskException($this, 'target directory is not defined'); + } + } + + try { + $finder->files()->in($dir); + } catch (\InvalidArgumentException $e) { + // if finder cannot handle it, try with in()->name() + if (strpos($dir, '/') === false) { + $dir = './'.$dir; + } + $parts = explode('/', $dir); + $new_dir = implode('/', array_slice($parts, 0, -1)); + try { + $finder->files()->in($new_dir)->name(array_pop($parts)); + } catch (\InvalidArgumentException $e) { + return Result::fromException($this, $e); + } + } + + foreach ($finder as $file) { + // store the absolute path as key and target as value in the files array + $files[$file->getRealpath()] = $this->getTarget($file->getRealPath(), $to); + } + $fileNoun = count($finder) == 1 ? ' file' : ' files'; + $this->printTaskInfo("Found {filecount} $fileNoun in {dir}", ['filecount' => count($finder), 'dir' => $dir]); + } + + return $files; + } + + /** + * @param string $file + * @param string $to + * + * @return string + */ + protected function getTarget($file, $to) + { + $target = $to.'/'.basename($file); + + return $target; + } + + /** + * @param array $files + * + * @return \Robo\Result + */ + protected function minify($files) + { + // store the individual results into the results array + $this->results = [ + 'success' => [], + 'error' => [], + ]; + + // loop through the files + foreach ($files as $from => $to) { + if (!isset($this->minifier)) { + // check filetype based on the extension + $extension = strtolower(pathinfo($from, PATHINFO_EXTENSION)); + + // set the default minifiers based on the extension + switch ($extension) { + case 'png': + $minifier = 'optipng'; + break; + case 'jpg': + case 'jpeg': + $minifier = 'jpegtran'; + break; + case 'gif': + $minifier = 'gifsicle'; + break; + case 'svg': + $minifier = 'svgo'; + break; + } + } else { + if (!in_array($this->minifier, $this->minifiers, true) + && !is_callable(strtr($this->minifier, '-', '_')) + ) { + $message = sprintf('Invalid minifier %s!', $this->minifier); + + return Result::error($this, $message); + } + $minifier = $this->minifier; + } + + // Convert minifier name to camelCase (e.g. jpeg-recompress) + $funcMinifier = $this->camelCase($minifier); + + // call the minifier method which prepares the command + if (is_callable($funcMinifier)) { + $command = call_user_func($funcMinifier, $from, $to, $this->minifierOptions); + } elseif (method_exists($this, $funcMinifier)) { + $command = $this->{$funcMinifier}($from, $to); + } else { + $message = sprintf('Minifier method %s cannot be found!', $funcMinifier); + + return Result::error($this, $message); + } + + // launch the command + $this->printTaskInfo('Minifying {filepath} with {minifier}', ['filepath' => $from, 'minifier' => $minifier]); + $result = $this->executeCommand($command); + + // check the return code + if ($result->getExitCode() == 127) { + $this->printTaskError('The {minifier} executable cannot be found', ['minifier' => $minifier]); + // try to install from imagemin repository + if (array_key_exists($minifier, $this->imageminRepos)) { + $result = $this->installFromImagemin($minifier); + if ($result instanceof Result) { + if ($result->wasSuccessful()) { + $this->printTaskSuccess($result->getMessage()); + // retry the conversion with the downloaded executable + if (is_callable($minifier)) { + $command = call_user_func($minifier, $from, $to, $minifierOptions); + } elseif (method_exists($this, $minifier)) { + $command = $this->{$minifier}($from, $to); + } + // launch the command + $this->printTaskInfo('Minifying {filepath} with {minifier}', ['filepath' => $from, 'minifier' => $minifier]); + $result = $this->executeCommand($command); + } else { + $this->printTaskError($result->getMessage()); + // the download was not successful + return $result; + } + } + } else { + return $result; + } + } + + // check the success of the conversion + if ($result->getExitCode() !== 0) { + $this->results['error'][] = $from; + } else { + $this->results['success'][] = $from; + } + } + } + + /** + * @return string + */ + protected function getOS() + { + $os = php_uname('s'); + $os .= '/'.php_uname('m'); + // replace x86_64 to x64, because the imagemin repo uses that + $os = str_replace('x86_64', 'x64', $os); + // replace i386, i686, etc to x86, because of imagemin + $os = preg_replace('/i[0-9]86/', 'x86', $os); + // turn info to lowercase, because of imagemin + $os = strtolower($os); + + return $os; + } + + /** + * @param string $command + * + * @return \Robo\Result + */ + protected function executeCommand($command) + { + // insert the options into the command + $a = explode(' ', $command); + $executable = array_shift($a); + foreach ($this->minifierOptions as $key => $value) { + // first prepend the value + if (!empty($value)) { + array_unshift($a, $value); + } + // then add the key + if (!is_numeric($key)) { + array_unshift($a, $key); + } + } + // check if the executable can be replaced with the downloaded one + if (array_key_exists($executable, $this->executablePaths)) { + $executable = $this->executablePaths[$executable]; + } + array_unshift($a, $executable); + $command = implode(' ', $a); + + // execute the command + $exec = new Exec($command); + + return $exec->inflect($this)->printed(false)->run(); + } + + /** + * @param string $executable + * + * @return \Robo\Result + */ + protected function installFromImagemin($executable) + { + // check if there is an url defined for the executable + if (!array_key_exists($executable, $this->imageminRepos)) { + $message = sprintf('The executable %s cannot be found in the defined imagemin repositories', $executable); + + return Result::error($this, $message); + } + $this->printTaskInfo('Downloading the {executable} executable from the imagemin repository', ['executable' => $executable]); + + $os = $this->getOS(); + $url = $this->imageminRepos[$executable].'/blob/master/vendor/'.$os.'/'.$executable.'?raw=true'; + if (substr($os, 0, 3) == 'win') { + // if it is win, add a .exe extension + $url = $this->imageminRepos[$executable].'/blob/master/vendor/'.$os.'/'.$executable.'.exe?raw=true'; + } + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is something wrong with the url, try it without the version info + $url = preg_replace('/x[68][64]\//', '', $url); + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is still something wrong with the url if it is win, try with win32 + if (substr($os, 0, 3) == 'win') { + $url = preg_replace('win/', 'win32/', $url); + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is nothing more we can do + $message = sprintf('Could not download the executable %s', $executable); + + return Result::error($this, $message); + } + } + // if it is not windows there is nothing we can do + $message = sprintf('Could not download the executable %s', $executable); + + return Result::error($this, $message); + } + } + // check if target directory exists + if (!is_dir($this->executableTargetDir)) { + mkdir($this->executableTargetDir); + } + // save the executable into the target dir + $path = $this->executableTargetDir.'/'.$executable; + if (substr($os, 0, 3) == 'win') { + // if it is win, add a .exe extension + $path = $this->executableTargetDir.'/'.$executable.'.exe'; + } + $result = file_put_contents($path, $data); + if ($result === false) { + $message = sprintf('Could not copy the executable %s to %s', $executable, $target_dir); + + return Result::error($this, $message); + } + // set the binary to executable + chmod($path, 0755); + + // if everything successful, store the executable path + $this->executablePaths[$executable] = $this->executableTargetDir.'/'.$executable; + // if it is win, add a .exe extension + if (substr($os, 0, 3) == 'win') { + $this->executablePaths[$executable] .= '.exe'; + } + + $message = sprintf('Executable %s successfully downloaded', $executable); + + return Result::success($this, $message); + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function optipng($from, $to) + { + $command = sprintf('optipng -quiet -out "%s" -- "%s"', $to, $from); + if ($from != $to && is_file($to)) { + // earlier versions of optipng do not overwrite the target without a backup + // http://sourceforge.net/p/optipng/bugs/37/ + unlink($to); + } + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegtran($from, $to) + { + $command = sprintf('jpegtran -optimize -outfile "%s" "%s"', $to, $from); + + return $command; + } + + protected function gifsicle($from, $to) + { + $command = sprintf('gifsicle -o "%s" "%s"', $to, $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function svgo($from, $to) + { + $command = sprintf('svgo "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngquant($from, $to) + { + $command = sprintf('pngquant --force --output "%s" "%s"', $to, $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function advpng($from, $to) + { + // advpng does not have any output parameters, copy the file and then compress the copy + $command = sprintf('advpng --recompress --quiet "%s"', $to); + $this->fs->copy($from, $to, true); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngout($from, $to) + { + $command = sprintf('pngout -y -q "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function zopflipng($from, $to) + { + $command = sprintf('zopflipng -y "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngcrush($from, $to) + { + $command = sprintf('pngcrush -q -ow "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegoptim($from, $to) + { + // jpegoptim only takes the destination directory as an argument + $command = sprintf('jpegoptim --quiet -o --dest "%s" "%s"', dirname($to), $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegRecompress($from, $to) + { + $command = sprintf('jpeg-recompress --quiet "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $text + * + * @return string + */ + public static function camelCase($text) + { + // non-alpha and non-numeric characters become spaces + $text = preg_replace('/[^a-z0-9]+/i', ' ', $text); + $text = trim($text); + // uppercase the first character of each word + $text = ucwords($text); + $text = str_replace(" ", "", $text); + $text = lcfirst($text); + + return $text; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Less.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Less.php new file mode 100644 index 00000000..4cfa0978 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Less.php @@ -0,0 +1,108 @@ +taskLess([ + * 'less/default.less' => 'css/default.css' + * ]) + * ->run(); + * ?> + * ``` + * + * Use one of both less compilers in your project: + * + * ``` + * "leafo/lessphp": "~0.5", + * "oyejorge/less.php": "~1.5" + * ``` + * + * Specify directory (string or array) for less imports lookup: + * + * ```php + * taskLess([ + * 'less/default.less' => 'css/default.css' + * ]) + * ->importDir('less') + * ->compiler('lessphp') + * ->run(); + * ?> + * ``` + * + * You can implement additional compilers by extending this task and adding a + * method named after them and overloading the lessCompilers() method to + * inject the name there. + */ +class Less extends CssPreprocessor +{ + const FORMAT_NAME = 'less'; + + /** + * @var string[] + */ + protected $compilers = [ + 'less', // https://github.com/oyejorge/less.php + 'lessphp', //https://github.com/leafo/lessphp + ]; + + /** + * lessphp compiler + * @link https://github.com/leafo/lessphp + * + * @param string $file + * + * @return string + */ + protected function lessphp($file) + { + if (!class_exists('\lessc')) { + return Result::errorMissingPackage($this, 'lessc', 'leafo/lessphp'); + } + + $lessCode = file_get_contents($file); + + $less = new \lessc(); + if (isset($this->compilerOptions['importDirs'])) { + $less->setImportDir($this->compilerOptions['importDirs']); + } + + return $less->compile($lessCode); + } + + /** + * less compiler + * @link https://github.com/oyejorge/less.php + * + * @param string $file + * + * @return string + */ + protected function less($file) + { + if (!class_exists('\Less_Parser')) { + return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php'); + } + + $lessCode = file_get_contents($file); + + $parser = new \Less_Parser(); + $parser->SetOptions($this->compilerOptions); + if (isset($this->compilerOptions['importDirs'])) { + $importDirs = []; + foreach ($this->compilerOptions['importDirs'] as $dir) { + $importDirs[$dir] = $dir; + } + $parser->SetImportDirs($importDirs); + } + + $parser->parse($lessCode); + + return $parser->getCss(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Minify.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Minify.php new file mode 100644 index 00000000..3187714e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Minify.php @@ -0,0 +1,297 @@ +taskMinify( 'web/assets/theme.css' ) + * ->run() + * ?> + * ``` + * Please install additional dependencies to use: + * + * ``` + * "patchwork/jsqueeze": "~1.0", + * "natxet/CssMin": "~3.0" + * ``` + */ +class Minify extends BaseTask +{ + /** + * @var array + */ + protected $types = ['css', 'js']; + + /** + * @var string + */ + protected $text; + + /** + * @var string + */ + protected $dst; + + /** + * @var string + */ + protected $type; + + /** + * @var array + */ + protected $squeezeOptions = [ + 'singleLine' => true, + 'keepImportantComments' => true, + 'specialVarRx' => false, + ]; + + /** + * Constructor. Accepts asset file path or string source. + * + * @param string $input + */ + public function __construct($input) + { + if (file_exists($input)) { + $this->fromFile($input); + return; + } + + $this->fromText($input); + } + + /** + * Sets destination. Tries to guess type from it. + * + * @param string $dst + * + * @return $this + */ + public function to($dst) + { + $this->dst = $dst; + + if (!empty($this->dst) && empty($this->type)) { + $this->type($this->getExtension($this->dst)); + } + + return $this; + } + + /** + * Sets type with validation. + * + * @param string $type css|js + * + * @return $this + */ + public function type($type) + { + $type = strtolower($type); + + if (in_array($type, $this->types)) { + $this->type = $type; + } + + return $this; + } + + /** + * Sets text from string source. + * + * @param string $text + * + * @return $this + */ + protected function fromText($text) + { + $this->text = (string)$text; + unset($this->type); + + return $this; + } + + /** + * Sets text from asset file path. Tries to guess type and set default destination. + * + * @param string $path + * + * @return $this + */ + protected function fromFile($path) + { + $this->text = file_get_contents($path); + + unset($this->type); + $this->type($this->getExtension($path)); + + if (empty($this->dst) && !empty($this->type)) { + $ext_length = strlen($this->type) + 1; + $this->dst = substr($path, 0, -$ext_length) . '.min.' . $this->type; + } + + return $this; + } + + /** + * Gets file extension from path. + * + * @param string $path + * + * @return string + */ + protected function getExtension($path) + { + return pathinfo($path, PATHINFO_EXTENSION); + } + + /** + * Minifies and returns text. + * + * @return string|bool + */ + protected function getMinifiedText() + { + switch ($this->type) { + case 'css': + if (!class_exists('\CssMin')) { + return Result::errorMissingPackage($this, 'CssMin', 'natxet/CssMin'); + } + + return \CssMin::minify($this->text); + break; + + case 'js': + if (!class_exists('\JSqueeze') && !class_exists('\Patchwork\JSqueeze')) { + return Result::errorMissingPackage($this, 'Patchwork\JSqueeze', 'patchwork/jsqueeze'); + } + + if (class_exists('\JSqueeze')) { + $jsqueeze = new \JSqueeze(); + } else { + $jsqueeze = new \Patchwork\JSqueeze(); + } + + return $jsqueeze->squeeze( + $this->text, + $this->squeezeOptions['singleLine'], + $this->squeezeOptions['keepImportantComments'], + $this->squeezeOptions['specialVarRx'] + ); + break; + } + + return false; + } + + /** + * Single line option for the JS minimisation. + * + * @param bool $singleLine + * + * @return $this + */ + public function singleLine($singleLine) + { + $this->squeezeOptions['singleLine'] = (bool)$singleLine; + return $this; + } + + /** + * keepImportantComments option for the JS minimisation. + * + * @param bool $keepImportantComments + * + * @return $this + */ + public function keepImportantComments($keepImportantComments) + { + $this->squeezeOptions['keepImportantComments'] = (bool)$keepImportantComments; + return $this; + } + + /** + * specialVarRx option for the JS minimisation. + * + * @param bool $specialVarRx + * + * @return $this ; + */ + public function specialVarRx($specialVarRx) + { + $this->squeezeOptions['specialVarRx'] = (bool)$specialVarRx; + return $this; + } + + /** + * @return string + */ + public function __toString() + { + return (string) $this->getMinifiedText(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->type)) { + return Result::error($this, 'Unknown asset type.'); + } + + if (empty($this->dst)) { + return Result::error($this, 'Unknown file destination.'); + } + + if (file_exists($this->dst) && !is_writable($this->dst)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + + $size_before = strlen($this->text); + $minified = $this->getMinifiedText(); + + if ($minified instanceof Result) { + return $minified; + } elseif (false === $minified) { + return Result::error($this, 'Minification failed.'); + } + + $size_after = strlen($minified); + + // Minification did not reduce file size, so use original file. + if ($size_after > $size_before) { + $minified = $this->text; + $size_after = $size_before; + } + + $dst = $this->dst . '.part'; + $write_result = file_put_contents($dst, $minified); + + if (false === $write_result) { + @unlink($dst); + return Result::error($this, 'File write failed.'); + } + // Cannot be cross-volume; should always succeed. + @rename($dst, $this->dst); + if ($size_before === 0) { + $minified_percent = 0; + } else { + $minified_percent = number_format(100 - ($size_after / $size_before * 100), 1); + } + $this->printTaskSuccess('Wrote {filepath}', ['filepath' => $this->dst]); + $context = [ + 'bytes' => $this->formatBytes($size_after), + 'reduction' => $this->formatBytes(($size_before - $size_after)), + 'percentage' => $minified_percent, + ]; + $this->printTaskSuccess('Wrote {bytes} (reduced by {reduction} / {percentage})', $context); + return Result::success($this, 'Asset minified.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Scss.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Scss.php new file mode 100644 index 00000000..ffd39345 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/Scss.php @@ -0,0 +1,93 @@ +taskScss([ + * 'scss/default.scss' => 'css/default.css' + * ]) + * ->importDir('assets/styles') + * ->run(); + * ?> + * ``` + * + * Use the following scss compiler in your project: + * + * ``` + * "leafo/scssphp": "~0.1", + * ``` + * + * You can implement additional compilers by extending this task and adding a + * method named after them and overloading the scssCompilers() method to + * inject the name there. + */ +class Scss extends CssPreprocessor +{ + const FORMAT_NAME = 'scss'; + + /** + * @var string[] + */ + protected $compilers = [ + 'scssphp', // https://github.com/leafo/scssphp + ]; + + /** + * scssphp compiler + * @link https://github.com/leafo/scssphp + * + * @param string $file + * + * @return string + */ + protected function scssphp($file) + { + if (!class_exists('\Leafo\ScssPhp\Compiler')) { + return Result::errorMissingPackage($this, 'scssphp', 'leafo/scssphp'); + } + + $scssCode = file_get_contents($file); + $scss = new \Leafo\ScssPhp\Compiler(); + + // set options for the scssphp compiler + if (isset($this->compilerOptions['importDirs'])) { + $scss->setImportPaths($this->compilerOptions['importDirs']); + } + + if (isset($this->compilerOptions['formatter'])) { + $scss->setFormatter($this->compilerOptions['formatter']); + } + + return $scss->compile($scssCode); + } + + /** + * Sets the formatter for scssphp + * + * The method setFormatter($formatterName) sets the current formatter to $formatterName, + * the name of a class as a string that implements the formatting interface. See the source + * for Leafo\ScssPhp\Formatter\Expanded for an example. + * + * Five formatters are included with leafo/scssphp: + * - Leafo\ScssPhp\Formatter\Expanded + * - Leafo\ScssPhp\Formatter\Nested (default) + * - Leafo\ScssPhp\Formatter\Compressed + * - Leafo\ScssPhp\Formatter\Compact + * - Leafo\ScssPhp\Formatter\Crunched + * + * @link http://leafo.github.io/scssphp/docs/#output-formatting + * + * @param string $formatterName + * + * @return $this + */ + public function setFormatter($formatterName) + { + return parent::setFormatter($formatterName); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/loadTasks.php new file mode 100644 index 00000000..12192dd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Assets/loadTasks.php @@ -0,0 +1,45 @@ +task(Minify::class, $input); + } + + /** + * @param string|string[] $input + * + * @return \Robo\Task\Assets\ImageMinify + */ + protected function taskImageMinify($input) + { + return $this->task(ImageMinify::class, $input); + } + + /** + * @param array $input + * + * @return \Robo\Task\Assets\Less + */ + protected function taskLess($input) + { + return $this->task(Less::class, $input); + } + + /** + * @param array $input + * + * @return \Robo\Task\Assets\Scss + */ + protected function taskScss($input) + { + return $this->task(Scss::class, $input); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Exec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Exec.php new file mode 100644 index 00000000..c3e47917 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Exec.php @@ -0,0 +1,125 @@ +taskExec('compass')->arg('watch')->run(); + * // or use shortcut + * $this->_exec('compass watch'); + * + * $this->taskExec('compass watch')->background()->run(); + * + * if ($this->taskExec('phpunit .')->run()->wasSuccessful()) { + * $this->say('tests passed'); + * } + * + * ?> + * ``` + */ +class Exec extends BaseTask implements CommandInterface, PrintedInterface, SimulatedInterface +{ + use \Robo\Common\CommandReceiver; + use \Robo\Common\ExecOneCommand; + + /** + * @var static[] + */ + protected static $instances = []; + + /** + * @var string|\Robo\Contract\CommandInterface + */ + protected $command; + + /** + * @param string|\Robo\Contract\CommandInterface $command + */ + public function __construct($command) + { + $this->command = $this->receiveCommand($command); + } + + /** + * + */ + public function __destruct() + { + $this->stop(); + } + + /** + * Executes command in background mode (asynchronously) + * + * @return $this + */ + public function background($arg = true) + { + self::$instances[] = $this; + $this->background = $arg; + return $this; + } + + /** + * {@inheritdoc} + */ + protected function getCommandDescription() + { + return $this->getCommand(); + } + /** + * {@inheritdoc} + */ + public function getCommand() + { + return trim($this->command . $this->arguments); + } + + /** + * {@inheritdoc} + */ + public function simulate($context) + { + $this->printAction($context); + } + + public static function stopRunningJobs() + { + foreach (self::$instances as $instance) { + if ($instance) { + unset($instance); + } + } + } + + /** + * {@inheritdoc} + */ + public function run() + { + // TODO: Symfony 4 requires that we supply the working directory. + $result_data = $this->execute(new Process($this->getCommand(), getcwd())); + return new Result( + $this, + $result_data->getExitCode(), + $result_data->getMessage(), + $result_data->getData() + ); + } +} + +if (function_exists('pcntl_signal')) { + pcntl_signal(SIGTERM, ['Robo\Task\Base\Exec', 'stopRunningJobs']); +} + +register_shutdown_function(['Robo\Task\Base\Exec', 'stopRunningJobs']); diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ExecStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ExecStack.php new file mode 100644 index 00000000..51b39ef1 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ExecStack.php @@ -0,0 +1,23 @@ +taskExecStack() + * ->stopOnFail() + * ->exec('mkdir site') + * ->exec('cd site') + * ->run(); + * + * ?> + * ``` + */ +class ExecStack extends CommandStack +{ +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ParallelExec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ParallelExec.php new file mode 100644 index 00000000..c98b7841 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/ParallelExec.php @@ -0,0 +1,199 @@ +taskParallelExec() + * ->process('php ~/demos/script.php hey') + * ->process('php ~/demos/script.php hoy') + * ->process('php ~/demos/script.php gou') + * ->run(); + * ?> + * ``` + */ +class ParallelExec extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\CommandReceiver; + + /** + * @var Process[] + */ + protected $processes = []; + + /** + * @var null|int + */ + protected $timeout = null; + + /** + * @var null|int + */ + protected $idleTimeout = null; + + /** + * @var null|int + */ + protected $waitInterval = 0; + + /** + * @var bool + */ + protected $isPrinted = false; + + /** + * {@inheritdoc} + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * @param bool $isPrinted + * + * @return $this + */ + public function printed($isPrinted = true) + { + $this->isPrinted = $isPrinted; + return $this; + } + + /** + * @param string|\Robo\Contract\CommandInterface $command + * + * @return $this + */ + public function process($command) + { + // TODO: Symfony 4 requires that we supply the working directory. + $this->processes[] = new Process($this->receiveCommand($command), getcwd()); + return $this; + } + + /** + * Stops process if it runs longer then `$timeout` (seconds). + * + * @param int $timeout + * + * @return $this + */ + public function timeout($timeout) + { + $this->timeout = $timeout; + return $this; + } + + /** + * Stops process if it does not output for time longer then `$timeout` (seconds). + * + * @param int $idleTimeout + * + * @return $this + */ + public function idleTimeout($idleTimeout) + { + $this->idleTimeout = $idleTimeout; + return $this; + } + + /** + * Parallel processing will wait `$waitInterval` seconds after launching each process and before + * the next one. + * + * @param int $waitInterval + * + * @return $this + */ + public function waitInterval($waitInterval) + { + $this->waitInterval = $waitInterval; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return implode(' && ', $this->processes); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + return count($this->processes); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->startProgressIndicator(); + $running = []; + $queue = $this->processes; + $nextTime = time(); + while (true) { + if (($nextTime <= time()) && !empty($queue)) { + $process = array_shift($queue); + $process->setIdleTimeout($this->idleTimeout); + $process->setTimeout($this->timeout); + $process->start(); + $this->printTaskInfo($process->getCommandLine()); + $running[] = $process; + $nextTime = time() + $this->waitInterval; + } + foreach ($running as $k => $process) { + try { + $process->checkTimeout(); + } catch (ProcessTimedOutException $e) { + $this->printTaskWarning("Process timed out for {command}", ['command' => $process->getCommandLine(), '_style' => ['command' => 'fg=white;bg=magenta']]); + } + if (!$process->isRunning()) { + $this->advanceProgressIndicator(); + if ($this->isPrinted) { + $this->printTaskInfo("Output for {command}:\n\n{output}", ['command' => $process->getCommandLine(), 'output' => $process->getOutput(), '_style' => ['command' => 'fg=white;bg=magenta']]); + $errorOutput = $process->getErrorOutput(); + if ($errorOutput) { + $this->printTaskError(rtrim($errorOutput)); + } + } + unset($running[$k]); + } + } + if (empty($running) && empty($queue)) { + break; + } + usleep(1000); + } + $this->stopProgressIndicator(); + + $errorMessage = ''; + $exitCode = 0; + foreach ($this->processes as $p) { + if ($p->getExitCode() === 0) { + continue; + } + $errorMessage .= "'" . $p->getCommandLine() . "' exited with code ". $p->getExitCode()." \n"; + $exitCode = max($exitCode, $p->getExitCode()); + } + if (!$errorMessage) { + $this->printTaskSuccess('{process-count} processes finished running', ['process-count' => count($this->processes)]); + } + + return new Result($this, $exitCode, $errorMessage, ['time' => $this->getExecutionTime()]); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/SymfonyCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/SymfonyCommand.php new file mode 100644 index 00000000..708ea845 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/SymfonyCommand.php @@ -0,0 +1,75 @@ +taskSymfonyCommand(new \Codeception\Command\Run('run')) + * ->arg('suite','acceptance') + * ->opt('debug') + * ->run(); + * + * // Artisan Command + * $this->taskSymfonyCommand(new ModelGeneratorCommand()) + * ->arg('name', 'User') + * ->run(); + * ?> + * ``` + */ +class SymfonyCommand extends BaseTask +{ + /** + * @var \Symfony\Component\Console\Command\Command + */ + protected $command; + + /** + * @var string[] + */ + protected $input; + + public function __construct(Command $command) + { + $this->command = $command; + $this->input = []; + } + + /** + * @param string $arg + * @param string $value + * + * @return $this + */ + public function arg($arg, $value) + { + $this->input[$arg] = $value; + return $this; + } + + public function opt($option, $value = null) + { + $this->input["--$option"] = $value; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running command {command}', ['command' => $this->command->getName()]); + return new Result( + $this, + $this->command->run(new ArrayInput($this->input), Robo::output()) + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Watch.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Watch.php new file mode 100644 index 00000000..d7940ac9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/Watch.php @@ -0,0 +1,89 @@ +taskWatch() + * ->monitor('composer.json', function() { + * $this->taskComposerUpdate()->run(); + * })->monitor('src', function() { + * $this->taskExec('phpunit')->run(); + * })->run(); + * ?> + * ``` + */ +class Watch extends BaseTask +{ + /** + * @var \Closure + */ + protected $closure; + + /** + * @var array + */ + protected $monitor = []; + + /** + * @var object + */ + protected $bindTo; + + /** + * @param $bindTo + */ + public function __construct($bindTo) + { + $this->bindTo = $bindTo; + } + + /** + * @param string|string[] $paths + * @param \Closure $callable + * + * @return $this + */ + public function monitor($paths, \Closure $callable) + { + if (!is_array($paths)) { + $paths = [$paths]; + } + $this->monitor[] = [$paths, $callable]; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!class_exists('Lurker\\ResourceWatcher')) { + return Result::errorMissingPackage($this, 'ResourceWatcher', 'henrikbjorn/lurker'); + } + + $watcher = new ResourceWatcher(); + + foreach ($this->monitor as $k => $monitor) { + /** @var \Closure $closure */ + $closure = $monitor[1]; + $closure->bindTo($this->bindTo); + foreach ($monitor[0] as $i => $dir) { + $watcher->track("fs.$k.$i", $dir, FilesystemEvent::MODIFY); + $this->printTaskInfo('Watching {dir} for changes...', ['dir' => $dir]); + $watcher->addListener("fs.$k.$i", $closure); + } + } + + $watcher->start(); + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadShortcuts.php new file mode 100644 index 00000000..dba0af66 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadShortcuts.php @@ -0,0 +1,17 @@ +taskExec($command)->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadTasks.php new file mode 100644 index 00000000..ab5301bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Base/loadTasks.php @@ -0,0 +1,48 @@ +task(Exec::class, $command); + } + + /** + * @return ExecStack + */ + protected function taskExecStack() + { + return $this->task(ExecStack::class); + } + + /** + * @return ParallelExec + */ + protected function taskParallelExec() + { + return $this->task(ParallelExec::class); + } + + /** + * @param $command + * @return SymfonyCommand + */ + protected function taskSymfonyCommand($command) + { + return $this->task(SymfonyCommand::class, $command); + } + + /** + * @return Watch + */ + protected function taskWatch() + { + return $this->task(Watch::class, $this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/BaseTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/BaseTask.php new file mode 100644 index 00000000..66155c09 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/BaseTask.php @@ -0,0 +1,60 @@ +logger) { + $child->setLogger($this->logger); + } + if ($child instanceof ProgressIndicatorAwareInterface && $this->progressIndicator) { + $child->setProgressIndicator($this->progressIndicator); + } + if ($child instanceof ConfigAwareInterface && $this->getConfig()) { + $child->setConfig($this->getConfig()); + } + if ($child instanceof VerbosityThresholdInterface && $this->outputAdapter()) { + $child->setOutputAdapter($this->outputAdapter()); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Base.php new file mode 100644 index 00000000..9bc614c6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Base.php @@ -0,0 +1,88 @@ +option('allow-root'); + return $this; + } + + /** + * adds `force-latest` option to bower + * + * @return $this + */ + public function forceLatest() + { + $this->option('force-latest'); + return $this; + } + + /** + * adds `production` option to bower + * + * @return $this + */ + public function noDev() + { + $this->option('production'); + return $this; + } + + /** + * adds `offline` option to bower + * + * @return $this + */ + public function offline() + { + $this->option('offline'); + return $this; + } + + /** + * Base constructor. + * + * @param null|string $pathToBower + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToBower = null) + { + $this->command = $pathToBower; + if (!$this->command) { + $this->command = $this->findExecutable('bower'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Bower executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Install.php new file mode 100644 index 00000000..c3c0ce75 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Install.php @@ -0,0 +1,36 @@ +taskBowerInstall()->run(); + * + * // prefer dist with custom path + * $this->taskBowerInstall('path/to/my/bower') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Install extends Base implements CommandInterface +{ + /** + * {@inheritdoc} + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Install Bower packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Update.php new file mode 100644 index 00000000..f0dfa94e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/Update.php @@ -0,0 +1,34 @@ +taskBowerUpdate->run(); + * + * // prefer dist with custom path + * $this->taskBowerUpdate('path/to/my/bower') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Update Bower packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/loadTasks.php new file mode 100644 index 00000000..6e33f8ac --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Bower/loadTasks.php @@ -0,0 +1,25 @@ +task(Install::class, $pathToBower); + } + + /** + * @param null|string $pathToBower + * + * @return Update + */ + protected function taskBowerUpdate($pathToBower = null) + { + return $this->task(Update::class, $pathToBower); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/CommandStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/CommandStack.php new file mode 100644 index 00000000..f1cb4492 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/CommandStack.php @@ -0,0 +1,134 @@ +exec); + } + + /** + * @param string $executable + * + * @return $this + */ + public function executable($executable) + { + $this->executable = $executable; + return $this; + } + + /** + * @param string|string[] $command + * + * @return $this + */ + public function exec($command) + { + if (is_array($command)) { + $command = implode(' ', array_filter($command)); + } + + $command = $this->executable . ' ' . $this->stripExecutableFromCommand($command); + $this->exec[] = trim($command); + return $this; + } + + /** + * @param bool $stopOnFail + * + * @return $this + */ + public function stopOnFail($stopOnFail = true) + { + $this->stopOnFail = $stopOnFail; + return $this; + } + + public function result($result) + { + $this->result = $result; + return $this; + } + + /** + * @param string $command + * + * @return string + */ + protected function stripExecutableFromCommand($command) + { + $command = trim($command); + $executable = $this->executable . ' '; + if (strpos($command, $executable) === 0) { + $command = substr($command, strlen($executable)); + } + return $command; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->exec)) { + throw new TaskException($this, 'You must add at least one command'); + } + // If 'stopOnFail' is not set, or if there is only one command to run, + // then execute the single command to run. + if (!$this->stopOnFail || (count($this->exec) == 1)) { + $this->printTaskInfo('{command}', ['command' => $this->getCommand()]); + return $this->executeCommand($this->getCommand()); + } + + // When executing multiple commands in 'stopOnFail' mode, run them + // one at a time so that the result will have the exact command + // that failed available to the caller. This is at the expense of + // losing the output from all successful commands. + $data = []; + $message = ''; + $result = null; + foreach ($this->exec as $command) { + $this->printTaskInfo("Executing {command}", ['command' => $command]); + $result = $this->executeCommand($command); + $result->accumulateExecutionTime($data); + $message = $result->accumulateMessage($message); + $data = $result->mergeData($data); + if (!$result->wasSuccessful()) { + return $result; + } + } + + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Base.php new file mode 100644 index 00000000..de3fe217 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Base.php @@ -0,0 +1,248 @@ +command = $pathToComposer; + if (!$this->command) { + $this->command = $this->findExecutablePhar('composer'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Neither local composer.phar nor global composer installation could be found."); + } + } + + /** + * adds `prefer-dist` option to composer + * + * @return $this + */ + public function preferDist($preferDist = true) + { + if (!$preferDist) { + return $this->preferSource(); + } + $this->prefer = '--prefer-dist'; + return $this; + } + + /** + * adds `prefer-source` option to composer + * + * @return $this + */ + public function preferSource() + { + $this->prefer = '--prefer-source'; + return $this; + } + + /** + * adds `dev` option to composer + * + * @return $this + */ + public function dev($dev = true) + { + if (!$dev) { + return $this->noDev(); + } + $this->dev = '--dev'; + return $this; + } + + /** + * adds `no-dev` option to composer + * + * @return $this + */ + public function noDev() + { + $this->dev = '--no-dev'; + return $this; + } + + /** + * adds `ansi` option to composer + * + * @return $this + */ + public function ansi($ansi = true) + { + if (!$ansi) { + return $this->noAnsi(); + } + $this->ansi = '--ansi'; + return $this; + } + + /** + * adds `no-ansi` option to composer + * + * @return $this + */ + public function noAnsi() + { + $this->ansi = '--no-ansi'; + return $this; + } + + public function interaction($interaction = true) + { + if (!$interaction) { + return $this->noInteraction(); + } + return $this; + } + + /** + * adds `no-interaction` option to composer + * + * @return $this + */ + public function noInteraction() + { + $this->nointeraction = '--no-interaction'; + return $this; + } + + /** + * adds `optimize-autoloader` option to composer + * + * @return $this + */ + public function optimizeAutoloader($optimize = true) + { + if ($optimize) { + $this->option('--optimize-autoloader'); + } + return $this; + } + + /** + * adds `ignore-platform-reqs` option to composer + * + * @return $this + */ + public function ignorePlatformRequirements($ignore = true) + { + $this->option('--ignore-platform-reqs'); + return $this; + } + + /** + * disable plugins + * + * @return $this + */ + public function disablePlugins($disable = true) + { + if ($disable) { + $this->option('--no-plugins'); + } + return $this; + } + + /** + * skip scripts + * + * @return $this + */ + public function noScripts($disable = true) + { + if ($disable) { + $this->option('--no-scripts'); + } + return $this; + } + + /** + * adds `--working-dir $dir` option to composer + * + * @return $this + */ + public function workingDir($dir) + { + $this->option("--working-dir", $dir); + return $this; + } + + /** + * Copy class fields into command options as directed. + */ + public function buildCommand() + { + if (!isset($this->ansi) && $this->getConfig()->get(\Robo\Config\Config::DECORATED)) { + $this->ansi(); + } + if (!isset($this->nointeraction) && !$this->getConfig()->get(\Robo\Config\Config::INTERACTIVE)) { + $this->noInteraction(); + } + $this->option($this->prefer) + ->option($this->dev) + ->option($this->nointeraction) + ->option($this->ansi); + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + if (!$this->built) { + $this->buildCommand(); + $this->built = true; + } + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Config.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Config.php new file mode 100644 index 00000000..b5a6bbff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Config.php @@ -0,0 +1,93 @@ +taskComposerConfig()->set('bin-dir', 'bin/')->run(); + * ?> + * ``` + */ +class Config extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'config'; + + /** + * Set a configuration value + * @return $this + */ + public function set($key, $value) + { + $this->arg($key); + $this->arg($value); + return $this; + } + + /** + * Operate on the global repository + * @return $this + */ + public function useGlobal($useGlobal = true) + { + if ($useGlobal) { + $this->option('global'); + } + return $this; + } + + /** + * @return $this + */ + public function repository($id, $uri, $repoType = 'vcs') + { + $this->arg("repositories.$id"); + $this->arg($repoType); + $this->arg($uri); + return $this; + } + + /** + * @return $this + */ + public function removeRepository($id) + { + $this->option('unset', "repositories.$id"); + return $this; + } + + /** + * @return $this + */ + public function disableRepository($id) + { + $this->arg("repositories.$id"); + $this->arg('false'); + return $this; + } + + /** + * @return $this + */ + public function enableRepository($id) + { + $this->arg("repositories.$id"); + $this->arg('true'); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Configuring composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/CreateProject.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/CreateProject.php new file mode 100644 index 00000000..5f979a64 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/CreateProject.php @@ -0,0 +1,112 @@ +taskComposerCreateProject()->source('foo/bar')->target('myBar')->run(); + * ?> + * ``` + */ +class CreateProject extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'create-project'; + + protected $source; + protected $target = ''; + protected $version = ''; + + /** + * @return $this + */ + public function source($source) + { + $this->source = $source; + return $this; + } + + /** + * @return $this + */ + public function target($target) + { + $this->target = $target; + return $this; + } + + /** + * @return $this + */ + public function version($version) + { + $this->version = $version; + return $this; + } + + public function keepVcs($keep = true) + { + if ($keep) { + $this->option('--keep-vcs'); + } + return $this; + } + + public function noInstall($noInstall = true) + { + if ($noInstall) { + $this->option('--no-install'); + } + return $this; + } + + /** + * @return $this + */ + public function repository($repository) + { + if (!empty($repository)) { + $this->option('repository', $repository); + } + return $this; + } + + /** + * @return $this + */ + public function stability($stability) + { + if (!empty($stability)) { + $this->option('stability', $stability); + } + return $this; + } + + public function buildCommand() + { + $this->arg($this->source); + if (!empty($this->target)) { + $this->arg($this->target); + } + if (!empty($this->version)) { + $this->arg($this->version); + } + + return parent::buildCommand(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Creating project: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/DumpAutoload.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/DumpAutoload.php new file mode 100644 index 00000000..55b1ea00 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/DumpAutoload.php @@ -0,0 +1,62 @@ +taskComposerDumpAutoload()->run(); + * + * // dump auto loader with custom path + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader dump with custom path + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->optimize() + * ->run(); + * + * // optimize autoloader dump with custom path and no dev + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->optimize() + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class DumpAutoload extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'dump-autoload'; + + /** + * @var string + */ + protected $optimize; + + /** + * @return $this + */ + public function optimize($optimize = true) + { + if ($optimize) { + $this->option("--optimize"); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Dumping Autoloader: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Init.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Init.php new file mode 100644 index 00000000..c841299d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Init.php @@ -0,0 +1,115 @@ +taskComposerInit()->run(); + * ?> + * ``` + */ +class Init extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'init'; + + /** + * @return $this + */ + public function projectName($projectName) + { + $this->option('name', $projectName); + return $this; + } + + /** + * @return $this + */ + public function description($description) + { + $this->option('description', $description); + return $this; + } + + /** + * @return $this + */ + public function author($author) + { + $this->option('author', $author); + return $this; + } + + /** + * @return $this + */ + public function projectType($type) + { + $this->option('type', $type); + return $this; + } + + /** + * @return $this + */ + public function homepage($homepage) + { + $this->option('homepage', $homepage); + return $this; + } + + /** + * 'require' is a keyword, so it cannot be a method name. + * @return $this + */ + public function dependency($project, $version = null) + { + if (isset($version)) { + $project .= ":$version"; + } + $this->option('require', $project); + return $this; + } + + /** + * @return $this + */ + public function stability($stability) + { + $this->option('stability', $stability); + return $this; + } + + /** + * @return $this + */ + public function license($license) + { + $this->option('license', $license); + return $this; + } + + /** + * @return $this + */ + public function repository($repository) + { + $this->option('repository', $repository); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Creating composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Install.php new file mode 100644 index 00000000..76cb9861 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Install.php @@ -0,0 +1,40 @@ +taskComposerInstall()->run(); + * + * // prefer dist with custom path + * $this->taskComposerInstall('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader with custom path + * $this->taskComposerInstall('path/to/my/composer.phar') + * ->optimizeAutoloader() + * ->run(); + * ?> + * ``` + */ +class Install extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Installing Packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Remove.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Remove.php new file mode 100644 index 00000000..b0316f05 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Remove.php @@ -0,0 +1,85 @@ +taskComposerRemove()->run(); + * ?> + * ``` + */ +class Remove extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'remove'; + + /** + * @return $this + */ + public function dev($dev = true) + { + if ($dev) { + $this->option('--dev'); + } + return $this; + } + + /** + * @return $this + */ + public function noProgress($noProgress = true) + { + if ($noProgress) { + $this->option('--no-progress'); + } + return $this; + } + + /** + * @return $this + */ + public function noUpdate($noUpdate = true) + { + if ($noUpdate) { + $this->option('--no-update'); + } + return $this; + } + + /** + * @return $this + */ + public function updateNoDev($updateNoDev = true) + { + if ($updateNoDev) { + $this->option('--update-no-dev'); + } + return $this; + } + + /** + * @return $this + */ + public function noUpdateWithDependencies($updateWithDependencies = true) + { + if ($updateWithDependencies) { + $this->option('--no-update-with-dependencies'); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Removing packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/RequireDependency.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/RequireDependency.php new file mode 100644 index 00000000..6cdbf613 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/RequireDependency.php @@ -0,0 +1,50 @@ +taskComposerRequire()->dependency('foo/bar', '^.2.4.8')->run(); + * ?> + * ``` + */ +class RequireDependency extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'require'; + + /** + * 'require' is a keyword, so it cannot be a method name. + * @return $this + */ + public function dependency($project, $version = null) + { + $project = (array)$project; + + if (isset($version)) { + $project = array_map( + function ($item) use ($version) { + return "$item:$version"; + }, + $project + ); + } + $this->args($project); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Requiring packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Update.php new file mode 100644 index 00000000..3a0a64af --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Update.php @@ -0,0 +1,40 @@ +taskComposerUpdate()->run(); + * + * // prefer dist with custom path + * $this->taskComposerUpdate('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader with custom path + * $this->taskComposerUpdate('path/to/my/composer.phar') + * ->optimizeAutoloader() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Updating Packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Validate.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Validate.php new file mode 100644 index 00000000..adb15854 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/Validate.php @@ -0,0 +1,85 @@ +taskComposerValidate()->run(); + * ?> + * ``` + */ +class Validate extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'validate'; + + /** + * @return $this + */ + public function noCheckAll($noCheckAll = true) + { + if ($noCheckAll) { + $this->option('--no-check-all'); + } + return $this; + } + + /** + * @return $this + */ + public function noCheckLock($noCheckLock = true) + { + if ($noCheckLock) { + $this->option('--no-check-lock'); + } + return $this; + } + + /** + * @return $this + */ + public function noCheckPublish($noCheckPublish = true) + { + if ($noCheckPublish) { + $this->option('--no-check-publish'); + } + return $this; + } + + /** + * @return $this + */ + public function withDependencies($withDependencies = true) + { + if ($withDependencies) { + $this->option('--with-dependencies'); + } + return $this; + } + + /** + * @return $this + */ + public function strict($strict = true) + { + if ($strict) { + $this->option('--strict'); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Validating composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/loadTasks.php new file mode 100644 index 00000000..6b074ba3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Composer/loadTasks.php @@ -0,0 +1,95 @@ +task(Install::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Update + */ + protected function taskComposerUpdate($pathToComposer = null) + { + return $this->task(Update::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return DumpAutoload + */ + protected function taskComposerDumpAutoload($pathToComposer = null) + { + return $this->task(DumpAutoload::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Init + */ + protected function taskComposerInit($pathToComposer = null) + { + return $this->task(Init::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Init + */ + protected function taskComposerConfig($pathToComposer = null) + { + return $this->task(Config::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Validate + */ + protected function taskComposerValidate($pathToComposer = null) + { + return $this->task(Validate::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerRemove($pathToComposer = null) + { + return $this->task(Remove::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerRequire($pathToComposer = null) + { + return $this->task(RequireDependency::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerCreateProject($pathToComposer = null) + { + return $this->task(CreateProject::class, $pathToComposer); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/Changelog.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/Changelog.php new file mode 100644 index 00000000..44af6d82 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/Changelog.php @@ -0,0 +1,246 @@ +taskChangelog() + * ->version($version) + * ->change("released to github") + * ->run(); + * ?> + * ``` + * + * Changes can be asked from Console + * + * ``` php + * taskChangelog() + * ->version($version) + * ->askForChanges() + * ->run(); + * ?> + * ``` + */ +class Changelog extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $filename; + + /** + * @var array + */ + protected $log = []; + + /** + * @var string + */ + protected $anchor = "# Changelog"; + + /** + * @var string + */ + protected $version = ""; + + /** + * @var string + */ + protected $body = ""; + + /** + * @var string + */ + protected $header = ""; + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * Sets the changelog body text. + * + * This method permits the raw changelog text to be set directly If this is set, $this->log changes will be ignored. + * + * @param string $body + * + * @return $this + */ + public function setBody($body) + { + $this->body = $body; + return $this; + } + + /** + * @param string $header + * + * @return $this + */ + public function setHeader($header) + { + $this->header = $header; + return $this; + } + + /** + * @param string $item + * + * @return $this + */ + public function log($item) + { + $this->log[] = $item; + return $this; + } + + /** + * @param string $anchor + * + * @return $this + */ + public function anchor($anchor) + { + $this->anchor = $anchor; + return $this; + } + + /** + * @param string $version + * + * @return $this + */ + public function version($version) + { + $this->version = $version; + return $this; + } + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param array $data + * + * @return $this + */ + public function changes(array $data) + { + $this->log = array_merge($this->log, $data); + return $this; + } + + /** + * @param string $change + * + * @return $this + */ + public function change($change) + { + $this->log[] = $change; + return $this; + } + + /** + * @return array + */ + public function getChanges() + { + return $this->log; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->body)) { + if (empty($this->log)) { + return Result::error($this, "Changelog is empty"); + } + $this->body = $this->generateBody(); + } + if (empty($this->header)) { + $this->header = $this->generateHeader(); + } + + $text = $this->header . $this->body; + + if (!file_exists($this->filename)) { + $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]); + $res = file_put_contents($this->filename, $this->anchor); + if ($res === false) { + return Result::error($this, "File {filename} cant be created", ['filename' => $this->filename]); + } + } + + /** @var \Robo\Result $result */ + // trying to append to changelog for today + $result = $this->collectionBuilder()->taskReplaceInFile($this->filename) + ->from($this->header) + ->to($text) + ->run(); + + if (!isset($result['replaced']) || !$result['replaced']) { + $result = $this->collectionBuilder()->taskReplaceInFile($this->filename) + ->from($this->anchor) + ->to($this->anchor . "\n\n" . $text) + ->run(); + } + + return new Result($this, $result->getExitCode(), $result->getMessage(), $this->log); + } + + /** + * @return \Robo\Result|string + */ + protected function generateBody() + { + $text = implode("\n", array_map([$this, 'processLogRow'], $this->log)); + $text .= "\n"; + + return $text; + } + + /** + * @return string + */ + protected function generateHeader() + { + return "#### {$this->version}\n\n"; + } + + /** + * @param $i + * + * @return string + */ + public function processLogRow($i) + { + return "* $i *" . date('Y-m-d') . "*"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateMarkdownDoc.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateMarkdownDoc.php new file mode 100644 index 00000000..0c3ec26c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateMarkdownDoc.php @@ -0,0 +1,782 @@ +taskGenDoc('models.md') + * ->docClass('Model\User') // take class Model\User + * ->docClass('Model\Post') // take class Model\Post + * ->filterMethods(function(\ReflectionMethod $r) { + * return $r->isPublic() or $r->isProtected(); // process public and protected methods + * })->processClass(function(\ReflectionClass $r, $text) { + * return "Class ".$r->getName()."\n\n$text\n\n###Methods\n"; + * })->run(); + * ``` + * + * By default this task generates a documentation for each public method of a class. + * It combines method signature with a docblock. Both can be post-processed. + * + * ``` php + * taskGenDoc('models.md') + * ->docClass('Model\User') + * ->processClassSignature(false) // false can be passed to not include class signature + * ->processClassDocBlock(function(\ReflectionClass $r, $text) { + * return "[This is part of application model]\n" . $text; + * })->processMethodSignature(function(\ReflectionMethod $r, $text) { + * return "#### {$r->name}()"; + * })->processMethodDocBlock(function(\ReflectionMethod $r, $text) { + * return strpos($r->name, 'save')===0 ? "[Saves to the database]\n" . $text : $text; + * })->run(); + * ``` + */ +class GenerateMarkdownDoc extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string[] + */ + protected $docClass = []; + + /** + * @var callable + */ + protected $filterMethods; + + /** + * @var callable + */ + protected $filterClasses; + + /** + * @var callable + */ + protected $filterProperties; + + /** + * @var callable + */ + protected $processClass; + + /** + * @var callable|false + */ + protected $processClassSignature; + + /** + * @var callable|false + */ + protected $processClassDocBlock; + + /** + * @var callable|false + */ + protected $processMethod; + + /** + * @var callable|false + */ + protected $processMethodSignature; + + /** + * @var callable|false + */ + protected $processMethodDocBlock; + + /** + * @var callable|false + */ + protected $processProperty; + + /** + * @var callable|false + */ + protected $processPropertySignature; + + /** + * @var callable|false + */ + protected $processPropertyDocBlock; + + /** + * @var callable + */ + protected $reorder; + + /** + * @var callable + */ + protected $reorderMethods; + + /** + * @todo Unused property. + * + * @var callable + */ + protected $reorderProperties; + + /** + * @var string + */ + protected $filename; + + /** + * @var string + */ + protected $prepend = ""; + + /** + * @var string + */ + protected $append = ""; + + /** + * @var string + */ + protected $text; + + /** + * @var string[] + */ + protected $textForClass = []; + + /** + * @param string $filename + * + * @return static + */ + public static function init($filename) + { + return new static($filename); + } + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * Put a class you want to be documented. + * + * @param string $item + * + * @return $this + */ + public function docClass($item) + { + $this->docClass[] = $item; + return $this; + } + + /** + * Using a callback function filter out methods that won't be documented. + * + * @param callable $filterMethods + * + * @return $this + */ + public function filterMethods($filterMethods) + { + $this->filterMethods = $filterMethods; + return $this; + } + + /** + * Using a callback function filter out classes that won't be documented. + * + * @param callable $filterClasses + * + * @return $this + */ + public function filterClasses($filterClasses) + { + $this->filterClasses = $filterClasses; + return $this; + } + + /** + * Using a callback function filter out properties that won't be documented. + * + * @param callable $filterProperties + * + * @return $this + */ + public function filterProperties($filterProperties) + { + $this->filterProperties = $filterProperties; + return $this; + } + + /** + * Post-process class documentation. + * + * @param callable $processClass + * + * @return $this + */ + public function processClass($processClass) + { + $this->processClass = $processClass; + return $this; + } + + /** + * Post-process class signature. Provide *false* to skip. + * + * @param callable|false $processClassSignature + * + * @return $this + */ + public function processClassSignature($processClassSignature) + { + $this->processClassSignature = $processClassSignature; + return $this; + } + + /** + * Post-process class docblock contents. Provide *false* to skip. + * + * @param callable|false $processClassDocBlock + * + * @return $this + */ + public function processClassDocBlock($processClassDocBlock) + { + $this->processClassDocBlock = $processClassDocBlock; + return $this; + } + + /** + * Post-process method documentation. Provide *false* to skip. + * + * @param callable|false $processMethod + * + * @return $this + */ + public function processMethod($processMethod) + { + $this->processMethod = $processMethod; + return $this; + } + + /** + * Post-process method signature. Provide *false* to skip. + * + * @param callable|false $processMethodSignature + * + * @return $this + */ + public function processMethodSignature($processMethodSignature) + { + $this->processMethodSignature = $processMethodSignature; + return $this; + } + + /** + * Post-process method docblock contents. Provide *false* to skip. + * + * @param callable|false $processMethodDocBlock + * + * @return $this + */ + public function processMethodDocBlock($processMethodDocBlock) + { + $this->processMethodDocBlock = $processMethodDocBlock; + return $this; + } + + /** + * Post-process property documentation. Provide *false* to skip. + * + * @param callable|false $processProperty + * + * @return $this + */ + public function processProperty($processProperty) + { + $this->processProperty = $processProperty; + return $this; + } + + /** + * Post-process property signature. Provide *false* to skip. + * + * @param callable|false $processPropertySignature + * + * @return $this + */ + public function processPropertySignature($processPropertySignature) + { + $this->processPropertySignature = $processPropertySignature; + return $this; + } + + /** + * Post-process property docblock contents. Provide *false* to skip. + * + * @param callable|false $processPropertyDocBlock + * + * @return $this + */ + public function processPropertyDocBlock($processPropertyDocBlock) + { + $this->processPropertyDocBlock = $processPropertyDocBlock; + return $this; + } + + /** + * Use a function to reorder classes. + * + * @param callable $reorder + * + * @return $this + */ + public function reorder($reorder) + { + $this->reorder = $reorder; + return $this; + } + + /** + * Use a function to reorder methods in class. + * + * @param callable $reorderMethods + * + * @return $this + */ + public function reorderMethods($reorderMethods) + { + $this->reorderMethods = $reorderMethods; + return $this; + } + + /** + * @param callable $reorderProperties + * + * @return $this + */ + public function reorderProperties($reorderProperties) + { + $this->reorderProperties = $reorderProperties; + return $this; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * Inserts text at the beginning of markdown file. + * + * @param string $prepend + * + * @return $this + */ + public function prepend($prepend) + { + $this->prepend = $prepend; + return $this; + } + + /** + * Inserts text at the end of markdown file. + * + * @param string $append + * + * @return $this + */ + public function append($append) + { + $this->append = $append; + return $this; + } + + /** + * @param string $text + * + * @return $this + */ + public function text($text) + { + $this->text = $text; + return $this; + } + + /** + * @param string $item + * + * @return $this + */ + public function textForClass($item) + { + $this->textForClass[] = $item; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + foreach ($this->docClass as $class) { + $this->printTaskInfo("Processing {class}", ['class' => $class]); + $this->textForClass[$class] = $this->documentClass($class); + } + + if (is_callable($this->reorder)) { + $this->printTaskInfo("Applying reorder function"); + call_user_func_array($this->reorder, [$this->textForClass]); + } + + $this->text = implode("\n", $this->textForClass); + + /** @var \Robo\Result $result */ + $result = $this->collectionBuilder()->taskWriteToFile($this->filename) + ->line($this->prepend) + ->text($this->text) + ->line($this->append) + ->run(); + + $this->printTaskSuccess('{filename} created. {class-count} classes documented', ['filename' => $this->filename, 'class-count' => count($this->docClass)]); + + return new Result($this, $result->getExitCode(), $result->getMessage(), $this->textForClass); + } + + /** + * @param string $class + * + * @return null|string + */ + protected function documentClass($class) + { + if (!class_exists($class)) { + return ""; + } + $refl = new \ReflectionClass($class); + + if (is_callable($this->filterClasses)) { + $ret = call_user_func($this->filterClasses, $refl); + if (!$ret) { + return; + } + } + $doc = $this->documentClassSignature($refl); + $doc .= "\n" . $this->documentClassDocBlock($refl); + $doc .= "\n"; + + if (is_callable($this->processClass)) { + $doc = call_user_func($this->processClass, $refl, $doc); + } + + $properties = []; + foreach ($refl->getProperties() as $reflProperty) { + $properties[] = $this->documentProperty($reflProperty); + } + + $properties = array_filter($properties); + $doc .= implode("\n", $properties); + + $methods = []; + foreach ($refl->getMethods() as $reflMethod) { + $methods[$reflMethod->name] = $this->documentMethod($reflMethod); + } + if (is_callable($this->reorderMethods)) { + call_user_func_array($this->reorderMethods, [&$methods]); + } + + $methods = array_filter($methods); + + $doc .= implode("\n", $methods)."\n"; + + return $doc; + } + + /** + * @param \ReflectionClass $reflectionClass + * + * @return string + */ + protected function documentClassSignature(\ReflectionClass $reflectionClass) + { + if ($this->processClassSignature === false) { + return ""; + } + + $signature = "## {$reflectionClass->name}\n\n"; + + if ($parent = $reflectionClass->getParentClass()) { + $signature .= "* *Extends* `{$parent->name}`"; + } + $interfaces = $reflectionClass->getInterfaceNames(); + if (count($interfaces)) { + $signature .= "\n* *Implements* `" . implode('`, `', $interfaces) . '`'; + } + $traits = $reflectionClass->getTraitNames(); + if (count($traits)) { + $signature .= "\n* *Uses* `" . implode('`, `', $traits) . '`'; + } + if (is_callable($this->processClassSignature)) { + $signature = call_user_func($this->processClassSignature, $reflectionClass, $signature); + } + + return $signature; + } + + /** + * @param \ReflectionClass $reflectionClass + * + * @return string + */ + protected function documentClassDocBlock(\ReflectionClass $reflectionClass) + { + if ($this->processClassDocBlock === false) { + return ""; + } + $doc = self::indentDoc($reflectionClass->getDocComment()); + if (is_callable($this->processClassDocBlock)) { + $doc = call_user_func($this->processClassDocBlock, $reflectionClass, $doc); + } + return $doc; + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethod(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethod === false) { + return ""; + } + if (is_callable($this->filterMethods)) { + $ret = call_user_func($this->filterMethods, $reflectedMethod); + if (!$ret) { + return ""; + } + } else { + if (!$reflectedMethod->isPublic()) { + return ""; + } + } + + $signature = $this->documentMethodSignature($reflectedMethod); + $docblock = $this->documentMethodDocBlock($reflectedMethod); + $methodDoc = "$signature $docblock"; + if (is_callable($this->processMethod)) { + $methodDoc = call_user_func($this->processMethod, $reflectedMethod, $methodDoc); + } + return $methodDoc; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentProperty(\ReflectionProperty $reflectedProperty) + { + if ($this->processProperty === false) { + return ""; + } + if (is_callable($this->filterProperties)) { + $ret = call_user_func($this->filterProperties, $reflectedProperty); + if (!$ret) { + return ""; + } + } else { + if (!$reflectedProperty->isPublic()) { + return ""; + } + } + $signature = $this->documentPropertySignature($reflectedProperty); + $docblock = $this->documentPropertyDocBlock($reflectedProperty); + $propertyDoc = $signature . $docblock; + if (is_callable($this->processProperty)) { + $propertyDoc = call_user_func($this->processProperty, $reflectedProperty, $propertyDoc); + } + return $propertyDoc; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentPropertySignature(\ReflectionProperty $reflectedProperty) + { + if ($this->processPropertySignature === false) { + return ""; + } + $modifiers = implode(' ', \Reflection::getModifierNames($reflectedProperty->getModifiers())); + $signature = "#### *$modifiers* {$reflectedProperty->name}"; + if (is_callable($this->processPropertySignature)) { + $signature = call_user_func($this->processPropertySignature, $reflectedProperty, $signature); + } + return $signature; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentPropertyDocBlock(\ReflectionProperty $reflectedProperty) + { + if ($this->processPropertyDocBlock === false) { + return ""; + } + $propertyDoc = $reflectedProperty->getDocComment(); + // take from parent + if (!$propertyDoc) { + $parent = $reflectedProperty->getDeclaringClass(); + while ($parent = $parent->getParentClass()) { + if ($parent->hasProperty($reflectedProperty->name)) { + $propertyDoc = $parent->getProperty($reflectedProperty->name)->getDocComment(); + } + } + } + $propertyDoc = self::indentDoc($propertyDoc, 7); + $propertyDoc = preg_replace("~^@(.*?)([$\s])~", ' * `$1` $2', $propertyDoc); // format annotations + if (is_callable($this->processPropertyDocBlock)) { + $propertyDoc = call_user_func($this->processPropertyDocBlock, $reflectedProperty, $propertyDoc); + } + return ltrim($propertyDoc); + } + + /** + * @param \ReflectionParameter $param + * + * @return string + */ + protected function documentParam(\ReflectionParameter $param) + { + $text = ""; + if ($param->isArray()) { + $text .= 'array '; + } + if ($param->isCallable()) { + $text .= 'callable '; + } + $text .= '$' . $param->name; + if ($param->isDefaultValueAvailable()) { + if ($param->allowsNull()) { + $text .= ' = null'; + } else { + $text .= ' = ' . str_replace("\n", ' ', print_r($param->getDefaultValue(), true)); + } + } + + return $text; + } + + /** + * @param string $doc + * @param int $indent + * + * @return string + */ + public static function indentDoc($doc, $indent = 3) + { + if (!$doc) { + return $doc; + } + return implode( + "\n", + array_map( + function ($line) use ($indent) { + return substr($line, $indent); + }, + explode("\n", $doc) + ) + ); + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethodSignature(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethodSignature === false) { + return ""; + } + $modifiers = implode(' ', \Reflection::getModifierNames($reflectedMethod->getModifiers())); + $params = implode( + ', ', + array_map( + function ($p) { + return $this->documentParam($p); + }, + $reflectedMethod->getParameters() + ) + ); + $signature = "#### *$modifiers* {$reflectedMethod->name}($params)"; + if (is_callable($this->processMethodSignature)) { + $signature = call_user_func($this->processMethodSignature, $reflectedMethod, $signature); + } + return $signature; + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethodDocBlock(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethodDocBlock === false) { + return ""; + } + $methodDoc = $reflectedMethod->getDocComment(); + // take from parent + if (!$methodDoc) { + $parent = $reflectedMethod->getDeclaringClass(); + while ($parent = $parent->getParentClass()) { + if ($parent->hasMethod($reflectedMethod->name)) { + $methodDoc = $parent->getMethod($reflectedMethod->name)->getDocComment(); + } + } + } + // take from interface + if (!$methodDoc) { + $interfaces = $reflectedMethod->getDeclaringClass()->getInterfaces(); + foreach ($interfaces as $interface) { + $i = new \ReflectionClass($interface->name); + if ($i->hasMethod($reflectedMethod->name)) { + $methodDoc = $i->getMethod($reflectedMethod->name)->getDocComment(); + break; + } + } + } + + $methodDoc = self::indentDoc($methodDoc, 7); + $methodDoc = preg_replace("~^@(.*?) ([$\s])~m", ' * `$1` $2', $methodDoc); // format annotations + if (is_callable($this->processMethodDocBlock)) { + $methodDoc = call_user_func($this->processMethodDocBlock, $reflectedMethod, $methodDoc); + } + + return $methodDoc; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateTask.php new file mode 100644 index 00000000..9d7a698e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GenerateTask.php @@ -0,0 +1,107 @@ +taskGenerateTask('Symfony\Component\Filesystem\Filesystem', 'FilesystemStack') + * ->run(); + * ``` + */ +class GenerateTask extends BaseTask +{ + /** + * @var string + */ + protected $className; + + /** + * @var string + */ + protected $wrapperClassName; + + /** + * @param string $className + * @param string $wrapperClassName + */ + public function __construct($className, $wrapperClassName = '') + { + $this->className = $className; + $this->wrapperClassName = $wrapperClassName; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $delegate = new \ReflectionClass($this->className); + $replacements = []; + + $leadingCommentChars = " * "; + $methodDescriptions = []; + $methodImplementations = []; + $immediateMethods = []; + foreach ($delegate->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { + $methodName = $method->name; + $getter = preg_match('/^(get|has|is)/', $methodName); + $setter = preg_match('/^(set|unset)/', $methodName); + $argPrototypeList = []; + $argNameList = []; + $needsImplementation = false; + foreach ($method->getParameters() as $arg) { + $argDescription = '$' . $arg->name; + $argNameList[] = $argDescription; + if ($arg->isOptional()) { + $argDescription = $argDescription . ' = ' . str_replace("\n", "", var_export($arg->getDefaultValue(), true)); + // We will create wrapper methods for any method that + // has default parameters. + $needsImplementation = true; + } + $argPrototypeList[] = $argDescription; + } + $argPrototypeString = implode(', ', $argPrototypeList); + $argNameListString = implode(', ', $argNameList); + + if ($methodName[0] != '_') { + $methodDescriptions[] = "@method $methodName($argPrototypeString)"; + + if ($getter) { + $immediateMethods[] = " public function $methodName($argPrototypeString)\n {\n return \$this->delegate->$methodName($argNameListString);\n }"; + } elseif ($setter) { + $immediateMethods[] = " public function $methodName($argPrototypeString)\n {\n \$this->delegate->$methodName($argNameListString);\n return \$this;\n }"; + } elseif ($needsImplementation) { + // Include an implementation for the wrapper method if necessary + $methodImplementations[] = " protected function _$methodName($argPrototypeString)\n {\n \$this->delegate->$methodName($argNameListString);\n }"; + } + } + } + + $classNameParts = explode('\\', $this->className); + $delegate = array_pop($classNameParts); + $delegateNamespace = implode('\\', $classNameParts); + + if (empty($this->wrapperClassName)) { + $this->wrapperClassName = $delegate; + } + + $replacements['{delegateNamespace}'] = $delegateNamespace; + $replacements['{delegate}'] = $delegate; + $replacements['{wrapperClassName}'] = $this->wrapperClassName; + $replacements['{taskname}'] = "task$delegate"; + $replacements['{methodList}'] = $leadingCommentChars . implode("\n$leadingCommentChars", $methodDescriptions); + $replacements['{immediateMethods}'] = "\n\n" . implode("\n\n", $immediateMethods); + $replacements['{methodImplementations}'] = "\n\n" . implode("\n\n", $methodImplementations); + + $template = file_get_contents(__DIR__ . '/../../../data/Task/Development/GeneratedWrapper.tmpl'); + $template = str_replace(array_keys($replacements), array_values($replacements), $template); + + // Returning data in the $message will cause it to be printed. + return Result::success($this, $template); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHub.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHub.php new file mode 100644 index 00000000..9fc9909d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHub.php @@ -0,0 +1,157 @@ +repo = $repo; + return $this; + } + + /** + * @param string $owner + * + * @return $this + */ + public function owner($owner) + { + $this->owner = $owner; + return $this; + } + + /** + * @param string $uri + * + * @return $this + */ + public function uri($uri) + { + list($this->owner, $this->repo) = explode('/', $uri); + return $this; + } + + /** + * @return string + */ + protected function getUri() + { + return $this->owner . '/' . $this->repo; + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + $this->user = $user; + return $this; + } + + /** + * @param $password + * + * @return $this + */ + public function password($password) + { + $this->password = $password; + return $this; + } + + /** + * @param $accessToken + * + * @return $this + */ + public function accessToken($token) + { + $this->accessToken = $token; + return $this; + } + + /** + * @param string $uri + * @param array $params + * @param string $method + * + * @return array + * + * @throws \Robo\Exception\TaskException + */ + protected function sendRequest($uri, $params = [], $method = 'POST') + { + if (!$this->owner or !$this->repo) { + throw new TaskException($this, 'Repo URI is not set'); + } + + $ch = curl_init(); + $url = sprintf('%s/repos/%s/%s', self::GITHUB_URL, $this->getUri(), $uri); + $this->printTaskInfo($url); + $this->printTaskInfo('{method} {url}', ['method' => $method, 'url' => $url]); + + if (!empty($this->user)) { + curl_setopt($ch, CURLOPT_USERPWD, $this->user . ':' . $this->password); + } + + if (!empty($this->accessToken)) { + $url .= "?access_token=" . $this->accessToken; + } + + curl_setopt_array( + $ch, + array( + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => $method != 'GET', + CURLOPT_POSTFIELDS => json_encode($params), + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_USERAGENT => "Robo" + ) + ); + + $output = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $response = json_decode($output); + + $this->printTaskInfo($output); + return [$code, $response]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHubRelease.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHubRelease.php new file mode 100644 index 00000000..bf7a4889 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/GitHubRelease.php @@ -0,0 +1,208 @@ +taskGitHubRelease('0.1.0') + * ->uri('consolidation-org/Robo') + * ->description('Add stuff people need.') + * ->change('Fix #123') + * ->change('Add frobulation method to all widgets') + * ->run(); + * ?> + * ``` + */ +class GitHubRelease extends GitHub +{ + /** + * @var string + */ + protected $tag; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $description = ''; + + /** + * @var string[] + */ + protected $changes = []; + + /** + * @var bool + */ + protected $draft = false; + + /** + * @var bool + */ + protected $prerelease = false; + + /** + * @var string + */ + protected $comittish = 'master'; + + /** + * @param string $tag + */ + public function __construct($tag) + { + $this->tag = $tag; + } + + /** + * @param string $tag + * + * @return $this + */ + public function tag($tag) + { + $this->tag = $tag; + return $this; + } + + /** + * @param bool $draft + * + * @return $this + */ + public function draft($draft) + { + $this->draft = $draft; + return $this; + } + + /** + * @param string $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this; + } + + /** + * @param string $description + * + * @return $this + */ + public function description($description) + { + $this->description = $description; + return $this; + } + + /** + * @param bool $prerelease + * + * @return $this + */ + public function prerelease($prerelease) + { + $this->prerelease = $prerelease; + return $this; + } + + /** + * @param string $comittish + * + * @return $this + */ + public function comittish($comittish) + { + $this->comittish = $comittish; + return $this; + } + + /** + * @param string $description + * + * @return $this + */ + public function appendDescription($description) + { + if (!empty($this->description)) { + $this->description .= "\n\n"; + } + $this->description .= $description; + return $this; + } + + public function changes(array $changes) + { + $this->changes = array_merge($this->changes, $changes); + return $this; + } + + /** + * @param string $change + * + * @return $this + */ + public function change($change) + { + $this->changes[] = $change; + return $this; + } + + /** + * @return string + */ + protected function getBody() + { + $body = $this->description; + if (!empty($this->changes)) { + $changes = array_map( + function ($line) { + return "* $line"; + }, + $this->changes + ); + $changesText = implode("\n", $changes); + $body .= "### Changelog \n\n$changesText"; + } + return $body; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Releasing {tag}', ['tag' => $this->tag]); + $this->startTimer(); + list($code, $data) = $this->sendRequest( + 'releases', + [ + "tag_name" => $this->tag, + "target_commitish" => $this->comittish, + "name" => $this->name, + "body" => $this->getBody(), + "draft" => $this->draft, + "prerelease" => $this->prerelease + ] + ); + $this->stopTimer(); + + return new Result( + $this, + in_array($code, [200, 201]) ? 0 : 1, + isset($data->message) ? $data->message : '', + ['response' => $data, 'time' => $this->getExecutionTime()] + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/OpenBrowser.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/OpenBrowser.php new file mode 100644 index 00000000..ea01b326 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/OpenBrowser.php @@ -0,0 +1,80 @@ +taskOpenBrowser('http://localhost') + * ->run(); + * + * // open two browser windows + * $this->taskOpenBrowser([ + * 'http://localhost/mysite', + * 'http://localhost/mysite2' + * ]) + * ->run(); + * ``` + */ +class OpenBrowser extends BaseTask +{ + /** + * @var string[] + */ + protected $urls = []; + + /** + * @param string|array $url + */ + public function __construct($url) + { + $this->urls = (array) $url; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $openCommand = $this->getOpenCommand(); + + if (empty($openCommand)) { + return Result::error($this, 'no suitable browser opening command found'); + } + + foreach ($this->urls as $url) { + passthru(sprintf($openCommand, ProcessUtils::escapeArgument($url))); + $this->printTaskInfo('Opened {url}', ['url' => $url]); + } + + return Result::success($this); + } + + /** + * @return null|string + */ + private function getOpenCommand() + { + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + return 'start "web" explorer "%s"'; + } + + passthru('which xdg-open', $linux); + passthru('which open', $osx); + + if (0 === $linux) { + return 'xdg-open %s'; + } + + if (0 === $osx) { + return 'open %s'; + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PackPhar.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PackPhar.php new file mode 100644 index 00000000..6d0a04d7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PackPhar.php @@ -0,0 +1,252 @@ +taskPackPhar('package/codecept.phar') + * ->compress() + * ->stub('package/stub.php'); + * + * $finder = Finder::create() + * ->name('*.php') + * ->in('src'); + * + * foreach ($finder as $file) { + * $pharTask->addFile('src/'.$file->getRelativePathname(), $file->getRealPath()); + * } + * + * $finder = Finder::create()->files() + * ->name('*.php') + * ->in('vendor'); + * + * foreach ($finder as $file) { + * $pharTask->addStripped('vendor/'.$file->getRelativePathname(), $file->getRealPath()); + * } + * $pharTask->run(); + * + * // verify Phar is packed correctly + * $code = $this->_exec('php package/codecept.phar'); + * ?> + * ``` + */ +class PackPhar extends BaseTask implements PrintedInterface, ProgressIndicatorAwareInterface +{ + /** + * @var \Phar + */ + protected $phar; + + /** + * @var null|string + */ + protected $compileDir = null; + + /** + * @var string + */ + protected $filename; + + /** + * @var bool + */ + protected $compress = false; + + protected $stub; + + protected $bin; + + /** + * @var string + */ + protected $stubTemplate = <<filename = $filename; + if (file_exists($file->getRealPath())) { + @unlink($file->getRealPath()); + } + $this->phar = new \Phar($file->getPathname(), 0, $file->getFilename()); + } + + /** + * @param bool $compress + * + * @return $this + */ + public function compress($compress = true) + { + $this->compress = $compress; + return $this; + } + + /** + * @param string $stub + * + * @return $this + */ + public function stub($stub) + { + $this->phar->setStub(file_get_contents($stub)); + return $this; + } + + /** + * {@inheritdoc} + */ + public function progressIndicatorSteps() + { + // run() will call advanceProgressIndicator() once for each + // file, one after calling stopBuffering, and again after compression. + return count($this->files)+2; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]); + $this->phar->setSignatureAlgorithm(\Phar::SHA1); + $this->phar->startBuffering(); + + $this->printTaskInfo('Packing {file-count} files into phar', ['file-count' => count($this->files)]); + + $this->startProgressIndicator(); + foreach ($this->files as $path => $content) { + $this->phar->addFromString($path, $content); + $this->advanceProgressIndicator(); + } + $this->phar->stopBuffering(); + $this->advanceProgressIndicator(); + + if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) { + if (count($this->files) > 1000) { + $this->printTaskInfo('Too many files. Compression DISABLED'); + } else { + $this->printTaskInfo('{filename} compressed', ['filename' => $this->filename]); + $this->phar = $this->phar->compressFiles(\Phar::GZ); + } + } + $this->advanceProgressIndicator(); + $this->stopProgressIndicator(); + $this->printTaskSuccess('{filename} produced', ['filename' => $this->filename]); + return Result::success($this, '', ['time' => $this->getExecutionTime()]); + } + + /** + * @param string $path + * @param string $file + * + * @return $this + */ + public function addStripped($path, $file) + { + $this->files[$path] = $this->stripWhitespace(file_get_contents($file)); + return $this; + } + + /** + * @param string $path + * @param string $file + * + * @return $this + */ + public function addFile($path, $file) + { + $this->files[$path] = file_get_contents($file); + return $this; + } + + /** + * @param \Symfony\Component\Finder\SplFileInfo[] $files + */ + public function addFiles($files) + { + foreach ($files as $file) { + $this->addFile($file->getRelativePathname(), $file->getRealPath()); + } + } + + /** + * @param string $file + * + * @return $this + */ + public function executable($file) + { + $source = file_get_contents($file); + if (strpos($source, '#!/usr/bin/env php') === 0) { + $source = substr($source, strpos($source, 'phar->setStub(sprintf($this->stubTemplate, $source)); + return $this; + } + + /** + * Strips whitespace from source. Taken from composer + * + * @param string $source + * + * @return string + */ + private function stripWhitespace($source) + { + if (!function_exists('token_get_all')) { + return $source; + } + + $output = ''; + foreach (token_get_all($source) as $token) { + if (is_string($token)) { + $output .= $token; + } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + // $output .= $token[1]; + $output .= str_repeat("\n", substr_count($token[1], "\n")); + } elseif (T_WHITESPACE === $token[0]) { + // reduce wide spaces + $whitespace = preg_replace('{[ \t]+}', ' ', $token[1]); + // normalize newlines to \n + $whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace); + // trim leading spaces + $whitespace = preg_replace('{\n +}', "\n", $whitespace); + $output .= $whitespace; + } else { + $output .= $token[1]; + } + } + + return $output; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PhpServer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PhpServer.php new file mode 100644 index 00000000..6dd36680 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/PhpServer.php @@ -0,0 +1,86 @@ +taskServer(8000) + * ->dir('public') + * ->run(); + * + * // run with IP 0.0.0.0 + * $this->taskServer(8000) + * ->host('0.0.0.0') + * ->run(); + * + * // execute server in background + * $this->taskServer(8000) + * ->background() + * ->run(); + * ?> + * ``` + */ +class PhpServer extends Exec +{ + /** + * @var int + */ + protected $port; + + /** + * @var string + */ + protected $host = '127.0.0.1'; + + /** + * {@inheritdoc} + */ + protected $command = 'php -S %s:%d '; + + /** + * @param int $port + */ + public function __construct($port) + { + $this->port = $port; + + if (strtolower(PHP_OS) === 'linux') { + $this->command = 'exec php -S %s:%d '; + } + } + + /** + * @param string $host + * + * @return $this + */ + public function host($host) + { + $this->host = $host; + return $this; + } + + /** + * @param string $path + * + * @return $this + */ + public function dir($path) + { + $this->command .= "-t $path"; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return sprintf($this->command . $this->arguments, $this->host, $this->port); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/SemVer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/SemVer.php new file mode 100644 index 00000000..6c807d89 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/SemVer.php @@ -0,0 +1,255 @@ +taskSemVer('.semver') + * ->increment() + * ->run(); + * ?> + * ``` + * + */ +class SemVer implements TaskInterface +{ + const SEMVER = "---\n:major: %d\n:minor: %d\n:patch: %d\n:special: '%s'\n:metadata: '%s'"; + + const REGEX = "/^\-\-\-\n:major:\s(0|[1-9]\d*)\n:minor:\s(0|[1-9]\d*)\n:patch:\s(0|[1-9]\d*)\n:special:\s'([a-zA-z0-9]*\.?(?:0|[1-9]\d*)?)'\n:metadata:\s'((?:0|[1-9]\d*)?(?:\.[a-zA-z0-9\.]*)?)'/"; + + const REGEX_STRING = '/^(?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(|-(?[0-9a-zA-Z.]+))(|\+(?[0-9a-zA-Z.]+))$/'; + + /** + * @var string + */ + protected $format = 'v%M.%m.%p%s'; + + /** + * @var string + */ + protected $specialSeparator = '-'; + + /** + * @var string + */ + protected $metadataSeparator = '+'; + + /** + * @var string + */ + protected $path; + + /** + * @var array + */ + protected $version = [ + 'major' => 0, + 'minor' => 0, + 'patch' => 0, + 'special' => '', + 'metadata' => '' + ]; + + /** + * @param string $filename + */ + public function __construct($filename = '') + { + $this->path = $filename; + + if (file_exists($this->path)) { + $semverFileContents = file_get_contents($this->path); + $this->parseFile($semverFileContents); + } + } + + /** + * @return string + */ + public function __toString() + { + $search = ['%M', '%m', '%p', '%s']; + $replace = $this->version + ['extra' => '']; + + foreach (['special', 'metadata'] as $key) { + if (!empty($replace[$key])) { + $separator = $key . 'Separator'; + $replace['extra'] .= $this->{$separator} . $replace[$key]; + } + unset($replace[$key]); + } + + return str_replace($search, $replace, $this->format); + } + + public function version($version) + { + $this->parseString($version); + return $this; + } + + /** + * @param string $format + * + * @return $this + */ + public function setFormat($format) + { + $this->format = $format; + return $this; + } + + /** + * @param string $separator + * + * @return $this + */ + public function setMetadataSeparator($separator) + { + $this->metadataSeparator = $separator; + return $this; + } + + /** + * @param string $separator + * + * @return $this + */ + public function setPrereleaseSeparator($separator) + { + $this->specialSeparator = $separator; + return $this; + } + + /** + * @param string $what + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function increment($what = 'patch') + { + switch ($what) { + case 'major': + $this->version['major']++; + $this->version['minor'] = 0; + $this->version['patch'] = 0; + break; + case 'minor': + $this->version['minor']++; + $this->version['patch'] = 0; + break; + case 'patch': + $this->version['patch']++; + break; + default: + throw new TaskException( + $this, + 'Bad argument, only one of the following is allowed: major, minor, patch' + ); + } + return $this; + } + + /** + * @param string $tag + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function prerelease($tag = 'RC') + { + if (!is_string($tag)) { + throw new TaskException($this, 'Bad argument, only strings allowed.'); + } + + $number = 0; + + if (!empty($this->version['special'])) { + list($current, $number) = explode('.', $this->version['special']); + if ($tag != $current) { + $number = 0; + } + } + + $number++; + + $this->version['special'] = implode('.', [$tag, $number]); + return $this; + } + + /** + * @param array|string $data + * + * @return $this + */ + public function metadata($data) + { + if (is_array($data)) { + $data = implode('.', $data); + } + + $this->version['metadata'] = $data; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $written = $this->dump(); + return new Result($this, (int)($written === false), $this->__toString()); + } + + /** + * @return bool + * + * @throws \Robo\Exception\TaskException + */ + protected function dump() + { + if (empty($this->path)) { + return true; + } + extract($this->version); + $semver = sprintf(self::SEMVER, $major, $minor, $patch, $special, $metadata); + if (is_writeable($this->path) === false || file_put_contents($this->path, $semver) === false) { + throw new TaskException($this, 'Failed to write semver file.'); + } + return true; + } + + protected function parseString($semverString) + { + if (!preg_match_all(self::REGEX_STRING, $semverString, $matches)) { + throw new TaskException($this, 'Bad semver value: ' . $semverString); + } + + $this->version = array_intersect_key($matches, $this->version); + $this->version = array_map(function ($item) { + return $item[0]; + }, $this->version); + } + + /** + * @throws \Robo\Exception\TaskException + */ + protected function parseFile($semverFileContents) + { + if (!preg_match_all(self::REGEX, $semverFileContents, $matches)) { + throw new TaskException($this, 'Bad semver file.'); + } + + list(, $major, $minor, $patch, $special, $metadata) = array_map('current', $matches); + $this->version = compact('major', 'minor', 'patch', 'special', 'metadata'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/loadTasks.php new file mode 100644 index 00000000..e3dc49a3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Development/loadTasks.php @@ -0,0 +1,86 @@ +task(Changelog::class, $filename); + } + + /** + * @param string $filename + * + * @return GenerateMarkdownDoc + */ + protected function taskGenDoc($filename) + { + return $this->task(GenerateMarkdownDoc::class, $filename); + } + + /** + * @param string $className + * @param string $wrapperClassName + * + * @return \Robo\Task\Development\GenerateTask + */ + protected function taskGenTask($className, $wrapperClassName = '') + { + return $this->task(GenerateTask::class, $className, $wrapperClassName); + } + + /** + * @param string $pathToSemVer + * + * @return SemVer + */ + protected function taskSemVer($pathToSemVer = '.semver') + { + return $this->task(SemVer::class, $pathToSemVer); + } + + /** + * @param int $port + * + * @return PhpServer + */ + protected function taskServer($port = 8000) + { + return $this->task(PhpServer::class, $port); + } + + /** + * @param string $filename + * + * @return PackPhar + */ + protected function taskPackPhar($filename) + { + return $this->task(PackPhar::class, $filename); + } + + /** + * @param string $tag + * + * @return GitHubRelease + */ + protected function taskGitHubRelease($tag) + { + return $this->task(GitHubRelease::class, $tag); + } + + /** + * @param string|array $url + * + * @return OpenBrowser + */ + protected function taskOpenBrowser($url) + { + return $this->task(OpenBrowser::class, $url); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Base.php new file mode 100644 index 00000000..135f39e7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Base.php @@ -0,0 +1,28 @@ +getCommand(); + return $this->executeCommand($command); + } + + abstract public function getCommand(); +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Build.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Build.php new file mode 100644 index 00000000..11eb92ab --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Build.php @@ -0,0 +1,55 @@ +taskDockerBuild()->run(); + * + * $this->taskDockerBuild('path/to/dir') + * ->tag('database') + * ->run(); + * + * ?> + * + * ``` + * + * Class Build + * @package Robo\Task\Docker + */ +class Build extends Base +{ + /** + * @var string + */ + protected $path; + + /** + * @param string $path + */ + public function __construct($path = '.') + { + $this->command = "docker build"; + $this->path = $path; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->path; + } + + /** + * @param string $tag + * + * @return $this + */ + public function tag($tag) + { + return $this->option('-t', $tag); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Commit.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Commit.php new file mode 100644 index 00000000..302f1920 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Commit.php @@ -0,0 +1,66 @@ +taskDockerCommit($containerId) + * ->name('my/database') + * ->run(); + * + * // alternatively you can take the result from DockerRun task: + * + * $result = $this->taskDockerRun('db') + * ->exec('./prepare_database.sh') + * ->run(); + * + * $task->dockerCommit($result) + * ->name('my/database') + * ->run(); + * ``` + */ +class Commit extends Base +{ + /** + * @var string + */ + protected $command = "docker commit"; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->cid . ' ' . $this->name . ' ' . $this->arguments; + } + + /** + * @param $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Exec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Exec.php new file mode 100644 index 00000000..fa67c8da --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Exec.php @@ -0,0 +1,95 @@ +taskDockerRun('test_env') + * ->detached() + * ->run(); + * + * $this->taskDockerExec($test) + * ->interactive() + * ->exec('./runtests') + * ->run(); + * + * // alternatively use commands from other tasks + * + * $this->taskDockerExec($test) + * ->interactive() + * ->exec($this->taskCodecept()->suite('acceptance')) + * ->run(); + * ?> + * ``` + * + */ +class Exec extends Base +{ + use CommandReceiver; + + /** + * @var string + */ + protected $command = "docker exec"; + + /** + * @var string + */ + protected $cid; + + /** + * @var string + */ + protected $run = ''; + + /** + * @param string|\Robo\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * @return $this + */ + public function detached() + { + $this->option('-d'); + return $this; + } + + /** + * {@inheritdoc)} + */ + public function interactive($interactive = true) + { + if ($interactive) { + $this->option('-i'); + } + return parent::interactive($interactive); + } + + /** + * @param string|\Robo\Contract\CommandInterface $command + * + * @return $this + */ + public function exec($command) + { + $this->run = $this->receiveCommand($command); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid.' '.$this->run; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Pull.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Pull.php new file mode 100644 index 00000000..32ba5b40 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Pull.php @@ -0,0 +1,33 @@ +taskDockerPull('wordpress') + * ->run(); + * + * ?> + * ``` + * + */ +class Pull extends Base +{ + /** + * @param string $image + */ + public function __construct($image) + { + $this->command = "docker pull $image "; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Remove.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Remove.php new file mode 100644 index 00000000..0a8c0ac6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Remove.php @@ -0,0 +1,32 @@ +taskDockerRemove($container) + * ->run(); + * ?> + * ``` + * + */ +class Remove extends Base +{ + /** + * @param string $container + */ + public function __construct($container) + { + $this->command = "docker rm $container "; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Result.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Result.php new file mode 100644 index 00000000..0533159a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Result.php @@ -0,0 +1,35 @@ +taskDockerRun('mysql')->run(); + * + * $result = $this->taskDockerRun('my_db_image') + * ->env('DB', 'database_name') + * ->volume('/path/to/data', '/data') + * ->detached() + * ->publish(3306) + * ->name('my_mysql') + * ->run(); + * + * // retrieve container's cid: + * $this->say("Running container ".$result->getCid()); + * + * // execute script inside container + * $result = $this->taskDockerRun('db') + * ->exec('prepare_test_data.sh') + * ->run(); + * + * $this->taskDockerCommit($result) + * ->name('test_db') + * ->run(); + * + * // link containers + * $mysql = $this->taskDockerRun('mysql') + * ->name('wp_db') // important to set name for linked container + * ->env('MYSQL_ROOT_PASSWORD', '123456') + * ->run(); + * + * $this->taskDockerRun('wordpress') + * ->link($mysql) + * ->publish(80, 8080) + * ->detached() + * ->run(); + * + * ?> + * ``` + * + */ +class Run extends Base +{ + use CommandReceiver; + + /** + * @var string + */ + protected $image = ''; + + /** + * @var string + */ + protected $run = ''; + + /** + * @var string + */ + protected $cidFile; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $dir; + + /** + * @param string $image + */ + public function __construct($image) + { + $this->image = $image; + } + + /** + * {@inheritdoc} + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + if ($this->isPrinted) { + $this->option('-i'); + } + if ($this->cidFile) { + $this->option('cidfile', $this->cidFile); + } + return trim('docker run ' . $this->arguments . ' ' . $this->image . ' ' . $this->run); + } + + /** + * @return $this + */ + public function detached() + { + $this->option('-d'); + return $this; + } + + /** + * {@inheritdoc)} + */ + public function interactive($interactive = true) + { + if ($interactive) { + $this->option('-i'); + } + return parent::interactive($interactive); + } + + /** + * @param string|\Robo\Contract\CommandInterface $run + * + * @return $this + */ + public function exec($run) + { + $this->run = $this->receiveCommand($run); + return $this; + } + + /** + * @param string $from + * @param null|string $to + * + * @return $this + */ + public function volume($from, $to = null) + { + $volume = $to ? "$from:$to" : $from; + $this->option('-v', $volume); + return $this; + } + + /** + * Set environment variables. + * n.b. $this->env($variable, $value) also available here, + * inherited from ExecTrait. + * + * @param array $env + * @return type + */ + public function envVars(array $env) + { + foreach ($env as $variable => $value) { + $this->setDockerEnv($variable, $value); + } + return $this; + } + + /** + * @param string $variable + * @param null|string $value + * + * @return $this + */ + protected function setDockerEnv($variable, $value = null) + { + $env = $value ? "$variable=$value" : $variable; + return $this->option("-e", $env); + } + + /** + * @param null|int $port + * @param null|int $portTo + * + * @return $this + */ + public function publish($port = null, $portTo = null) + { + if (!$port) { + return $this->option('-P'); + } + if ($portTo) { + $port = "$port:$portTo"; + } + return $this->option('-p', $port); + } + + /** + * @param string $dir + * + * @return $this + */ + public function containerWorkdir($dir) + { + return $this->option('-w', $dir); + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + return $this->option('-u', $user); + } + + /** + * @return $this + */ + public function privileged() + { + return $this->option('--privileged'); + } + + /** + * @param string $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this->option('name', $name); + } + + /** + * @param string|\Robo\Task\Docker\Result $name + * @param string $alias + * + * @return $this + */ + public function link($name, $alias) + { + if ($name instanceof Result) { + $name = $name->getContainerName(); + } + $this->option('link', "$name:$alias"); + return $this; + } + + /** + * @param string $dir + * + * @return $this + */ + public function tmpDir($dir) + { + $this->dir = $dir; + return $this; + } + + /** + * @return string + */ + public function getTmpDir() + { + return $this->dir ? $this->dir : sys_get_temp_dir(); + } + + /** + * @return string + */ + public function getUniqId() + { + return uniqid(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->cidFile = $this->getTmpDir() . '/docker_' . $this->getUniqId() . '.cid'; + $result = parent::run(); + $result['cid'] = $this->getCid(); + return $result; + } + + /** + * @return null|string + */ + protected function getCid() + { + if (!$this->cidFile || !file_exists($this->cidFile)) { + return null; + } + $cid = trim(file_get_contents($this->cidFile)); + @unlink($this->cidFile); + return $cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Start.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Start.php new file mode 100644 index 00000000..ef19d74d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Start.php @@ -0,0 +1,41 @@ +taskDockerStart($cidOrResult) + * ->run(); + * ?> + * ``` + */ +class Start extends Base +{ + /** + * @var string + */ + protected $command = "docker start"; + + /** + * @var null|string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Stop.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Stop.php new file mode 100644 index 00000000..4d0d436d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/Stop.php @@ -0,0 +1,41 @@ +taskDockerStop($cidOrResult) + * ->run(); + * ?> + * ``` + */ +class Stop extends Base +{ + /** + * @var string + */ + protected $command = "docker stop"; + + /** + * @var null|string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/loadTasks.php new file mode 100644 index 00000000..e58f5ef0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Docker/loadTasks.php @@ -0,0 +1,85 @@ +task(Run::class, $image); + } + + /** + * @param string $image + * + * @return \Robo\Task\Docker\Pull + */ + protected function taskDockerPull($image) + { + return $this->task(Pull::class, $image); + } + + /** + * @param string $path + * + * @return \Robo\Task\Docker\Build + */ + protected function taskDockerBuild($path = '.') + { + return $this->task(Build::class, $path); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Stop + */ + protected function taskDockerStop($cidOrResult) + { + return $this->task(Stop::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Commit + */ + protected function taskDockerCommit($cidOrResult) + { + return $this->task(Commit::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Start + */ + protected function taskDockerStart($cidOrResult) + { + return $this->task(Start::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Remove + */ + protected function taskDockerRemove($cidOrResult) + { + return $this->task(Remove::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Exec + */ + protected function taskDockerExec($cidOrResult) + { + return $this->task(Exec::class, $cidOrResult); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Concat.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Concat.php new file mode 100644 index 00000000..12b1eca0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Concat.php @@ -0,0 +1,101 @@ +taskConcat([ + * 'web/assets/screen.css', + * 'web/assets/print.css', + * 'web/assets/theme.css' + * ]) + * ->to('web/assets/style.css') + * ->run() + * ?> + * ``` + */ +class Concat extends BaseTask +{ + use ResourceExistenceChecker; + + /** + * @var array|Iterator + */ + protected $files; + + /** + * @var string + */ + protected $dst; + + /** + * Constructor. + * + * @param array|Iterator $files + */ + public function __construct($files) + { + $this->files = $files; + } + + /** + * set the destination file + * + * @param string $dst + * + * @return $this + */ + public function to($dst) + { + $this->dst = $dst; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (is_null($this->dst) || "" === $this->dst) { + return Result::error($this, 'You must specify a destination file with to() method.'); + } + + if (!$this->checkResources($this->files, 'file')) { + return Result::error($this, 'Source files are missing!'); + } + + if (file_exists($this->dst) && !is_writable($this->dst)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + + $dump = ''; + + foreach ($this->files as $path) { + foreach (glob($path) as $file) { + $dump .= file_get_contents($file) . "\n"; + } + } + + $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]); + + $dst = $this->dst . '.part'; + $write_result = file_put_contents($dst, $dump); + + if (false === $write_result) { + @unlink($dst); + return Result::error($this, 'File write failed.'); + } + // Cannot be cross-volume; should always succeed. + @rename($dst, $this->dst); + + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Replace.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Replace.php new file mode 100644 index 00000000..0107df13 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Replace.php @@ -0,0 +1,141 @@ +taskReplaceInFile('VERSION') + * ->from('0.2.0') + * ->to('0.3.0') + * ->run(); + * + * $this->taskReplaceInFile('README.md') + * ->from(date('Y')-1) + * ->to(date('Y')) + * ->run(); + * + * $this->taskReplaceInFile('config.yml') + * ->regex('~^service:~') + * ->to('services:') + * ->run(); + * + * $this->taskReplaceInFile('box/robo.txt') + * ->from(array('##dbname##', '##dbhost##')) + * ->to(array('robo', 'localhost')) + * ->run(); + * ?> + * ``` + */ +class Replace extends BaseTask +{ + /** + * @var string + */ + protected $filename; + + /** + * @var string|string[] + */ + protected $from; + + /** + * @var string|string[] + */ + protected $to; + + /** + * @var string + */ + protected $regex; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * String(s) to be replaced. + * + * @param string|string[] $from + * + * @return $this + */ + public function from($from) + { + $this->from = $from; + return $this; + } + + /** + * Value(s) to be set as a replacement. + * + * @param string|string[] $to + * + * @return $this + */ + public function to($to) + { + $this->to = $to; + return $this; + } + + /** + * Regex to match string to be replaced. + * + * @param string $regex + * + * @return $this + */ + public function regex($regex) + { + $this->regex = $regex; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!file_exists($this->filename)) { + $this->printTaskError('File {filename} does not exist', ['filename' => $this->filename]); + return false; + } + + $text = file_get_contents($this->filename); + if ($this->regex) { + $text = preg_replace($this->regex, $this->to, $text, -1, $count); + } else { + $text = str_replace($this->from, $this->to, $text, $count); + } + if ($count > 0) { + $res = file_put_contents($this->filename, $text); + if ($res === false) { + return Result::error($this, "Error writing to file {filename}.", ['filename' => $this->filename]); + } + $this->printTaskSuccess("{filename} updated. {count} items replaced", ['filename' => $this->filename, 'count' => $count]); + } else { + $this->printTaskInfo("{filename} unchanged. {count} items replaced", ['filename' => $this->filename, 'count' => $count]); + } + return Result::success($this, '', ['replaced' => $count]); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/TmpFile.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/TmpFile.php new file mode 100644 index 00000000..4a18691d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/TmpFile.php @@ -0,0 +1,72 @@ +collectionBuilder(); + * $tmpFilePath = $collection->taskTmpFile() + * ->line('-----') + * ->line(date('Y-m-d').' '.$title) + * ->line('----') + * ->getPath(); + * $collection->run(); + * ?> + * ``` + */ +class TmpFile extends Write implements CompletionInterface +{ + /** + * @param string $filename + * @param string $extension + * @param string $baseDir + * @param bool $includeRandomPart + */ + public function __construct($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true) + { + if (empty($baseDir)) { + $baseDir = sys_get_temp_dir(); + } + if ($includeRandomPart) { + $random = static::randomString(); + $filename = "{$filename}_{$random}"; + } + $filename .= $extension; + parent::__construct("{$baseDir}/{$filename}"); + } + + /** + * Generate a suitably random string to use as the suffix for our + * temporary file. + * + * @param int $length + * + * @return string + */ + private static function randomString($length = 12) + { + return substr(str_shuffle('23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'), 0, $length); + } + + /** + * Delete this file when our collection completes. + * If this temporary file is not part of a collection, + * then it will be deleted when the program terminates, + * presuming that it was created by taskTmpFile() or _tmpFile(). + */ + public function complete() + { + unlink($this->getPath()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Write.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Write.php new file mode 100644 index 00000000..dc2199f9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/Write.php @@ -0,0 +1,335 @@ +taskWriteToFile('blogpost.md') + * ->line('-----') + * ->line(date('Y-m-d').' '.$title) + * ->line('----') + * ->run(); + * ?> + * ``` + */ +class Write extends BaseTask +{ + /** + * @var array + */ + protected $stack = []; + + /** + * @var string + */ + protected $filename; + + /** + * @var bool + */ + protected $append = false; + + /** + * @var null|string + */ + protected $originalContents = null; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * @param bool $append + * + * @return $this + */ + public function append($append = true) + { + $this->append = $append; + return $this; + } + + /** + * add a line. + * + * @param string $line + * + * @return $this The current instance + */ + public function line($line) + { + $this->text($line . "\n"); + return $this; + } + + /** + * add more lines. + * + * @param array $lines + * + * @return $this The current instance + */ + public function lines(array $lines) + { + $this->text(implode("\n", $lines) . "\n"); + return $this; + } + + /** + * add a text. + * + * @param string $text + * + * @return $this The current instance + */ + public function text($text) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * add a text from a file. + * + * Note that the file is read in the run() method of this task. + * To load text from the current state of a file (e.g. one that may + * be deleted or altered by other tasks prior the execution of this one), + * use: + * $task->text(file_get_contents($filename)); + * + * @param string $filename + * + * @return $this The current instance + */ + public function textFromFile($filename) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * substitute a placeholder with value, placeholder must be enclosed by `{}`. + * + * @param string $name + * @param string $val + * + * @return $this The current instance + */ + public function place($name, $val) + { + $this->replace('{'.$name.'}', $val); + + return $this; + } + + /** + * replace any string with value. + * + * @param string $string + * @param string $replacement + * + * @return $this The current instance + */ + public function replace($string, $replacement) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * replace any string with value using regular expression. + * + * @param string $pattern + * @param string $replacement + * + * @return $this The current instance + */ + public function regexReplace($pattern, $replacement) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * Append the provided text to the end of the buffer if the provided + * regex pattern matches any text already in the buffer. + * + * @param string $pattern + * @param string $text + * + * @return $this + */ + public function appendIfMatches($pattern, $text) + { + $this->stack[] = array_merge(['appendIfMatchesCollect'], [$pattern, $text, true]); + return $this; + } + + /** + * Append the provided text to the end of the buffer unless the provided + * regex pattern matches any text already in the buffer. + * + * @param string $pattern + * @param string $text + * + * @return $this + */ + public function appendUnlessMatches($pattern, $text) + { + $this->stack[] = array_merge(['appendIfMatchesCollect'], [$pattern, $text, false]); + return $this; + } + + /** + * @param $contents string + * @param $filename string + * + * @return string + */ + protected function textFromFileCollect($contents, $filename) + { + if (file_exists($filename)) { + $contents .= file_get_contents($filename); + } + return $contents; + } + + /** + * @param string|string[] $contents + * @param string|string[] $string + * @param string|string[] $replacement + * + * @return string|string[] + */ + protected function replaceCollect($contents, $string, $replacement) + { + return str_replace($string, $replacement, $contents); + } + + /** + * @param string|string[] $contents + * @param string|string[] $pattern + * @param string|string[] $replacement + * + * @return string|string[] + */ + protected function regexReplaceCollect($contents, $pattern, $replacement) + { + return preg_replace($pattern, $replacement, $contents); + } + + /** + * @param string $contents + * @param string $text + * + * @return string + */ + protected function textCollect($contents, $text) + { + return $contents . $text; + } + + /** + * @param string $contents + * @param string $pattern + * @param string $text + * @param bool $shouldMatch + * + * @return string + */ + protected function appendIfMatchesCollect($contents, $pattern, $text, $shouldMatch) + { + if (preg_match($pattern, $contents) == $shouldMatch) { + $contents .= $text; + } + return $contents; + } + + /** + * @return string + */ + public function originalContents() + { + if (!isset($this->originalContents)) { + $this->originalContents = ''; + if (file_exists($this->filename)) { + $this->originalContents = file_get_contents($this->filename); + } + } + return $this->originalContents; + } + + /** + * @return bool + */ + public function wouldChange() + { + return $this->originalContents() != $this->getContentsToWrite(); + } + + /** + * @return string + */ + protected function getContentsToWrite() + { + $contents = ""; + if ($this->append) { + $contents = $this->originalContents(); + } + foreach ($this->stack as $action) { + $command = array_shift($action); + if (method_exists($this, $command)) { + array_unshift($action, $contents); + $contents = call_user_func_array([$this, $command], $action); + } + } + return $contents; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo("Writing to {filename}.", ['filename' => $this->filename]); + $contents = $this->getContentsToWrite(); + if (!file_exists(dirname($this->filename))) { + mkdir(dirname($this->filename), 0777, true); + } + $res = file_put_contents($this->filename, $contents); + if ($res === false) { + return Result::error($this, "File {$this->filename} couldn't be created"); + } + + return Result::success($this); + } + + /** + * @return string + */ + public function getPath() + { + return $this->filename; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/loadTasks.php new file mode 100644 index 00000000..c5f39c95 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/File/loadTasks.php @@ -0,0 +1,48 @@ +task(Concat::class, $files); + } + + /** + * @param string $file + * + * @return \Robo\Task\File\Replace + */ + protected function taskReplaceInFile($file) + { + return $this->task(Replace::class, $file); + } + + /** + * @param string $file + * + * @return \Robo\Task\File\Write + */ + protected function taskWriteToFile($file) + { + return $this->task(Write::class, $file); + } + + /** + * @param string $filename + * @param string $extension + * @param string $baseDir + * @param bool $includeRandomPart + * + * @return \Robo\Task\File\TmpFile + */ + protected function taskTmpFile($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true) + { + return $this->task(TmpFile::class, $filename, $extension, $baseDir, $includeRandomPart); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/BaseDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/BaseDir.php new file mode 100644 index 00000000..434334d7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/BaseDir.php @@ -0,0 +1,30 @@ +dirs = $dirs + : $this->dirs[] = $dirs; + + $this->fs = new sfFilesystem(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CleanDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CleanDir.php new file mode 100644 index 00000000..762f8550 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CleanDir.php @@ -0,0 +1,63 @@ +taskCleanDir(['tmp','logs'])->run(); + * // as shortcut + * $this->_cleanDir('app/cache'); + * ?> + * ``` + */ +class CleanDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $dir) { + $this->emptyDir($dir); + $this->printTaskInfo("Cleaned {dir}", ['dir' => $dir]); + } + return Result::success($this); + } + + /** + * @param string $path + */ + protected function emptyDir($path) + { + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path), + \RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($iterator as $path) { + if ($path->isDir()) { + $dir = (string)$path; + if (basename($dir) === '.' || basename($dir) === '..') { + continue; + } + $this->fs->remove($dir); + } else { + $file = (string)$path; + if (basename($file) === '.gitignore' || basename($file) === '.gitkeep') { + continue; + } + $this->fs->remove($file); + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CopyDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CopyDir.php new file mode 100644 index 00000000..08482222 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/CopyDir.php @@ -0,0 +1,162 @@ +taskCopyDir(['dist/config' => 'config'])->run(); + * // as shortcut + * $this->_copyDir('dist/config', 'config'); + * ?> + * ``` + */ +class CopyDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * Explicitly declare our consturctor, so that + * our copyDir() method does not look like a php4 constructor. + */ + public function __construct($dirs) + { + parent::__construct($dirs); + } + + /** + * @var int + */ + protected $chmod = 0755; + + /** + * Files to exclude on copying. + * + * @var string[] + */ + protected $exclude = []; + + /** + * Overwrite destination files newer than source files. + */ + protected $overwrite = true; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $src => $dst) { + $this->copyDir($src, $dst); + $this->printTaskInfo('Copied from {source} to {destination}', ['source' => $src, 'destination' => $dst]); + } + return Result::success($this); + } + + /** + * Sets the default folder permissions for the destination if it doesn't exist + * + * @link http://en.wikipedia.org/wiki/Chmod + * @link http://php.net/manual/en/function.mkdir.php + * @link http://php.net/manual/en/function.chmod.php + * + * @param int $value + * + * @return $this + */ + public function dirPermissions($value) + { + $this->chmod = (int)$value; + return $this; + } + + /** + * List files to exclude. + * + * @param string[] $exclude + * + * @return $this + */ + public function exclude($exclude = []) + { + $this->exclude = $this->simplifyForCompare($exclude); + return $this; + } + + /** + * Destination files newer than source files are overwritten. + * + * @param bool $overwrite + * + * @return $this + */ + public function overwrite($overwrite) + { + $this->overwrite = $overwrite; + return $this; + } + + /** + * Copies a directory to another location. + * + * @param string $src Source directory + * @param string $dst Destination directory + * @param string $parent Parent directory + * + * @throws \Robo\Exception\TaskException + */ + protected function copyDir($src, $dst, $parent = '') + { + $dir = @opendir($src); + if (false === $dir) { + throw new TaskException($this, "Cannot open source directory '" . $src . "'"); + } + if (!is_dir($dst)) { + mkdir($dst, $this->chmod, true); + } + while (false !== ($file = readdir($dir))) { + // Support basename and full path exclusion. + if ($this->excluded($file, $src, $parent)) { + continue; + } + $srcFile = $src . '/' . $file; + $destFile = $dst . '/' . $file; + if (is_dir($srcFile)) { + $this->copyDir($srcFile, $destFile, $parent . $file . DIRECTORY_SEPARATOR); + } else { + $this->fs->copy($srcFile, $destFile, $this->overwrite); + } + } + closedir($dir); + } + + /** + * Check to see if the current item is excluded. + */ + protected function excluded($file, $src, $parent) + { + return + ($file == '.') || + ($file == '..') || + in_array($file, $this->exclude) || + in_array($this->simplifyForCompare($parent . $file), $this->exclude) || + in_array($this->simplifyForCompare($src . DIRECTORY_SEPARATOR . $file), $this->exclude); + } + + /** + * Avoid problems comparing paths on Windows that may have a + * combination of DIRECTORY_SEPARATOR and /. + */ + protected function simplifyForCompare($item) + { + return str_replace(DIRECTORY_SEPARATOR, '/', $item); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/DeleteDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/DeleteDir.php new file mode 100644 index 00000000..25cf007b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/DeleteDir.php @@ -0,0 +1,36 @@ +taskDeleteDir('tmp')->run(); + * // as shortcut + * $this->_deleteDir(['tmp', 'log']); + * ?> + * ``` + */ +class DeleteDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $dir) { + $this->fs->remove($dir); + $this->printTaskInfo("Deleted {dir}...", ['dir' => $dir]); + } + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FilesystemStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FilesystemStack.php new file mode 100644 index 00000000..8663e245 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FilesystemStack.php @@ -0,0 +1,154 @@ +taskFilesystemStack() + * ->mkdir('logs') + * ->touch('logs/.gitignore') + * ->chgrp('www', 'www-data') + * ->symlink('/var/log/nginx/error.log', 'logs/error.log') + * ->run(); + * + * // one line + * $this->_touch('.gitignore'); + * $this->_mkdir('logs'); + * + * ?> + * ``` + * + * @method $this mkdir(string|array|\Traversable $dir, int $mode = 0777) + * @method $this touch(string|array|\Traversable $file, int $time = null, int $atime = null) + * @method $this copy(string $from, string $to, bool $force = false) + * @method $this chmod(string|array|\Traversable $file, int $permissions, int $umask = 0000, bool $recursive = false) + * @method $this chgrp(string|array|\Traversable $file, string $group, bool $recursive = false) + * @method $this chown(string|array|\Traversable $file, string $user, bool $recursive = false) + * @method $this remove(string|array|\Traversable $file) + * @method $this rename(string $from, string $to, bool $force = false) + * @method $this symlink(string $from, string $to, bool $copyOnWindows = false) + * @method $this mirror(string $from, string $to, \Traversable $iterator = null, array $options = []) + */ +class FilesystemStack extends StackBasedTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var \Symfony\Component\Filesystem\Filesystem + */ + protected $fs; + + public function __construct() + { + $this->fs = new sfFilesystem(); + } + + /** + * @return \Symfony\Component\Filesystem\Filesystem + */ + protected function getDelegate() + { + return $this->fs; + } + + /** + * @param string $from + * @param string $to + * @param bool $force + */ + protected function _copy($from, $to, $force = false) + { + $this->fs->copy($from, $to, $force); + } + + /** + * @param string|string[]|\Traversable $file + * @param int $permissions + * @param int $umask + * @param bool $recursive + */ + protected function _chmod($file, $permissions, $umask = 0000, $recursive = false) + { + $this->fs->chmod($file, $permissions, $umask, $recursive); + } + + /** + * @param string|string[]|\Traversable $file + * @param string $group + * @param bool $recursive + */ + protected function _chgrp($file, $group, $recursive = null) + { + $this->fs->chgrp($file, $group, $recursive); + } + + /** + * @param string|string[]|\Traversable $file + * @param string $user + * @param bool $recursive + */ + protected function _chown($file, $user, $recursive = null) + { + $this->fs->chown($file, $user, $recursive); + } + + /** + * @param string $origin + * @param string $target + * @param bool $overwrite + * + * @return null|true|\Robo\Result + */ + protected function _rename($origin, $target, $overwrite = false) + { + // we check that target does not exist + if ((!$overwrite && is_readable($target)) || (file_exists($target) && !is_writable($target))) { + throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); + } + + // Due to a bug (limitation) in PHP, cross-volume renames do not work. + // See: https://bugs.php.net/bug.php?id=54097 + if (true !== @rename($origin, $target)) { + return $this->crossVolumeRename($origin, $target); + } + return true; + } + + /** + * @param string $origin + * @param string $target + * + * @return null|\Robo\Result + */ + protected function crossVolumeRename($origin, $target) + { + // First step is to try to get rid of the target. If there + // is a single, deletable file, then we will just unlink it. + if (is_file($target)) { + unlink($target); + } + // If the target still exists, we will try to delete it. + // TODO: Note that if this fails partway through, then we cannot + // adequately rollback. Perhaps we need to preflight the operation + // and determine if everything inside of $target is writable. + if (file_exists($target)) { + $this->fs->remove($target); + } + + /** @var \Robo\Result $result */ + $result = $this->collectionBuilder()->taskCopyDir([$origin => $target])->run(); + if (!$result->wasSuccessful()) { + return $result; + } + $this->fs->remove($origin); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FlattenDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FlattenDir.php new file mode 100644 index 00000000..6e885112 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/FlattenDir.php @@ -0,0 +1,294 @@ +taskFlattenDir(['assets/*.min.js' => 'dist'])->run(); + * // or use shortcut + * $this->_flattenDir('assets/*.min.js', 'dist'); + * ?> + * ``` + * + * You can also define the target directory with an additional method, instead of + * key/value pairs. More similar to the gulp-flatten syntax: + * + * ``` php + * taskFlattenDir(['assets/*.min.js']) + * ->to('dist') + * ->run(); + * ?> + * ``` + * + * You can also append parts of the parent directories to the target path. If you give + * the value `1` to the `includeParents()` method, then the top parent will be appended + * to the target directory resulting in a path such as `dist/assets/asset-library1.min.js`. + * + * If you give a negative number, such as `-1` (the same as specifying `array(0, 1)` then + * the bottom parent will be appended, resulting in a path such as + * `dist/asset-library1/asset-library1.min.js`. + * + * The top parent directory will always be starting from the relative path to the current + * directory. You can override that with the `parentDir()` method. If in the above example + * you would specify `assets`, then the top parent directory would be `asset-library1`. + * + * ``` php + * taskFlattenDir(['assets/*.min.js' => 'dist']) + * ->parentDir('assets') + * ->includeParents(1) + * ->run(); + * ?> + * ``` + */ +class FlattenDir extends BaseDir +{ + /** + * @var int + */ + protected $chmod = 0755; + + /** + * @var int[] + */ + protected $parents = array(0, 0); + + /** + * @var string + */ + protected $parentDir = ''; + + /** + * @var string + */ + protected $to; + + /** + * {@inheritdoc} + */ + public function __construct($dirs) + { + parent::__construct($dirs); + $this->parentDir = getcwd(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + // find the files + $files = $this->findFiles($this->dirs); + + // copy the files + $this->copyFiles($files); + + $fileNoun = count($files) == 1 ? ' file' : ' files'; + $this->printTaskSuccess("Copied {count} $fileNoun to {destination}", ['count' => count($files), 'destination' => $this->to]); + + return Result::success($this); + } + + /** + * Sets the default folder permissions for the destination if it does not exist. + * + * @link http://en.wikipedia.org/wiki/Chmod + * @link http://php.net/manual/en/function.mkdir.php + * @link http://php.net/manual/en/function.chmod.php + * + * @param int $permission + * + * @return $this + */ + public function dirPermissions($permission) + { + $this->chmod = (int) $permission; + + return $this; + } + + /** + * Sets the value from which direction and how much parent dirs should be included. + * Accepts a positive or negative integer or an array with two integer values. + * + * @param int|int[] $parents + * + * @return $this + * + * @throws TaskException + */ + public function includeParents($parents) + { + if (is_int($parents)) { + // if an integer is given check whether it is for top or bottom parent + if ($parents >= 0) { + $this->parents[0] = $parents; + return $this; + } + $this->parents[1] = 0 - $parents; + return $this; + } + + if (is_array($parents)) { + // check if the array has two values no more, no less + if (count($parents) == 2) { + $this->parents = $parents; + return $this; + } + } + + throw new TaskException($this, 'includeParents expects an integer or an array with two values'); + } + + /** + * Sets the parent directory from which the relative parent directories will be calculated. + * + * @param string $dir + * + * @return $this + */ + public function parentDir($dir) + { + if (!$this->fs->isAbsolutePath($dir)) { + // attach the relative path to current working directory + $dir = getcwd().'/'.$dir; + } + $this->parentDir = $dir; + + return $this; + } + + /** + * Sets the target directory where the files will be copied to. + * + * @param string $target + * + * @return $this + */ + public function to($target) + { + $this->to = rtrim($target, '/'); + + return $this; + } + + /** + * @param array $dirs + * + * @return array|\Robo\Result + * + * @throws \Robo\Exception\TaskException + */ + protected function findFiles($dirs) + { + $files = array(); + + // find the files + foreach ($dirs as $k => $v) { + // reset finder + $finder = new Finder(); + + $dir = $k; + $to = $v; + // check if target was given with the to() method instead of key/value pairs + if (is_int($k)) { + $dir = $v; + if (isset($this->to)) { + $to = $this->to; + } else { + throw new TaskException($this, 'target directory is not defined'); + } + } + + try { + $finder->files()->in($dir); + } catch (\InvalidArgumentException $e) { + // if finder cannot handle it, try with in()->name() + if (strpos($dir, '/') === false) { + $dir = './'.$dir; + } + $parts = explode('/', $dir); + $new_dir = implode('/', array_slice($parts, 0, -1)); + try { + $finder->files()->in($new_dir)->name(array_pop($parts)); + } catch (\InvalidArgumentException $e) { + return Result::fromException($this, $e); + } + } + + foreach ($finder as $file) { + // store the absolute path as key and target as value in the files array + $files[$file->getRealpath()] = $this->getTarget($file->getRealPath(), $to); + } + $fileNoun = count($files) == 1 ? ' file' : ' files'; + $this->printTaskInfo("Found {count} $fileNoun in {dir}", ['count' => count($files), 'dir' => $dir]); + } + + return $files; + } + + /** + * @param string $file + * @param string $to + * + * @return string + */ + protected function getTarget($file, $to) + { + $target = $to.'/'.basename($file); + if ($this->parents !== array(0, 0)) { + // if the parent is set, create additional directories inside target + // get relative path to parentDir + $rel_path = $this->fs->makePathRelative(dirname($file), $this->parentDir); + // get top parents and bottom parents + $parts = explode('/', rtrim($rel_path, '/')); + $prefix_dir = ''; + $prefix_dir .= ($this->parents[0] > 0 ? implode('/', array_slice($parts, 0, $this->parents[0])).'/' : ''); + $prefix_dir .= ($this->parents[1] > 0 ? implode('/', array_slice($parts, (0 - $this->parents[1]), $this->parents[1])) : ''); + $prefix_dir = rtrim($prefix_dir, '/'); + $target = $to.'/'.$prefix_dir.'/'.basename($file); + } + + return $target; + } + + /** + * @param array $files + */ + protected function copyFiles($files) + { + // copy the files + foreach ($files as $from => $to) { + // check if target dir exists + if (!is_dir(dirname($to))) { + $this->fs->mkdir(dirname($to), $this->chmod); + } + $this->fs->copy($from, $to); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/MirrorDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/MirrorDir.php new file mode 100644 index 00000000..4eda9097 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/MirrorDir.php @@ -0,0 +1,40 @@ +taskMirrorDir(['dist/config/' => 'config/'])->run(); + * // or use shortcut + * $this->_mirrorDir('dist/config/', 'config/'); + * + * ?> + * ``` + */ +class MirrorDir extends BaseDir +{ + /** + * {@inheritdoc} + */ + public function run() + { + foreach ($this->dirs as $src => $dst) { + $this->fs->mirror( + $src, + $dst, + null, + [ + 'override' => true, + 'copy_on_windows' => true, + 'delete' => true + ] + ); + $this->printTaskInfo("Mirrored from {source} to {destination}", ['source' => $src, 'destination' => $dst]); + } + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/TmpDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/TmpDir.php new file mode 100644 index 00000000..104318de --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/TmpDir.php @@ -0,0 +1,173 @@ +run(). + * $collection = $this->collectionBuilder(); + * $tmpPath = $collection->tmpDir()->getPath(); + * $collection->taskFilesystemStack() + * ->mkdir("$tmpPath/log") + * ->touch("$tmpPath/log/error.txt"); + * $collection->run(); + * // as shortcut (deleted when program exits) + * $tmpPath = $this->_tmpDir(); + * ?> + * ``` + */ +class TmpDir extends BaseDir implements CompletionInterface +{ + /** + * @var string + */ + protected $base; + + /** + * @var string + */ + protected $prefix; + + /** + * @var bool + */ + protected $cwd; + + /** + * @var string + */ + protected $savedWorkingDirectory; + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + */ + public function __construct($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + if (empty($base)) { + $base = sys_get_temp_dir(); + } + $path = "{$base}/{$prefix}"; + if ($includeRandomPart) { + $path = static::randomLocation($path); + } + parent::__construct(["$path"]); + } + + /** + * Add a random part to a path, ensuring that the directory does + * not (currently) exist. + * + * @param string $path The base/prefix path to add a random component to + * @param int $length Number of digits in the random part + * + * @return string + */ + protected static function randomLocation($path, $length = 12) + { + $random = static::randomString($length); + while (is_dir("{$path}_{$random}")) { + $random = static::randomString($length); + } + return "{$path}_{$random}"; + } + + /** + * Generate a suitably random string to use as the suffix for our + * temporary directory. + * + * @param int $length + * + * @return string + */ + protected static function randomString($length = 12) + { + return substr(str_shuffle('23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'), 0, max($length, 3)); + } + + /** + * Flag that we should cwd to the temporary directory when it is + * created, and restore the old working directory when it is deleted. + * + * @param bool $shouldChangeWorkingDirectory + * + * @return $this + */ + public function cwd($shouldChangeWorkingDirectory = true) + { + $this->cwd = $shouldChangeWorkingDirectory; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Save the current working directory + $this->savedWorkingDirectory = getcwd(); + foreach ($this->dirs as $dir) { + $this->fs->mkdir($dir); + $this->printTaskInfo("Created {dir}...", ['dir' => $dir]); + + // Change the current working directory, if requested + if ($this->cwd) { + chdir($dir); + } + } + + return Result::success($this, '', ['path' => $this->getPath()]); + } + + protected function restoreWorkingDirectory() + { + // Restore the current working directory, if we redirected it. + if ($this->cwd) { + chdir($this->savedWorkingDirectory); + } + } + + protected function deleteTmpDir() + { + foreach ($this->dirs as $dir) { + $this->fs->remove($dir); + } + } + + /** + * Delete this directory when our collection completes. + * If this temporary directory is not part of a collection, + * then it will be deleted when the program terminates, + * presuming that it was created by taskTmpDir() or _tmpDir(). + */ + public function complete() + { + $this->restoreWorkingDirectory(); + $this->deleteTmpDir(); + } + + /** + * Get a reference to the path to the temporary directory, so that + * it may be used to create other tasks. Note that the directory + * is not actually created until the task runs. + * + * @return string + */ + public function getPath() + { + return $this->dirs[0]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/WorkDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/WorkDir.php new file mode 100644 index 00000000..4b75c6ed --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/WorkDir.php @@ -0,0 +1,126 @@ +collectionBuilder(); + * $workingPath = $collection->workDir("build")->getPath(); + * $collection->taskFilesystemStack() + * ->mkdir("$workingPath/log") + * ->touch("$workingPath/log/error.txt"); + * $collection->run(); + * ?> + * ``` + */ +class WorkDir extends TmpDir implements RollbackInterface, BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $finalDestination; + + /** + * @param string $finalDestination + */ + public function __construct($finalDestination) + { + $this->finalDestination = $finalDestination; + + // Create a temporary directory to work in. We will place our + // temporary directory in the same location as the final destination + // directory, so that the work directory can be moved into place + // without having to be copied, e.g. in a cross-volume rename scenario. + parent::__construct(basename($finalDestination), dirname($finalDestination)); + } + + /** + * Create our working directory. + * + * @return \Robo\Result + */ + public function run() + { + // Destination cannot be empty + if (empty($this->finalDestination)) { + return Result::error($this, "Destination directory not specified."); + } + + // Before we do anything else, ensure that any directory in the + // final destination is writable, so that we can at a minimum + // move it out of the way before placing our results there. + if (is_dir($this->finalDestination)) { + if (!is_writable($this->finalDestination)) { + return Result::error($this, "Destination directory {dir} exists and cannot be overwritten.", ['dir' => $this->finalDestination]); + } + } + + return parent::run(); + } + + /** + * Move our working directory into its final destination once the + * collection it belongs to completes. + */ + public function complete() + { + $this->restoreWorkingDirectory(); + + // Delete the final destination, if it exists. + // Move it out of the way first, in case it cannot + // be completely deleted. + if (file_exists($this->finalDestination)) { + $temporaryLocation = static::randomLocation($this->finalDestination . '_TO_DELETE_'); + // This should always work, because we already created a temporary + // folder in the parent directory of the final destination, and we + // have already checked to confirm that the final destination is + // writable. + rename($this->finalDestination, $temporaryLocation); + // This may silently fail, leaving artifacts behind, if there + // are permissions problems with some items somewhere inside + // the folder being deleted. + $this->fs->remove($temporaryLocation); + } + + // Move our working directory over the final destination. + // This should never be a cross-volume rename, so this should + // always succeed. + $workDir = reset($this->dirs); + if (file_exists($workDir)) { + rename($workDir, $this->finalDestination); + } + } + + /** + * Delete our working directory + */ + public function rollback() + { + $this->restoreWorkingDirectory(); + $this->deleteTmpDir(); + } + + /** + * Get a reference to the path to the temporary directory, so that + * it may be used to create other tasks. Note that the directory + * is not actually created until the task runs. + * + * @return string + */ + public function getPath() + { + return $this->dirs[0]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadShortcuts.php new file mode 100644 index 00000000..fe72ce5a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadShortcuts.php @@ -0,0 +1,159 @@ +taskCopyDir([$src => $dst])->run(); + } + + /** + * @param string $src + * @param string $dst + * + * @return \Robo\Result + */ + protected function _mirrorDir($src, $dst) + { + return $this->taskMirrorDir([$src => $dst])->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _deleteDir($dir) + { + return $this->taskDeleteDir($dir)->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _cleanDir($dir) + { + return $this->taskCleanDir($dir)->run(); + } + + /** + * @param string $from + * @param string $to + * @param bool $overwrite + * + * @return \Robo\Result + */ + protected function _rename($from, $to, $overwrite = false) + { + return $this->taskFilesystemStack()->rename($from, $to, $overwrite)->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _mkdir($dir) + { + return $this->taskFilesystemStack()->mkdir($dir)->run(); + } + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return string + */ + protected function _tmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + $result = $this->taskTmpDir($prefix, $base, $includeRandomPart)->run(); + return isset($result['path']) ? $result['path'] : ''; + } + + /** + * @param string $file + * + * @return \Robo\Result + */ + protected function _touch($file) + { + return $this->taskFilesystemStack()->touch($file)->run(); + } + + /** + * @param string|string[] $file + * + * @return \Robo\Result + */ + protected function _remove($file) + { + return $this->taskFilesystemStack()->remove($file)->run(); + } + + /** + * @param string|string[] $file + * @param string $group + * + * @return \Robo\Result + */ + protected function _chgrp($file, $group) + { + return $this->taskFilesystemStack()->chgrp($file, $group)->run(); + } + + /** + * @param string|string[] $file + * @param int $permissions + * @param int $umask + * @param bool $recursive + * + * @return \Robo\Result + */ + protected function _chmod($file, $permissions, $umask = 0000, $recursive = false) + { + return $this->taskFilesystemStack()->chmod($file, $permissions, $umask, $recursive)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _symlink($from, $to) + { + return $this->taskFilesystemStack()->symlink($from, $to)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _copy($from, $to) + { + return $this->taskFilesystemStack()->copy($from, $to)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _flattenDir($from, $to) + { + return $this->taskFlattenDir([$from => $to])->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadTasks.php new file mode 100644 index 00000000..8fecaaff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Filesystem/loadTasks.php @@ -0,0 +1,85 @@ +task(CleanDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\DeleteDir + */ + protected function taskDeleteDir($dirs) + { + return $this->task(DeleteDir::class, $dirs); + } + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return \Robo\Task\Filesystem\WorkDir + */ + protected function taskTmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + return $this->task(TmpDir::class, $prefix, $base, $includeRandomPart); + } + + /** + * @param string $finalDestination + * + * @return \Robo\Task\Filesystem\TmpDir + */ + protected function taskWorkDir($finalDestination) + { + return $this->task(WorkDir::class, $finalDestination); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\CopyDir + */ + protected function taskCopyDir($dirs) + { + return $this->task(CopyDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\MirrorDir + */ + protected function taskMirrorDir($dirs) + { + return $this->task(MirrorDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\FlattenDir + */ + protected function taskFlattenDir($dirs) + { + return $this->task(FlattenDir::class, $dirs); + } + + /** + * @return \Robo\Task\Filesystem\FilesystemStack + */ + protected function taskFilesystemStack() + { + return $this->task(FilesystemStack::class); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Base.php new file mode 100644 index 00000000..42728673 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Base.php @@ -0,0 +1,97 @@ +option('silent'); + return $this; + } + + /** + * adds `--no-color` option to gulp + * + * @return $this + */ + public function noColor() + { + $this->option('no-color'); + return $this; + } + + /** + * adds `--color` option to gulp + * + * @return $this + */ + public function color() + { + $this->option('color'); + return $this; + } + + /** + * adds `--tasks-simple` option to gulp + * + * @return $this + */ + public function simple() + { + $this->option('tasks-simple'); + return $this; + } + + /** + * @param string $task + * @param null|string $pathToGulp + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($task, $pathToGulp = null) + { + $this->task = $task; + $this->command = $pathToGulp; + if (!$this->command) { + $this->command = $this->findExecutable('gulp'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Gulp executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} " . ProcessUtils::escapeArgument($this->task) . "{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Run.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Run.php new file mode 100644 index 00000000..8f2077b5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/Run.php @@ -0,0 +1,35 @@ +taskGulpRun()->run(); + * + * // run task 'clean' with --silent option + * $this->taskGulpRun('clean') + * ->silent() + * ->run(); + * ?> + * ``` + */ +class Run extends Base implements CommandInterface +{ + /** + * {@inheritdoc} + */ + public function run() + { + if (strlen($this->arguments)) { + $this->printTaskInfo('Running Gulp task: {gulp_task} with arguments: {arguments}', ['gulp_task' => $this->task, 'arguments' => $this->arguments]); + } else { + $this->printTaskInfo('Running Gulp task: {gulp_task} without arguments', ['gulp_task' => $this->task]); + } + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/loadTasks.php new file mode 100644 index 00000000..6fdc6ca7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Gulp/loadTasks.php @@ -0,0 +1,16 @@ +task(Run::class, $task, $pathToGulp); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Base.php new file mode 100644 index 00000000..35ff9c48 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Base.php @@ -0,0 +1,60 @@ +option('production'); + return $this; + } + + /** + * @param null|string $pathToNpm + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToNpm = null) + { + $this->command = $pathToNpm; + if (!$this->command) { + $this->command = $this->findExecutable('npm'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Npm executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Install.php new file mode 100644 index 00000000..65cbe618 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Install.php @@ -0,0 +1,36 @@ +taskNpmInstall()->run(); + * + * // prefer dist with custom path + * $this->taskNpmInstall('path/to/my/npm') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Install extends Base implements CommandInterface +{ + /** + * @var string + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Install Npm packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Update.php new file mode 100644 index 00000000..75421b30 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/Update.php @@ -0,0 +1,34 @@ +taskNpmUpdate()->run(); + * + * // prefer dist with custom path + * $this->taskNpmUpdate('path/to/my/npm') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * @var string + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Update Npm packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/loadTasks.php new file mode 100644 index 00000000..4d9a26eb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Npm/loadTasks.php @@ -0,0 +1,25 @@ +task(Install::class, $pathToNpm); + } + + /** + * @param null|string $pathToNpm + * + * @return \Robo\Task\Npm\Update + */ + protected function taskNpmUpdate($pathToNpm = null) + { + return $this->task(Update::class, $pathToNpm); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Rsync.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Rsync.php new file mode 100644 index 00000000..5c334af4 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Rsync.php @@ -0,0 +1,484 @@ +taskRsync() + * ->fromPath('src/') + * ->toHost('localhost') + * ->toUser('dev') + * ->toPath('/var/www/html/app/') + * ->remoteShell('ssh -i public_key') + * ->recursive() + * ->excludeVcs() + * ->checksum() + * ->wholeFile() + * ->verbose() + * ->progress() + * ->humanReadable() + * ->stats() + * ->run(); + * ``` + * + * You could also clone the task and do a dry-run first: + * + * ``` php + * $rsync = $this->taskRsync() + * ->fromPath('src/') + * ->toPath('example.com:/var/www/html/app/') + * ->archive() + * ->excludeVcs() + * ->progress() + * ->stats(); + * + * $dryRun = clone $rsync; + * $dryRun->dryRun()->run(); + * if ('y' === $this->ask('Do you want to run (y/n)')) { + * $rsync->run(); + * } + * ``` + */ +class Rsync extends BaseTask implements CommandInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string + */ + protected $fromUser; + + /** + * @var string + */ + protected $fromHost; + + /** + * @var string + */ + protected $fromPath; + + /** + * @var string + */ + protected $toUser; + + /** + * @var string + */ + protected $toHost; + + /** + * @var string + */ + protected $toPath; + + /** + * @return static + */ + public static function init() + { + return new static(); + } + + public function __construct() + { + $this->command = 'rsync'; + } + + /** + * This can either be a full rsync path spec (user@host:path) or just a path. + * In case of the former do not specify host and user. + * + * @param string|array $path + * + * @return $this + */ + public function fromPath($path) + { + $this->fromPath = $path; + + return $this; + } + + /** + * This can either be a full rsync path spec (user@host:path) or just a path. + * In case of the former do not specify host and user. + * + * @param string $path + * + * @return $this + */ + public function toPath($path) + { + $this->toPath = $path; + + return $this; + } + + /** + * @param string $fromUser + * + * @return $this + */ + public function fromUser($fromUser) + { + $this->fromUser = $fromUser; + return $this; + } + + /** + * @param string $fromHost + * + * @return $this + */ + public function fromHost($fromHost) + { + $this->fromHost = $fromHost; + return $this; + } + + /** + * @param string $toUser + * + * @return $this + */ + public function toUser($toUser) + { + $this->toUser = $toUser; + return $this; + } + + /** + * @param string $toHost + * + * @return $this + */ + public function toHost($toHost) + { + $this->toHost = $toHost; + return $this; + } + + /** + * @return $this + */ + public function progress() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function stats() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function recursive() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function verbose() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function checksum() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function archive() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function compress() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function owner() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function group() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function times() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function delete() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @param int $seconds + * + * @return $this + */ + public function timeout($seconds) + { + $this->option(__FUNCTION__, $seconds); + + return $this; + } + + /** + * @return $this + */ + public function humanReadable() + { + $this->option('human-readable'); + + return $this; + } + + /** + * @return $this + */ + public function wholeFile() + { + $this->option('whole-file'); + + return $this; + } + + /** + * @return $this + */ + public function dryRun() + { + $this->option('dry-run'); + + return $this; + } + + /** + * @return $this + */ + public function itemizeChanges() + { + $this->option('itemize-changes'); + + return $this; + } + + /** + * Excludes .git, .svn and .hg items at any depth. + * + * @return $this + */ + public function excludeVcs() + { + return $this->exclude([ + '.git', + '.svn', + '.hg', + ]); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function exclude($pattern) + { + return $this->optionList(__FUNCTION__, $pattern); + } + + /** + * @param string $file + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function excludeFrom($file) + { + if (!is_readable($file)) { + throw new TaskException($this, "Exclude file $file is not readable"); + } + + return $this->option('exclude-from', $file); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function includeFilter($pattern) + { + return $this->optionList('include', $pattern); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function filter($pattern) + { + return $this->optionList(__FUNCTION__, $pattern); + } + + /** + * @param string $file + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function filesFrom($file) + { + if (!is_readable($file)) { + throw new TaskException($this, "Files-from file $file is not readable"); + } + + return $this->option('files-from', $file); + } + + /** + * @param string $command + * + * @return $this + */ + public function remoteShell($command) + { + $this->option('rsh', "'$command'"); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + + return $this->executeCommand($command); + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + foreach ((array)$this->fromPath as $from) { + $this->option(null, $this->getFromPathSpec($from)); + } + $this->option(null, $this->getToPathSpec()); + + return $this->command . $this->arguments; + } + + /** + * @return string + */ + protected function getFromPathSpec($from) + { + return $this->getPathSpec($this->fromHost, $this->fromUser, $from); + } + + /** + * @return string + */ + protected function getToPathSpec() + { + return $this->getPathSpec($this->toHost, $this->toUser, $this->toPath); + } + + /** + * @param string $host + * @param string $user + * @param string $path + * + * @return string + */ + protected function getPathSpec($host, $user, $path) + { + $spec = isset($path) ? $path : ''; + if (!empty($host)) { + $spec = "{$host}:{$spec}"; + } + if (!empty($user)) { + $spec = "{$user}@{$spec}"; + } + + return $spec; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Ssh.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Ssh.php new file mode 100644 index 00000000..69df9fe2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/Ssh.php @@ -0,0 +1,273 @@ +taskSshExec('remote.example.com', 'user') + * ->remoteDir('/var/www/html') + * ->exec('ls -la') + * ->exec('chmod g+x logs') + * ->run(); + * + * ``` + * + * You can even exec other tasks (which implement CommandInterface): + * + * ```php + * $gitTask = $this->taskGitStack() + * ->checkout('master') + * ->pull(); + * + * $this->taskSshExec('remote.example.com') + * ->remoteDir('/var/www/html/site') + * ->exec($gitTask) + * ->run(); + * ``` + * + * You can configure the remote directory for all future calls: + * + * ```php + * \Robo\Task\Remote\Ssh::configure('remoteDir', '/some-dir'); + * ``` + */ +class Ssh extends BaseTask implements CommandInterface, SimulatedInterface +{ + use \Robo\Common\CommandReceiver; + use \Robo\Common\ExecOneCommand; + + /** + * @var null|string + */ + protected $hostname; + + /** + * @var null|string + */ + protected $user; + + /** + * @var bool + */ + protected $stopOnFail = true; + + /** + * @var array + */ + protected $exec = []; + + /** + * Changes to the given directory before running commands. + * + * @var string + */ + protected $remoteDir; + + /** + * @param null|string $hostname + * @param null|string $user + */ + public function __construct($hostname = null, $user = null) + { + $this->hostname = $hostname; + $this->user = $user; + } + + /** + * @param string $hostname + * + * @return $this + */ + public function hostname($hostname) + { + $this->hostname = $hostname; + return $this; + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + $this->user = $user; + return $this; + } + + /** + * Whether or not to chain commands together with && and stop the chain if one command fails. + * + * @param bool $stopOnFail + * + * @return $this + */ + public function stopOnFail($stopOnFail = true) + { + $this->stopOnFail = $stopOnFail; + return $this; + } + + /** + * Changes to the given directory before running commands. + * + * @param string $remoteDir + * + * @return $this + */ + public function remoteDir($remoteDir) + { + $this->remoteDir = $remoteDir; + return $this; + } + + /** + * @param string $filename + * + * @return $this + */ + public function identityFile($filename) + { + $this->option('-i', $filename); + + return $this; + } + + /** + * @param int $port + * + * @return $this + */ + public function port($port) + { + $this->option('-p', $port); + + return $this; + } + + /** + * @return $this + */ + public function forcePseudoTty() + { + $this->option('-t'); + + return $this; + } + + /** + * @return $this + */ + public function quiet() + { + $this->option('-q'); + + return $this; + } + + /** + * @return $this + */ + public function verbose() + { + $this->option('-v'); + + return $this; + } + + /** + * @param string|string[]|CommandInterface $command + * + * @return $this + */ + public function exec($command) + { + if (is_array($command)) { + $command = implode(' ', array_filter($command)); + } + + $this->exec[] = $command; + + return $this; + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + $commands = []; + foreach ($this->exec as $command) { + $commands[] = $this->receiveCommand($command); + } + + $remoteDir = $this->remoteDir ? $this->remoteDir : $this->getConfigValue('remoteDir'); + if (!empty($remoteDir)) { + array_unshift($commands, sprintf('cd "%s"', $remoteDir)); + } + $command = implode($this->stopOnFail ? ' && ' : ' ; ', $commands); + + return $this->sshCommand($command); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->validateParameters(); + $command = $this->getCommand(); + return $this->executeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function simulate($context) + { + $command = $this->getCommand(); + $this->printTaskInfo("Running {command}", ['command' => $command] + $context); + } + + protected function validateParameters() + { + if (empty($this->hostname)) { + throw new TaskException($this, 'Please set a hostname'); + } + if (empty($this->exec)) { + throw new TaskException($this, 'Please add at least one command'); + } + } + + /** + * Returns an ssh command string running $command on the remote. + * + * @param string|CommandInterface $command + * + * @return string + */ + protected function sshCommand($command) + { + $command = $this->receiveCommand($command); + $sshOptions = $this->arguments; + $hostSpec = $this->hostname; + if ($this->user) { + $hostSpec = $this->user . '@' . $hostSpec; + } + + return "ssh{$sshOptions} {$hostSpec} '{$command}'"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/loadTasks.php new file mode 100644 index 00000000..092d2a55 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Remote/loadTasks.php @@ -0,0 +1,24 @@ +task(Rsync::class); + } + + /** + * @param null|string $hostname + * @param null|string $user + * + * @return \Robo\Task\Remote\Ssh + */ + protected function taskSshExec($hostname = null, $user = null) + { + return $this->task(Ssh::class, $hostname, $user); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Simulator.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Simulator.php new file mode 100644 index 00000000..e69d23fa --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Simulator.php @@ -0,0 +1,168 @@ +task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->constructorParameters = $constructorParameters; + } + + /** + * @param string $function + * @param array $args + * + * @return \Robo\Result|\Robo\Task\Simulator + */ + public function __call($function, $args) + { + $this->stack[] = array_merge([$function], $args); + $result = call_user_func_array([$this->task, $function], $args); + return $result == $this->task ? $this : $result; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $callchain = ''; + foreach ($this->stack as $action) { + $command = array_shift($action); + $parameters = $this->formatParameters($action); + $callchain .= "\n ->$command($parameters)"; + } + $context = $this->getTaskContext( + [ + '_level' => RoboLogLevel::SIMULATED_ACTION, + 'simulated' => TaskInfo::formatTaskName($this->task), + 'parameters' => $this->formatParameters($this->constructorParameters), + '_style' => ['simulated' => 'fg=blue;options=bold'], + ] + ); + + // RoboLogLevel::SIMULATED_ACTION + $this->printTaskInfo( + "Simulating {simulated}({parameters})$callchain", + $context + ); + + $result = null; + if ($this->task instanceof SimulatedInterface) { + $result = $this->task->simulate($context); + } + if (!isset($result)) { + $result = Result::success($this); + } + + return $result; + } + + /** + * Danger: reach through the simulated wrapper and pull out the command + * to be executed. This is used when using a simulated task with another + * simulated task that runs commands, e.g. the Remote\Ssh task. Using + * a simulated CommandInterface task with a non-simulated task may produce + * unexpected results (e.g. execution!). + * + * @return string + * + * @throws \Robo\Exception\TaskException + */ + public function getCommand() + { + if (!$this->task instanceof CommandInterface) { + throw new TaskException($this->task, 'Simulated task that is not a CommandInterface used as a CommandInterface.'); + } + return $this->task->getCommand(); + } + + /** + * @param string $action + * + * @return string + */ + protected function formatParameters($action) + { + $parameterList = array_map([$this, 'convertParameter'], $action); + return implode(', ', $parameterList); + } + + /** + * @param mixed $item + * + * @return string + */ + protected function convertParameter($item) + { + if (is_callable($item)) { + return 'inline_function(...)'; + } + if (is_array($item)) { + return $this->shortenParameter(var_export($item, true)); + } + if (is_object($item)) { + return '[' . get_class($item). ' object]'; + } + if (is_string($item)) { + return $this->shortenParameter("'$item'"); + } + if (is_null($item)) { + return 'null'; + } + return $item; + } + + /** + * @param string $item + * @param string $shortForm + * + * @return string + */ + protected function shortenParameter($item, $shortForm = '') + { + $maxLength = 80; + $tailLength = 20; + if (strlen($item) < $maxLength) { + return $item; + } + if (!empty($shortForm)) { + return $shortForm; + } + $item = trim($item); + $tail = preg_replace("#.*\n#ms", '', substr($item, -$tailLength)); + $head = preg_replace("#\n.*#ms", '', substr($item, 0, $maxLength - (strlen($tail) + 5))); + return "$head ... $tail"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/StackBasedTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/StackBasedTask.php new file mode 100644 index 00000000..91659f33 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/StackBasedTask.php @@ -0,0 +1,236 @@ +friz() + * ->fraz() + * ->frob(); + * + * We presume that the existing library throws an exception on error. + * + * You want: + * + * $result = $this->taskFrobinator($a, $b, $c) + * ->friz() + * ->fraz() + * ->frob() + * ->run(); + * + * Execution is deferred until run(), and a Robo\Result instance is + * returned. Additionally, using Robo will covert Exceptions + * into RoboResult objects. + * + * To create a new Robo task: + * + * - Make a new class that extends StackBasedTask + * - Give it a constructor that creates a new Frobinator + * - Override getDelegate(), and return the Frobinator instance + * + * Finally, add your new class to loadTasks.php as usual, + * and you are all done. + * + * If you need to add any methods to your task that should run + * immediately (e.g. to set parameters used at run() time), just + * implement them in your derived class. + * + * If you need additional methods that should run deferred, just + * define them as 'protected function _foo()'. Then, users may + * call $this->taskFrobinator()->foo() to get deferred execution + * of _foo(). + */ +abstract class StackBasedTask extends BaseTask +{ + /** + * @var array + */ + protected $stack = []; + + /** + * @var bool + */ + protected $stopOnFail = true; + + /** + * @param bool $stop + * + * @return $this + */ + public function stopOnFail($stop = true) + { + $this->stopOnFail = $stop; + return $this; + } + + /** + * Derived classes should override the getDelegate() method, and + * return an instance of the API class being wrapped. When this + * is done, any method of the delegate is available as a method of + * this class. Calling one of the delegate's methods will defer + * execution until the run() method is called. + * + * @return null + */ + protected function getDelegate() + { + return null; + } + + /** + * Derived classes that have more than one delegate may override + * getCommandList to add as many delegate commands as desired to + * the list of potential functions that __call() tried to find. + * + * @param string $function + * + * @return array + */ + protected function getDelegateCommandList($function) + { + return [[$this, "_$function"], [$this->getDelegate(), $function]]; + } + + /** + * Print progress about the commands being executed + * + * @param string $command + * @param string $action + */ + protected function printTaskProgress($command, $action) + { + $this->printTaskInfo('{command} {action}', ['command' => "{$command[1]}", 'action' => json_encode($action, JSON_UNESCAPED_SLASHES)]); + } + + /** + * Derived classes can override processResult to add more + * logic to result handling from functions. By default, it + * is assumed that if a function returns in int, then + * 0 == success, and any other value is the error code. + * + * @param int|\Robo\Result $function_result + * + * @return \Robo\Result + */ + protected function processResult($function_result) + { + if (is_int($function_result)) { + if ($function_result) { + return Result::error($this, $function_result); + } + } + return Result::success($this); + } + + /** + * Record a function to call later. + * + * @param string $command + * @param array $args + * + * @return $this + */ + protected function addToCommandStack($command, $args) + { + $this->stack[] = array_merge([$command], $args); + return $this; + } + + /** + * Any API function provided by the delegate that executes immediately + * may be handled by __call automatically. These operations will all + * be deferred until this task's run() method is called. + * + * @param string $function + * @param array $args + * + * @return $this + */ + public function __call($function, $args) + { + foreach ($this->getDelegateCommandList($function) as $command) { + if (method_exists($command[0], $command[1])) { + // Otherwise, we'll defer calling this function + // until run(), and return $this. + $this->addToCommandStack($command, $args); + return $this; + } + } + + $message = "Method $function does not exist.\n"; + throw new \BadMethodCallException($message); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + // run() will call advanceProgressIndicator() once for each + // file, one after calling stopBuffering, and again after compression. + return count($this->stack); + } + + /** + * Run all of the queued objects on the stack + * + * @return \Robo\Result + */ + public function run() + { + $this->startProgressIndicator(); + $result = Result::success($this); + + foreach ($this->stack as $action) { + $command = array_shift($action); + $this->printTaskProgress($command, $action); + $this->advanceProgressIndicator(); + // TODO: merge data from the result on this call + // with data from the result on the previous call? + // For now, the result always comes from the last function. + $result = $this->callTaskMethod($command, $action); + if ($this->stopOnFail && $result && !$result->wasSuccessful()) { + break; + } + } + + $this->stopProgressIndicator(); + + // todo: add timing information to the result + return $result; + } + + /** + * Execute one task method + * + * @param string $command + * @param string $action + * + * @return \Robo\Result + */ + protected function callTaskMethod($command, $action) + { + try { + $function_result = call_user_func_array($command, $action); + return $this->processResult($function_result); + } catch (\Exception $e) { + $this->printTaskError($e->getMessage()); + return Result::fromException($this, $e); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Atoum.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Atoum.php new file mode 100644 index 00000000..56b47d84 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Atoum.php @@ -0,0 +1,184 @@ +taskAtoum() + * ->files('path/to/test.php') + * ->configFile('config/dev.php') + * ->run() + * + * ?> + * ``` + */ +class Atoum extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * Atoum constructor. + * + * @param null|string $pathToAtoum + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToAtoum = null) + { + $this->command = $pathToAtoum; + if (!$this->command) { + $this->command = $this->findExecutable('atoum'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither local atoum nor global composer installation not found"); + } + } + + /** + * Tag or Tags to filter. + * + * @param string|array $tags + * + * @return $this + */ + public function tags($tags) + { + return $this->addMultipleOption('tags', $tags); + } + + /** + * Display result using the light reporter. + * + * @return $this + */ + public function lightReport() + { + $this->option("--use-light-report"); + + return $this; + } + + /** + * Display result using the tap reporter. + * + * @return $this + */ + public function tap() + { + $this->option("use-tap-report"); + + return $this; + } + + /** + * Path to the bootstrap file. + + * @param string $file + * + * @return $this + */ + public function bootstrap($file) + { + $this->option("bootstrap", $file); + + return $this; + } + + /** + * Path to the config file. + * + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option('-c', $file); + + return $this; + } + + /** + * Use atoum's debug mode. + * + * @return $this + */ + public function debug() + { + $this->option("debug"); + + return $this; + } + + /** + * Test file or test files to run. + * + * @param string|array + * + * @return $this + */ + public function files($files) + { + return $this->addMultipleOption('f', $files); + } + + /** + * Test directory or directories to run. + * + * @param string|array A single directory or a list of directories. + * + * @return $this + */ + public function directories($directories) + { + return $this->addMultipleOption('directories', $directories); + } + + /** + * @param string $option + * @param string|array $values + * + * @return $this + */ + protected function addMultipleOption($option, $values) + { + if (is_string($values)) { + $values = [$values]; + } + + foreach ($values as $value) { + $this->option($option, $value); + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running atoum ' . $this->arguments); + + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Behat.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Behat.php new file mode 100644 index 00000000..7e4f1d41 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Behat.php @@ -0,0 +1,163 @@ +taskBehat() + * ->format('pretty') + * ->noInteraction() + * ->run(); + * ?> + * ``` + * + */ +class Behat extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string[] $formaters available formaters for format option + */ + protected $formaters = ['progress', 'pretty', 'junit']; + + /** + * @var string[] $verbose_levels available verbose levels + */ + protected $verbose_levels = ['v', 'vv']; + + /** + * Behat constructor. + * + * @param null|string $pathToBehat + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToBehat = null) + { + $this->command = $pathToBehat; + if (!$this->command) { + $this->command = $this->findExecutable('behat'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Behat found"); + } + } + + /** + * @return $this + */ + public function stopOnFail() + { + $this->option('stop-on-failure'); + return $this; + } + + /** + * @return $this + */ + public function noInteraction() + { + $this->option('no-interaction'); + return $this; + } + + /** + * @param $config_file + * + * @return $this + */ + public function config($config_file) + { + $this->option('config', $config_file); + return $this; + } + + /** + * @return $this + */ + public function colors() + { + $this->option('colors'); + return $this; + } + + /** + * @return $this + */ + public function noColors() + { + $this->option('no-colors'); + return $this; + } + + /** + * @param string $suite + * + * @return $this + */ + public function suite($suite) + { + $this->option('suite', $suite); + return $this; + } + + /** + * @param string $level + * + * @return $this + */ + public function verbose($level = 'v') + { + if (!in_array($level, $this->verbose_levels)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels)); + } + $this->option('-' . $level); + return $this; + } + + /** + * @param string $formater + * + * @return $this + */ + public function format($formater) + { + if (!in_array($formater, $this->formaters)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters)); + } + $this->option('format', $formater); + return $this; + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running behat {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Codecept.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Codecept.php new file mode 100644 index 00000000..1f8cce70 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Codecept.php @@ -0,0 +1,271 @@ +taskCodecept() + * ->suite('acceptance') + * ->env('chrome') + * ->group('admin') + * ->xml() + * ->html() + * ->run(); + * + * ?> + * ``` + * + */ +class Codecept extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @param string $pathToCodeception + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToCodeception = '') + { + $this->command = $pathToCodeception; + if (!$this->command) { + $this->command = $this->findExecutable('codecept'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Neither composer nor phar installation of Codeception found."); + } + $this->command .= ' run'; + } + + /** + * @param string $suite + * + * @return $this + */ + public function suite($suite) + { + $this->option(null, $suite); + return $this; + } + + /** + * @param string $testName + * + * @return $this + */ + public function test($testName) + { + $this->option(null, $testName); + return $this; + } + + /** + * set group option. Can be called multiple times + * + * @param string $group + * + * @return $this + */ + public function group($group) + { + $this->option("group", $group); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function excludeGroup($group) + { + $this->option("skip-group", $group); + return $this; + } + + /** + * generate json report + * + * @param string $file + * + * @return $this + */ + public function json($file = null) + { + $this->option("json", $file); + return $this; + } + + /** + * generate xml JUnit report + * + * @param string $file + * + * @return $this + */ + public function xml($file = null) + { + $this->option("xml", $file); + return $this; + } + + /** + * Generate html report + * + * @param string $dir + * + * @return $this + */ + public function html($dir = null) + { + $this->option("html", $dir); + return $this; + } + + /** + * generate tap report + * + * @param string $file + * + * @return $this + */ + public function tap($file = null) + { + $this->option("tap", $file); + return $this; + } + + /** + * provides config file other then default `codeception.yml` with `-c` option + * + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option("-c", $file); + return $this; + } + + /** + * collect codecoverage in raw format. You may pass name of cov file to save results + * + * @param null|string $cov + * + * @return $this + */ + public function coverage($cov = null) + { + $this->option("coverage", $cov); + return $this; + } + + /** + * execute in silent mode + * + * @return $this + */ + public function silent() + { + $this->option("silent"); + return $this; + } + + /** + * collect code coverage in xml format. You may pass name of xml file to save results + * + * @param string $xml + * + * @return $this + */ + public function coverageXml($xml = null) + { + $this->option("coverage-xml", $xml); + return $this; + } + + /** + * collect code coverage and generate html report. You may pass + * + * @param string $html + * + * @return $this + */ + public function coverageHtml($html = null) + { + $this->option("coverage-html", $html); + return $this; + } + + /** + * @param string $env + * + * @return $this + */ + public function env($env) + { + $this->option("env", $env); + return $this; + } + + /** + * @return $this + */ + public function debug() + { + $this->option("debug"); + return $this; + } + + /** + * @return $this + */ + public function noRebuild() + { + $this->option("no-rebuild"); + return $this; + } + + /** + * @param string $failGroup + * @return $this + */ + public function failGroup($failGroup) + { + $this->option('override', "extensions: config: Codeception\\Extension\\RunFailed: fail-group: {$failGroup}"); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Executing {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/PHPUnit.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/PHPUnit.php new file mode 100644 index 00000000..df67e1c7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/PHPUnit.php @@ -0,0 +1,199 @@ +taskPHPUnit() + * ->group('core') + * ->bootstrap('test/bootstrap.php') + * ->run() + * + * ?> + * ``` + */ +class PHPUnit extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * Directory of test files or single test file to run. Appended to + * the command and arguments. + * + * @var string + */ + protected $files = ''; + + public function __construct($pathToPhpUnit = null) + { + $this->command = $pathToPhpUnit; + if (!$this->command) { + $this->command = $this->findExecutablePhar('phpunit'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither local phpunit nor global composer installation not found"); + } + } + + /** + * @param string $filter + * + * @return $this + */ + public function filter($filter) + { + $this->option('filter', $filter); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function group($group) + { + $this->option("group", $group); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function excludeGroup($group) + { + $this->option("exclude-group", $group); + return $this; + } + + /** + * adds `log-json` option to runner + * + * @param string $file + * + * @return $this + */ + public function json($file = null) + { + $this->option("log-json", $file); + return $this; + } + + /** + * adds `log-junit` option + * + * @param string $file + * + * @return $this + */ + public function xml($file = null) + { + $this->option("log-junit", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function tap($file = "") + { + $this->option("log-tap", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function bootstrap($file) + { + $this->option("bootstrap", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option('-c', $file); + return $this; + } + + /** + * @return $this + */ + public function debug() + { + $this->option("debug"); + return $this; + } + + /** + * Directory of test files or single test file to run. + * + * @param string $files A single test file or a directory containing test files. + * + * @return $this + * + * @throws \Robo\Exception\TaskException + * + * @deprecated Use file() or dir() method instead + */ + public function files($files) + { + if (!empty($this->files) || is_array($files)) { + throw new \Robo\Exception\TaskException(__CLASS__, "Only one file or directory may be provided."); + } + $this->files = ' ' . $files; + + return $this; + } + + /** + * Test the provided file. + * + * @param string $file path to file to test + * + * @return $this + */ + public function file($file) + { + return $this->files($file); + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments . $this->files; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running PHPUnit {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Phpspec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Phpspec.php new file mode 100644 index 00000000..dd6a5ae7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/Phpspec.php @@ -0,0 +1,116 @@ +taskPhpspec() + * ->format('pretty') + * ->noInteraction() + * ->run(); + * ?> + * ``` + * + */ +class Phpspec extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string[] $formaters available formaters for format option + */ + protected $formaters = ['progress', 'html', 'pretty', 'junit', 'dot', 'tap']; + + /** + * @var array $verbose_levels available verbose levels + */ + protected $verbose_levels = ['v', 'vv', 'vvv']; + + public function __construct($pathToPhpspec = null) + { + $this->command = $pathToPhpspec; + if (!$this->command) { + $this->command = $this->findExecutable('phpspec'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Phpspec found"); + } + $this->arg('run'); + } + + public function stopOnFail() + { + $this->option('stop-on-failure'); + return $this; + } + + public function noCodeGeneration() + { + $this->option('no-code-generation'); + return $this; + } + + public function quiet() + { + $this->option('quiet'); + return $this; + } + + public function verbose($level = 'v') + { + if (!in_array($level, $this->verbose_levels)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels)); + } + $this->option('-' . $level); + return $this; + } + + public function noAnsi() + { + $this->option('no-ansi'); + return $this; + } + + public function noInteraction() + { + $this->option('no-interaction'); + return $this; + } + + public function config($config_file) + { + $this->option('config', $config_file); + return $this; + } + + public function format($formater) + { + if (!in_array($formater, $this->formaters)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters)); + } + $this->option('format', $formater); + return $this; + } + + public function getCommand() + { + return $this->command . $this->arguments; + } + + public function run() + { + $this->printTaskInfo('Running phpspec {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/loadTasks.php new file mode 100644 index 00000000..43145b9b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Testing/loadTasks.php @@ -0,0 +1,55 @@ +task(Codecept::class, $pathToCodeception); + } + + /** + * @param null|string $pathToPhpUnit + * + * @return \Robo\Task\Testing\PHPUnit + */ + protected function taskPhpUnit($pathToPhpUnit = null) + { + return $this->task(PHPUnit::class, $pathToPhpUnit); + } + + /** + * @param null $pathToPhpspec + * + * @return \Robo\Task\Testing\Phpspec + */ + protected function taskPhpspec($pathToPhpspec = null) + { + return $this->task(Phpspec::class, $pathToPhpspec); + } + + /** + * @param null $pathToAtoum + * + * @return \Robo\Task\Testing\Atoum + */ + protected function taskAtoum($pathToAtoum = null) + { + return $this->task(Atoum::class, $pathToAtoum); + } + + /** + * @param null $pathToBehat + * + * @return \Robo\Task\Testing\Behat + */ + protected function taskBehat($pathToBehat = null) + { + return $this->task(Behat::class, $pathToBehat); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/GitStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/GitStack.php new file mode 100644 index 00000000..6cb1783f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/GitStack.php @@ -0,0 +1,177 @@ +taskGitStack() + * ->stopOnFail() + * ->add('-A') + * ->commit('adding everything') + * ->push('origin','master') + * ->tag('0.6.0') + * ->push('origin','0.6.0') + * ->run() + * + * $this->taskGitStack() + * ->stopOnFail() + * ->add('doc/*') + * ->commit('doc updated') + * ->push() + * ->run(); + * ?> + * ``` + */ +class GitStack extends CommandStack +{ + /** + * @param string $pathToGit + */ + public function __construct($pathToGit = 'git') + { + $this->executable = $pathToGit; + } + + /** + * Executes `git clone` + * + * @param string $repo + * @param string $to + * + * @return $this + */ + public function cloneRepo($repo, $to = "", $branch = "") + { + $cmd = ['clone', $repo, $to]; + if (!empty($branch)) { + $cmd[] = "--branch $branch"; + } + return $this->exec($cmd); + } + + /** + * Executes `git clone` with depth 1 as default + * + * @param string $repo + * @param string $to + * @param string $branch + * @param int $depth + * + * @return $this + */ + public function cloneShallow($repo, $to = '', $branch = "", $depth = 1) + { + $cmd = ["clone --depth $depth", $repo, $to]; + if (!empty($branch)) { + $cmd[] = "--branch $branch"; + } + + return $this->exec($cmd); + } + + /** + * Executes `git add` command with files to add pattern + * + * @param string $pattern + * + * @return $this + */ + public function add($pattern) + { + return $this->exec([__FUNCTION__, $pattern]); + } + + /** + * Executes `git commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = "") + { + $message = ProcessUtils::escapeArgument($message); + return $this->exec([__FUNCTION__, "-m $message", $options]); + } + + /** + * Executes `git pull` command. + * + * @param string $origin + * @param string $branch + * + * @return $this + */ + public function pull($origin = '', $branch = '') + { + return $this->exec([__FUNCTION__, $origin, $branch]); + } + + /** + * Executes `git push` command + * + * @param string $origin + * @param string $branch + * + * @return $this + */ + public function push($origin = '', $branch = '') + { + return $this->exec([__FUNCTION__, $origin, $branch]); + } + + /** + * Performs git merge + * + * @param string $branch + * + * @return $this + */ + public function merge($branch) + { + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `git checkout` command + * + * @param string $branch + * + * @return $this + */ + public function checkout($branch) + { + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `git tag` command + * + * @param string $tag_name + * @param string $message + * + * @return $this + */ + public function tag($tag_name, $message = "") + { + if ($message != "") { + $message = "-m '$message'"; + } + return $this->exec([__FUNCTION__, $message, $tag_name]); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo("Running git commands..."); + return parent::run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/HgStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/HgStack.php new file mode 100644 index 00000000..71cc0ca9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/HgStack.php @@ -0,0 +1,153 @@ +hgStack + * ->cloneRepo('https://bitbucket.org/durin42/hgsubversion') + * ->pull() + * ->add() + * ->commit('changed') + * ->push() + * ->tag('0.6.0') + * ->push('0.6.0') + * ->run(); + * ?> + * ``` + */ +class HgStack extends CommandStack +{ + + /** + * @param string $pathToHg + */ + public function __construct($pathToHg = 'hg') + { + $this->executable = $pathToHg; + } + + /** + * Executes `hg clone` + * + * @param string $repo + * @param string $to + * + * @return $this + */ + public function cloneRepo($repo, $to = '') + { + return $this->exec(['clone', $repo, $to]); + } + + /** + * Executes `hg add` command with files to add by pattern + * + * @param string $include + * @param string $exclude + * + * @return $this + */ + public function add($include = '', $exclude = '') + { + if (strlen($include) > 0) { + $include = "-I {$include}"; + } + + if (strlen($exclude) > 0) { + $exclude = "-X {$exclude}"; + } + + return $this->exec([__FUNCTION__, $include, $exclude]); + } + + /** + * Executes `hg commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = '') + { + return $this->exec([__FUNCTION__, "-m '{$message}'", $options]); + } + + /** + * Executes `hg pull` command. + * + * @param string $branch + * + * @return $this + */ + public function pull($branch = '') + { + if (strlen($branch) > 0) { + $branch = "-b '{$branch}''"; + } + + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `hg push` command + * + * @param string $branch + * + * @return $this + */ + public function push($branch = '') + { + if (strlen($branch) > 0) { + $branch = "-b '{$branch}'"; + } + + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Performs hg merge + * + * @param string $revision + * + * @return $this + */ + public function merge($revision = '') + { + if (strlen($revision) > 0) { + $revision = "-r {$revision}"; + } + + return $this->exec([__FUNCTION__, $revision]); + } + + /** + * Executes `hg tag` command + * + * @param string $tag_name + * @param string $message + * + * @return $this + */ + public function tag($tag_name, $message = '') + { + if ($message !== '') { + $message = "-m '{$message}'"; + } + return $this->exec([__FUNCTION__, $message, $tag_name]); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running hg commands...'); + return parent::run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/SvnStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/SvnStack.php new file mode 100644 index 00000000..ec719b53 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/SvnStack.php @@ -0,0 +1,106 @@ +taskSvnStack() + * ->checkout('http://svn.collab.net/repos/svn/trunk') + * ->run() + * + * // alternatively + * $this->_svnCheckout('http://svn.collab.net/repos/svn/trunk'); + * + * $this->taskSvnStack('username', 'password') + * ->stopOnFail() + * ->update() + * ->add('doc/*') + * ->commit('doc updated') + * ->run(); + * ?> + * ``` + */ +class SvnStack extends CommandStack implements CommandInterface +{ + /** + * @var bool + */ + protected $stopOnFail = false; + + /** + * @var \Robo\Result + */ + protected $result; + + /** + * @param string $username + * @param string $password + * @param string $pathToSvn + */ + public function __construct($username = '', $password = '', $pathToSvn = 'svn') + { + $this->executable = $pathToSvn; + if (!empty($username)) { + $this->executable .= " --username $username"; + } + if (!empty($password)) { + $this->executable .= " --password $password"; + } + $this->result = Result::success($this); + } + + /** + * Updates `svn update` command + * + * @param string $path + * + * @return $this; + */ + public function update($path = '') + { + return $this->exec("update $path"); + } + + /** + * Executes `svn add` command with files to add pattern + * + * @param string $pattern + * + * @return $this + */ + public function add($pattern = '') + { + return $this->exec("add $pattern"); + } + + /** + * Executes `svn commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = "") + { + return $this->exec("commit -m '$message' $options"); + } + + /** + * Executes `svn checkout` command + * + * @param string $branch + * + * @return $this + */ + public function checkout($branch) + { + return $this->exec("checkout $branch"); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadShortcuts.php new file mode 100644 index 00000000..7d64ab58 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadShortcuts.php @@ -0,0 +1,35 @@ +taskSvnStack()->checkout($url)->run(); + } + + /** + * @param string $url + * + * @return \Robo\Result + */ + protected function _gitClone($url) + { + return $this->taskGitStack()->cloneRepo($url)->run(); + } + + /** + * @param string $url + * + * @return \Robo\Result + */ + protected function _hgClone($url) + { + return $this->taskHgStack()->cloneRepo($url)->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadTasks.php new file mode 100644 index 00000000..6dd06228 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Task/Vcs/loadTasks.php @@ -0,0 +1,37 @@ +task(SvnStack::class, $username, $password, $pathToSvn); + } + + /** + * @param string $pathToGit + * + * @return \Robo\Task\Vcs\GitStack + */ + protected function taskGitStack($pathToGit = 'git') + { + return $this->task(GitStack::class, $pathToGit); + } + + /** + * @param string $pathToHg + * + * @return \Robo\Task\Vcs\HgStack + */ + protected function taskHgStack($pathToHg = 'hg') + { + return $this->task(HgStack::class, $pathToHg); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskAccessor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskAccessor.php new file mode 100644 index 00000000..e65cd3eb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskAccessor.php @@ -0,0 +1,47 @@ +task(Foo::class, $a, $b); + * + * instead of: + * + * $this->taskFoo($a, $b); + * + * The later form is preferred. + * + * @return \Robo\Collection\CollectionBuilder + */ + protected function task() + { + $args = func_get_args(); + $name = array_shift($args); + + $collectionBuilder = $this->collectionBuilder(); + return $collectionBuilder->build($name, $args); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskInfo.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskInfo.php new file mode 100644 index 00000000..ce59c2d5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/TaskInfo.php @@ -0,0 +1,35 @@ + TaskInfo::formatTaskName($task), + 'task' => $task, + ]; + } + + /** + * @param object $task + * + * @return string + */ + public static function formatTaskName($task) + { + $name = get_class($task); + $name = preg_replace('~Stack^~', '', $name); + $name = str_replace('Robo\\Task\Base\\', '', $name); + $name = str_replace('Robo\\Task\\', '', $name); + $name = str_replace('Robo\\Collection\\', '', $name); + return $name; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Tasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Tasks.php new file mode 100644 index 00000000..2822d7d5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony2/src/Tasks.php @@ -0,0 +1,23 @@ +getDefinition() + ->addOption( + new InputOption('--simulate', null, InputOption::VALUE_NONE, 'Run in simulated mode (show what would have happened).') + ); + $this->getDefinition() + ->addOption( + new InputOption('--progress-delay', null, InputOption::VALUE_REQUIRED, 'Number of seconds before progress bar is displayed in long-running task collections. Default: 2s.', Config::DEFAULT_PROGRESS_DELAY) + ); + + $this->getDefinition() + ->addOption( + new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', []) + ); + } + + /** + * @param string $roboFile + * @param string $roboClass + */ + public function addInitRoboFileCommand($roboFile, $roboClass) + { + $createRoboFile = new Command('init'); + $createRoboFile->setDescription("Intitalizes basic RoboFile in current dir"); + $createRoboFile->setCode(function () use ($roboClass, $roboFile) { + $output = Robo::output(); + $output->writeln(" ~~~ Welcome to Robo! ~~~~ "); + $output->writeln(" ". basename($roboFile) ." will be created in the current directory "); + file_put_contents( + $roboFile, + 'writeln(" Edit this file to add your commands! "); + }); + $this->add($createRoboFile); + } + + /** + * Add self update command, do nothing if null is provided + * + * @param string $repository GitHub Repository for self update + */ + public function addSelfUpdateCommand($repository = null) + { + if (!$repository) { + return; + } + $selfUpdateCommand = new SelfUpdateCommand($this->getName(), $this->getVersion(), $repository); + $this->add($selfUpdateCommand); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CallableTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CallableTask.php new file mode 100644 index 00000000..ae9c54fc --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CallableTask.php @@ -0,0 +1,62 @@ +fn = $fn; + $this->reference = $reference; + } + + /** + * @return \Robo\Result + */ + public function run() + { + $result = call_user_func($this->fn, $this->getState()); + // If the function returns no result, then count it + // as a success. + if (!isset($result)) { + $result = Result::success($this->reference); + } + // If the function returns a result, it must either return + // a \Robo\Result or an exit code. In the later case, we + // convert it to a \Robo\Result. + if (!$result instanceof Result) { + $result = new Result($this->reference, $result); + } + + return $result; + } + + public function getState() + { + if ($this->reference instanceof StateAwareInterface) { + return $this->reference->getState(); + } + return new Data(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Collection.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Collection.php new file mode 100644 index 00000000..607435a4 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Collection.php @@ -0,0 +1,769 @@ +resetState(); + } + + public function setProgressBarAutoDisplayInterval($interval) + { + if (!$this->progressIndicator) { + return; + } + return $this->progressIndicator->setProgressBarAutoDisplayInterval($interval); + } + + /** + * {@inheritdoc} + */ + public function add(TaskInterface $task, $name = self::UNNAMEDTASK) + { + $task = new CompletionWrapper($this, $task); + $this->addToTaskList($name, $task); + return $this; + } + + /** + * {@inheritdoc} + */ + public function addCode(callable $code, $name = self::UNNAMEDTASK) + { + return $this->add(new CallableTask($code, $this), $name); + } + + /** + * {@inheritdoc} + */ + public function addIterable($iterable, callable $code) + { + $callbackTask = (new IterationTask($iterable, $code, $this))->inflect($this); + return $this->add($callbackTask); + } + + /** + * {@inheritdoc} + */ + public function rollback(TaskInterface $rollbackTask) + { + // Rollback tasks always try as hard as they can, and never report failures. + $rollbackTask = $this->ignoreErrorsTaskWrapper($rollbackTask); + return $this->wrapAndRegisterRollback($rollbackTask); + } + + /** + * {@inheritdoc} + */ + public function rollbackCode(callable $rollbackCode) + { + // Rollback tasks always try as hard as they can, and never report failures. + $rollbackTask = $this->ignoreErrorsCodeWrapper($rollbackCode); + return $this->wrapAndRegisterRollback($rollbackTask); + } + + /** + * {@inheritdoc} + */ + public function completion(TaskInterface $completionTask) + { + $collection = $this; + $completionRegistrationTask = new CallableTask( + function () use ($collection, $completionTask) { + + $collection->registerCompletion($completionTask); + }, + $this + ); + $this->addToTaskList(self::UNNAMEDTASK, $completionRegistrationTask); + return $this; + } + + /** + * {@inheritdoc} + */ + public function completionCode(callable $completionTask) + { + $completionTask = new CallableTask($completionTask, $this); + return $this->completion($completionTask); + } + + /** + * {@inheritdoc} + */ + public function before($name, $task, $nameOfTaskToAdd = self::UNNAMEDTASK) + { + return $this->addBeforeOrAfter(__FUNCTION__, $name, $task, $nameOfTaskToAdd); + } + + /** + * {@inheritdoc} + */ + public function after($name, $task, $nameOfTaskToAdd = self::UNNAMEDTASK) + { + return $this->addBeforeOrAfter(__FUNCTION__, $name, $task, $nameOfTaskToAdd); + } + + /** + * {@inheritdoc} + */ + public function progressMessage($text, $context = [], $level = LogLevel::NOTICE) + { + $context += ['name' => 'Progress']; + $context += TaskInfo::getTaskContext($this); + return $this->addCode( + function () use ($level, $text, $context) { + $context += $this->getState()->getData(); + $this->printTaskOutput($level, $text, $context); + } + ); + } + + /** + * @param \Robo\Contract\TaskInterface $rollbackTask + * + * @return $this + */ + protected function wrapAndRegisterRollback(TaskInterface $rollbackTask) + { + $collection = $this; + $rollbackRegistrationTask = new CallableTask( + function () use ($collection, $rollbackTask) { + $collection->registerRollback($rollbackTask); + }, + $this + ); + $this->addToTaskList(self::UNNAMEDTASK, $rollbackRegistrationTask); + return $this; + } + + /** + * Add either a 'before' or 'after' function or task. + * + * @param string $method + * @param string $name + * @param callable|TaskInterface $task + * @param string $nameOfTaskToAdd + * + * @return $this + */ + protected function addBeforeOrAfter($method, $name, $task, $nameOfTaskToAdd) + { + if (is_callable($task)) { + $task = new CallableTask($task, $this); + } + $existingTask = $this->namedTask($name); + $fn = [$existingTask, $method]; + call_user_func($fn, $task, $nameOfTaskToAdd); + return $this; + } + + /** + * Wrap the provided task in a wrapper that will ignore + * any errors or exceptions that may be produced. This + * is useful, for example, in adding optional cleanup tasks + * at the beginning of a task collection, to remove previous + * results which may or may not exist. + * + * TODO: Provide some way to specify which sort of errors + * are ignored, so that 'file not found' may be ignored, + * but 'permission denied' reported? + * + * @param \Robo\Contract\TaskInterface $task + * + * @return \Robo\Collection\CallableTask + */ + public function ignoreErrorsTaskWrapper(TaskInterface $task) + { + // If the task is a stack-based task, then tell it + // to try to run all of its operations, even if some + // of them fail. + if ($task instanceof StackBasedTask) { + $task->stopOnFail(false); + } + $ignoreErrorsInTask = function () use ($task) { + $data = []; + try { + $result = $this->runSubtask($task); + $message = $result->getMessage(); + $data = $result->getData(); + $data['exitcode'] = $result->getExitCode(); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + return Result::success($task, $message, $data); + }; + // Wrap our ignore errors callable in a task. + return new CallableTask($ignoreErrorsInTask, $this); + } + + /** + * @param callable $task + * + * @return \Robo\Collection\CallableTask + */ + public function ignoreErrorsCodeWrapper(callable $task) + { + return $this->ignoreErrorsTaskWrapper(new CallableTask($task, $this)); + } + + /** + * Return the list of task names added to this collection. + * + * @return array + */ + public function taskNames() + { + return array_keys($this->taskList); + } + + /** + * Test to see if a specified task name exists. + * n.b. before() and after() require that the named + * task exist; use this function to test first, if + * unsure. + * + * @param string $name + * + * @return bool + */ + public function hasTask($name) + { + return array_key_exists($name, $this->taskList); + } + + /** + * Find an existing named task. + * + * @param string $name + * The name of the task to insert before. The named task MUST exist. + * + * @return Element + * The task group for the named task. Generally this is only + * used to call 'before()' and 'after()'. + */ + protected function namedTask($name) + { + if (!$this->hasTask($name)) { + throw new \RuntimeException("Could not find task named $name"); + } + return $this->taskList[$name]; + } + + /** + * Add a list of tasks to our task collection. + * + * @param TaskInterface[] $tasks + * An array of tasks to run with rollback protection + * + * @return $this + */ + public function addTaskList(array $tasks) + { + foreach ($tasks as $name => $task) { + $this->add($task, $name); + } + return $this; + } + + /** + * Add the provided task to our task list. + * + * @param string $name + * @param \Robo\Contract\TaskInterface $task + * + * @return \Robo\Collection\Collection + */ + protected function addToTaskList($name, TaskInterface $task) + { + // All tasks are stored in a task group so that we have a place + // to hang 'before' and 'after' tasks. + $taskGroup = new Element($task); + return $this->addCollectionElementToTaskList($name, $taskGroup); + } + + /** + * @param int|string $name + * @param \Robo\Collection\Element $taskGroup + * + * @return $this + */ + protected function addCollectionElementToTaskList($name, Element $taskGroup) + { + // If a task name is not provided, then we'll let php pick + // the array index. + if (Result::isUnnamed($name)) { + $this->taskList[] = $taskGroup; + return $this; + } + // If we are replacing an existing task with the + // same name, ensure that our new task is added to + // the end. + $this->taskList[$name] = $taskGroup; + return $this; + } + + /** + * Set the parent collection. This is necessary so that nested + * collections' rollback and completion tasks can be added to the + * top-level collection, ensuring that the rollbacks for a collection + * will run if any later task fails. + * + * @param \Robo\Collection\NestedCollectionInterface $parentCollection + * + * @return $this + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->parentCollection = $parentCollection; + return $this; + } + + /** + * Get the appropriate parent collection to use + * + * @return CollectionInterface + */ + public function getParentCollection() + { + return $this->parentCollection ? $this->parentCollection : $this; + } + + /** + * Register a rollback task to run if there is any failure. + * + * Clients are free to add tasks to the rollback stack as + * desired; however, usually it is preferable to call + * Collection::rollback() instead. With that function, + * the rollback function will only be called if all of the + * tasks added before it complete successfully, AND some later + * task fails. + * + * One example of a good use-case for registering a callback + * function directly is to add a task that sends notification + * when a task fails. + * + * @param TaskInterface $rollbackTask + * The rollback task to run on failure. + */ + public function registerRollback(TaskInterface $rollbackTask) + { + if ($this->parentCollection) { + return $this->parentCollection->registerRollback($rollbackTask); + } + if ($rollbackTask) { + $this->rollbackStack[] = $rollbackTask; + } + } + + /** + * Register a completion task to run once all other tasks finish. + * Completion tasks run whether or not a rollback operation was + * triggered. They do not trigger rollbacks if they fail. + * + * The typical use-case for a completion function is to clean up + * temporary objects (e.g. temporary folders). The preferred + * way to do that, though, is to use Temporary::wrap(). + * + * On failures, completion tasks will run after all rollback tasks. + * If one task collection is nested inside another task collection, + * then the nested collection's completion tasks will run as soon as + * the nested task completes; they are not deferred to the end of + * the containing collection's execution. + * + * @param TaskInterface $completionTask + * The completion task to run at the end of all other operations. + */ + public function registerCompletion(TaskInterface $completionTask) + { + if ($this->parentCollection) { + return $this->parentCollection->registerCompletion($completionTask); + } + if ($completionTask) { + // Completion tasks always try as hard as they can, and never report failures. + $completionTask = $this->ignoreErrorsTaskWrapper($completionTask); + $this->completionStack[] = $completionTask; + } + } + + /** + * Return the count of steps in this collection + * + * @return int + */ + public function progressIndicatorSteps() + { + $steps = 0; + foreach ($this->taskList as $name => $taskGroup) { + $steps += $taskGroup->progressIndicatorSteps(); + } + return $steps; + } + + /** + * A Collection of tasks can provide a command via `getCommand()` + * if it contains a single task, and that task implements CommandInterface. + * + * @return string + * + * @throws \Robo\Exception\TaskException + */ + public function getCommand() + { + if (empty($this->taskList)) { + return ''; + } + + if (count($this->taskList) > 1) { + // TODO: We could potentially iterate over the items in the collection + // and concatenate the result of getCommand() from each one, and fail + // only if we encounter a command that is not a CommandInterface. + throw new TaskException($this, "getCommand() does not work on arbitrary collections of tasks."); + } + + $taskElement = reset($this->taskList); + $task = $taskElement->getTask(); + $task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + if ($task instanceof CommandInterface) { + return $task->getCommand(); + } + + throw new TaskException($task, get_class($task) . " does not implement CommandInterface, so can't be used to provide a command"); + } + + /** + * Run our tasks, and roll back if necessary. + * + * @return \Robo\Result + */ + public function run() + { + $result = $this->runWithoutCompletion(); + $this->complete(); + return $result; + } + + /** + * @return \Robo\Result + */ + private function runWithoutCompletion() + { + $result = Result::success($this); + + if (empty($this->taskList)) { + return $result; + } + + $this->startProgressIndicator(); + if ($result->wasSuccessful()) { + foreach ($this->taskList as $name => $taskGroup) { + $taskList = $taskGroup->getTaskList(); + $result = $this->runTaskList($name, $taskList, $result); + if (!$result->wasSuccessful()) { + $this->fail(); + return $result; + } + } + $this->taskList = []; + } + $this->stopProgressIndicator(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * Run every task in a list, but only up to the first failure. + * Return the failing result, or success if all tasks run. + * + * @param string $name + * @param TaskInterface[] $taskList + * @param \Robo\Result $result + * + * @return \Robo\Result + * + * @throws \Robo\Exception\TaskExitException + */ + private function runTaskList($name, array $taskList, Result $result) + { + try { + foreach ($taskList as $taskName => $task) { + $taskResult = $this->runSubtask($task); + $this->advanceProgressIndicator(); + // If the current task returns an error code, then stop + // execution and signal a rollback. + if (!$taskResult->wasSuccessful()) { + return $taskResult; + } + // We accumulate our results into a field so that tasks that + // have a reference to the collection may examine and modify + // the incremental results, if they wish. + $key = Result::isUnnamed($taskName) ? $name : $taskName; + $result->accumulate($key, $taskResult); + // The result message will be the message of the last task executed. + $result->setMessage($taskResult->getMessage()); + } + } catch (TaskExitException $exitException) { + $this->fail(); + throw $exitException; + } catch (\Exception $e) { + // Tasks typically should not throw, but if one does, we will + // convert it into an error and roll back. + return Result::fromException($task, $e, $result->getData()); + } + return $result; + } + + /** + * Force the rollback functions to run + * + * @return $this + */ + public function fail() + { + $this->disableProgressIndicator(); + $this->runRollbackTasks(); + $this->complete(); + return $this; + } + + /** + * Force the completion functions to run + * + * @return $this + */ + public function complete() + { + $this->detatchProgressIndicator(); + $this->runTaskListIgnoringFailures($this->completionStack); + $this->reset(); + return $this; + } + + /** + * Reset this collection, removing all tasks. + * + * @return $this + */ + public function reset() + { + $this->taskList = []; + $this->completionStack = []; + $this->rollbackStack = []; + return $this; + } + + /** + * Run all of our rollback tasks. + * + * Note that Collection does not implement RollbackInterface, but + * it may still be used as a task inside another task collection + * (i.e. you can nest task collections, if desired). + */ + protected function runRollbackTasks() + { + $this->runTaskListIgnoringFailures($this->rollbackStack); + // Erase our rollback stack once we have finished rolling + // everything back. This will allow us to potentially use + // a command collection more than once (e.g. to retry a + // failed operation after doing some error recovery). + $this->rollbackStack = []; + } + + /** + * @param TaskInterface|NestedCollectionInterface|WrappedTaskInterface $task + * + * @return \Robo\Result + */ + protected function runSubtask($task) + { + $original = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->setParentCollectionForTask($original, $this->getParentCollection()); + if ($original instanceof InflectionInterface) { + $original->inflect($this); + } + if ($original instanceof StateAwareInterface) { + $original->setState($this->getState()); + } + $this->doDeferredInitialization($original); + $taskResult = $task->run(); + $taskResult = Result::ensureResult($task, $taskResult); + $this->doStateUpdates($original, $taskResult); + return $taskResult; + } + + protected function doStateUpdates($task, Data $taskResult) + { + $this->updateState($taskResult); + $key = spl_object_hash($task); + if (array_key_exists($key, $this->messageStoreKeys)) { + $state = $this->getState(); + list($stateKey, $sourceKey) = $this->messageStoreKeys[$key]; + $value = empty($sourceKey) ? $taskResult->getMessage() : $taskResult[$sourceKey]; + $state[$stateKey] = $value; + } + } + + public function storeState($task, $key, $source = '') + { + $this->messageStoreKeys[spl_object_hash($task)] = [$key, $source]; + + return $this; + } + + public function deferTaskConfiguration($task, $functionName, $stateKey) + { + return $this->defer( + $task, + function ($task, $state) use ($functionName, $stateKey) { + $fn = [$task, $functionName]; + $value = $state[$stateKey]; + $fn($value); + } + ); + } + + /** + * Defer execution of a callback function until just before a task + * runs. Use this time to provide more settings for the task, e.g. from + * the collection's shared state, which is populated with the results + * of previous test runs. + */ + public function defer($task, $callback) + { + $this->deferredCallbacks[spl_object_hash($task)][] = $callback; + + return $this; + } + + protected function doDeferredInitialization($task) + { + // If the task is a state consumer, then call its receiveState method + if ($task instanceof \Robo\State\Consumer) { + $task->receiveState($this->getState()); + } + + // Check and see if there are any deferred callbacks for this task. + $key = spl_object_hash($task); + if (!array_key_exists($key, $this->deferredCallbacks)) { + return; + } + + // Call all of the deferred callbacks + foreach ($this->deferredCallbacks[$key] as $fn) { + $fn($task, $this->getState()); + } + } + + /** + * @param TaskInterface|NestedCollectionInterface|WrappedTaskInterface $task + * @param $parentCollection + */ + protected function setParentCollectionForTask($task, $parentCollection) + { + if ($task instanceof NestedCollectionInterface) { + $task->setParentCollection($parentCollection); + } + } + + /** + * Run all of the tasks in a provided list, ignoring failures. + * This is used to roll back or complete. + * + * @param TaskInterface[] $taskList + */ + protected function runTaskListIgnoringFailures(array $taskList) + { + foreach ($taskList as $task) { + try { + $this->runSubtask($task); + } catch (\Exception $e) { + // Ignore rollback failures. + } + } + } + + /** + * Give all of our tasks to the provided collection builder. + * + * @param CollectionBuilder $builder + */ + public function transferTasks($builder) + { + foreach ($this->taskList as $name => $taskGroup) { + // TODO: We are abandoning all of our before and after tasks here. + // At the moment, transferTasks is only called under conditions where + // there will be none of these, but care should be taken if that changes. + $task = $taskGroup->getTask(); + $builder->addTaskToCollection($task); + } + $this->reset(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionBuilder.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionBuilder.php new file mode 100644 index 00000000..3e037b01 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionBuilder.php @@ -0,0 +1,571 @@ +collectionBuilder() + * ->taskFilesystemStack() + * ->mkdir('g') + * ->touch('g/g.txt') + * ->rollback( + * $this->taskDeleteDir('g') + * ) + * ->taskFilesystemStack() + * ->mkdir('g/h') + * ->touch('g/h/h.txt') + * ->taskFilesystemStack() + * ->mkdir('g/h/i/c') + * ->touch('g/h/i/i.txt') + * ->run() + * ?> + * + * In the example above, the `taskDeleteDir` will be called if + * ``` + */ +class CollectionBuilder extends BaseTask implements NestedCollectionInterface, WrappedTaskInterface, CommandInterface, StateAwareInterface +{ + use StateAwareTrait; + + /** + * @var \Robo\Tasks + */ + protected $commandFile; + + /** + * @var CollectionInterface + */ + protected $collection; + + /** + * @var TaskInterface + */ + protected $currentTask; + + /** + * @var bool + */ + protected $simulated; + + /** + * @param \Robo\Tasks $commandFile + */ + public function __construct($commandFile) + { + $this->commandFile = $commandFile; + $this->resetState(); + } + + public static function create($container, $commandFile) + { + $builder = new self($commandFile); + + $builder->setLogger($container->get('logger')); + $builder->setProgressIndicator($container->get('progressIndicator')); + $builder->setConfig($container->get('config')); + $builder->setOutputAdapter($container->get('outputAdapter')); + + return $builder; + } + + /** + * @param bool $simulated + * + * @return $this + */ + public function simulated($simulated = true) + { + $this->simulated = $simulated; + return $this; + } + + /** + * @return bool + */ + public function isSimulated() + { + if (!isset($this->simulated)) { + $this->simulated = $this->getConfig()->get(Config::SIMULATE); + } + return $this->simulated; + } + + /** + * Create a temporary directory to work in. When the collection + * completes or rolls back, the temporary directory will be deleted. + * Returns the path to the location where the directory will be + * created. + * + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return string + */ + public function tmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + // n.b. Any task that the builder is asked to create is + // automatically added to the builder's collection, and + // wrapped in the builder object. Therefore, the result + // of any call to `taskFoo()` from within the builder will + // always be `$this`. + return $this->taskTmpDir($prefix, $base, $includeRandomPart)->getPath(); + } + + /** + * Create a working directory to hold results. A temporary directory + * is first created to hold the intermediate results. After the + * builder finishes, the work directory is moved into its final location; + * any results already in place will be moved out of the way and + * then deleted. + * + * @param string $finalDestination The path where the working directory + * will be moved once the task collection completes. + * + * @return string + */ + public function workDir($finalDestination) + { + // Creating the work dir task in this context adds it to our task collection. + return $this->taskWorkDir($finalDestination)->getPath(); + } + + public function addTask(TaskInterface $task) + { + $this->getCollection()->add($task); + return $this; + } + + /** + * Add arbitrary code to execute as a task. + * + * @see \Robo\Collection\CollectionInterface::addCode + * + * @param callable $code + * @param int|string $name + * @return $this + */ + public function addCode(callable $code, $name = \Robo\Collection\CollectionInterface::UNNAMEDTASK) + { + $this->getCollection()->addCode($code, $name); + return $this; + } + + /** + * Add a list of tasks to our task collection. + * + * @param TaskInterface[] $tasks + * An array of tasks to run with rollback protection + * + * @return $this + */ + public function addTaskList(array $tasks) + { + $this->getCollection()->addTaskList($tasks); + return $this; + } + + public function rollback(TaskInterface $task) + { + // Ensure that we have a collection if we are going to add + // a rollback function. + $this->getCollection()->rollback($task); + return $this; + } + + public function rollbackCode(callable $rollbackCode) + { + $this->getCollection()->rollbackCode($rollbackCode); + return $this; + } + + public function completion(TaskInterface $task) + { + $this->getCollection()->completion($task); + return $this; + } + + public function completionCode(callable $completionCode) + { + $this->getCollection()->completionCode($completionCode); + return $this; + } + + /** + * @param string $text + * @param array $context + * @param string $level + * + * @return $this + */ + public function progressMessage($text, $context = [], $level = LogLevel::NOTICE) + { + $this->getCollection()->progressMessage($text, $context, $level); + return $this; + } + + /** + * @param \Robo\Collection\NestedCollectionInterface $parentCollection + * + * @return $this + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->getCollection()->setParentCollection($parentCollection); + return $this; + } + + /** + * Called by the factory method of each task; adds the current + * task to the task builder. + * + * TODO: protected + * + * @param TaskInterface $task + * + * @return $this + */ + public function addTaskToCollection($task) + { + // Postpone creation of the collection until the second time + // we are called. At that time, $this->currentTask will already + // be populated. We call 'getCollection()' so that it will + // create the collection and add the current task to it. + // Note, however, that if our only tasks implements NestedCollectionInterface, + // then we should force this builder to use a collection. + if (!$this->collection && (isset($this->currentTask) || ($task instanceof NestedCollectionInterface))) { + $this->getCollection(); + } + $this->currentTask = $task; + if ($this->collection) { + $this->collection->add($task); + } + return $this; + } + + public function getState() + { + $collection = $this->getCollection(); + return $collection->getState(); + } + + public function storeState($key, $source = '') + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + public function deferTaskConfiguration($functionName, $stateKey) + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + public function defer($callback) + { + return $this->callCollectionStateFuntion(__FUNCTION__, func_get_args()); + } + + protected function callCollectionStateFuntion($functionName, $args) + { + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + + array_unshift($args, $currentTask); + $collection = $this->getCollection(); + $fn = [$collection, $functionName]; + + call_user_func_array($fn, $args); + return $this; + } + + public function setVerbosityThreshold($verbosityThreshold) + { + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + if ($currentTask) { + $currentTask->setVerbosityThreshold($verbosityThreshold); + return $this; + } + parent::setVerbosityThreshold($verbosityThreshold); + return $this; + } + + + /** + * Return the current task for this collection builder. + * TODO: Not needed? + * + * @return \Robo\Contract\TaskInterface + */ + public function getCollectionBuilderCurrentTask() + { + return $this->currentTask; + } + + /** + * Create a new builder with its own task collection + * + * @return CollectionBuilder + */ + public function newBuilder() + { + $collectionBuilder = new self($this->commandFile); + $collectionBuilder->inflect($this); + $collectionBuilder->simulated($this->isSimulated()); + $collectionBuilder->setVerbosityThreshold($this->verbosityThreshold()); + $collectionBuilder->setState($this->getState()); + + return $collectionBuilder; + } + + /** + * Calling the task builder with methods of the current + * task calls through to that method of the task. + * + * There is extra complexity in this function that could be + * simplified if we attached the 'LoadAllTasks' and custom tasks + * to the collection builder instead of the RoboFile. While that + * change would be a better design overall, it would require that + * the user do a lot more work to set up and use custom tasks. + * We therefore take on some additional complexity here in order + * to allow users to maintain their tasks in their RoboFile, which + * is much more convenient. + * + * Calls to $this->collectionBuilder()->taskFoo() cannot be made + * directly because all of the task methods are protected. These + * calls will therefore end up here. If the method name begins + * with 'task', then it is eligible to be used with the builder. + * + * When we call getBuiltTask, below, it will use the builder attached + * to the commandfile to build the task. However, this is not what we + * want: the task needs to be built from THIS collection builder, so that + * it will be affected by whatever state is active in this builder. + * To do this, we have two choices: 1) save and restore the builder + * in the commandfile, or 2) clone the commandfile and set this builder + * on the copy. 1) is vulnerable to failure in multithreaded environments + * (currently not supported), while 2) might cause confusion if there + * is shared state maintained in the commandfile, which is in the + * domain of the user. + * + * Note that even though we are setting up the commandFile to + * use this builder, getBuiltTask always creates a new builder + * (which is constructed using all of the settings from the + * commandFile's builder), and the new task is added to that. + * We therefore need to transfer the newly built task into this + * builder. The temporary builder is discarded. + * + * @param string $fn + * @param array $args + * + * @return $this|mixed + */ + public function __call($fn, $args) + { + if (preg_match('#^task[A-Z]#', $fn) && (method_exists($this->commandFile, 'getBuiltTask'))) { + $saveBuilder = $this->commandFile->getBuilder(); + $this->commandFile->setBuilder($this); + $temporaryBuilder = $this->commandFile->getBuiltTask($fn, $args); + $this->commandFile->setBuilder($saveBuilder); + if (!$temporaryBuilder) { + throw new \BadMethodCallException("No such method $fn: task does not exist in " . get_class($this->commandFile)); + } + $temporaryBuilder->getCollection()->transferTasks($this); + return $this; + } + if (!isset($this->currentTask)) { + throw new \BadMethodCallException("No such method $fn: current task undefined in collection builder."); + } + // If the method called is a method of the current task, + // then call through to the current task's setter method. + $result = call_user_func_array([$this->currentTask, $fn], $args); + + // If something other than a setter method is called, then return its result. + $currentTask = ($this->currentTask instanceof WrappedTaskInterface) ? $this->currentTask->original() : $this->currentTask; + if (isset($result) && ($result !== $currentTask)) { + return $result; + } + + return $this; + } + + /** + * Construct the desired task and add it to this builder. + * + * @param string|object $name + * @param array $args + * + * @return \Robo\Collection\CollectionBuilder + */ + public function build($name, $args) + { + $reflection = new ReflectionClass($name); + $task = $reflection->newInstanceArgs($args); + if (!$task) { + throw new RuntimeException("Can not construct task $name"); + } + $task = $this->fixTask($task, $args); + $this->configureTask($name, $task); + return $this->addTaskToCollection($task); + } + + /** + * @param InflectionInterface $task + * @param array $args + * + * @return \Robo\Collection\CompletionWrapper|\Robo\Task\Simulator + */ + protected function fixTask($task, $args) + { + if ($task instanceof InflectionInterface) { + $task->inflect($this); + } + if ($task instanceof BuilderAwareInterface) { + $task->setBuilder($this); + } + if ($task instanceof VerbosityThresholdInterface) { + $task->setVerbosityThreshold($this->verbosityThreshold()); + } + + // Do not wrap our wrappers. + if ($task instanceof CompletionWrapper || $task instanceof Simulator) { + return $task; + } + + // Remember whether or not this is a task before + // it gets wrapped in any decorator. + $isTask = $task instanceof TaskInterface; + $isCollection = $task instanceof NestedCollectionInterface; + + // If the task implements CompletionInterface, ensure + // that its 'complete' method is called when the application + // terminates -- but only if its 'run' method is called + // first. If the task is added to a collection, then the + // task will be unwrapped via its `original` method, and + // it will be re-wrapped with a new completion wrapper for + // its new collection. + if ($task instanceof CompletionInterface) { + $task = new CompletionWrapper(Temporary::getCollection(), $task); + } + + // If we are in simulated mode, then wrap any task in + // a TaskSimulator. + if ($isTask && !$isCollection && ($this->isSimulated())) { + $task = new \Robo\Task\Simulator($task, $args); + $task->inflect($this); + } + + return $task; + } + + /** + * Check to see if there are any setter methods defined in configuration + * for this task. + */ + protected function configureTask($taskClass, $task) + { + $taskClass = static::configClassIdentifier($taskClass); + $configurationApplier = new ConfigForSetters($this->getConfig(), $taskClass, 'task.'); + $configurationApplier->apply($task, 'settings'); + + // TODO: If we counted each instance of $taskClass that was called from + // this builder, then we could also apply configuration from + // "task.{$taskClass}[$N].settings" + + // TODO: If the builder knew what the current command name was, + // then we could also search for task configuration under + // command-specific keys such as "command.{$commandname}.task.{$taskClass}.settings". + } + + /** + * When we run the collection builder, run everything in the collection. + * + * @return \Robo\Result + */ + public function run() + { + $this->startTimer(); + $result = $this->runTasks(); + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + $result->mergeData($this->getState()->getData()); + return $result; + } + + /** + * If there is a single task, run it; if there is a collection, run + * all of its tasks. + * + * @return \Robo\Result + */ + protected function runTasks() + { + if (!$this->collection && $this->currentTask) { + $result = $this->currentTask->run(); + return Result::ensureResult($this->currentTask, $result); + } + return $this->getCollection()->run(); + } + + /** + * @return string + */ + public function getCommand() + { + if (!$this->collection && $this->currentTask) { + $task = $this->currentTask; + $task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + if ($task instanceof CommandInterface) { + return $task->getCommand(); + } + } + + return $this->getCollection()->getCommand(); + } + + /** + * @return \Robo\Collection\Collection + */ + public function original() + { + return $this->getCollection(); + } + + /** + * Return the collection of tasks associated with this builder. + * + * @return CollectionInterface + */ + public function getCollection() + { + if (!isset($this->collection)) { + $this->collection = new Collection(); + $this->collection->inflect($this); + $this->collection->setState($this->getState()); + $this->collection->setProgressBarAutoDisplayInterval($this->getConfig()->get(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL)); + + if (isset($this->currentTask)) { + $this->collection->add($this->currentTask); + } + } + return $this->collection; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionInterface.php new file mode 100644 index 00000000..173ca169 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CollectionInterface.php @@ -0,0 +1,151 @@ +run(); + } catch (\Exception $e) { + return Result::fromException($result, $e); + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CompletionWrapper.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CompletionWrapper.php new file mode 100644 index 00000000..3e81bd91 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/CompletionWrapper.php @@ -0,0 +1,106 @@ +collection = $collection; + $this->task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->rollbackTask = $rollbackTask; + } + + /** + * {@inheritdoc} + */ + public function original() + { + return $this->task; + } + + /** + * Before running this task, register its rollback and completion + * handlers on its collection. The reason this class exists is to + * defer registration of rollback and completion tasks until 'run()' time. + * + * @return \Robo\Result + */ + public function run() + { + if ($this->rollbackTask) { + $this->collection->registerRollback($this->rollbackTask); + } + if ($this->task instanceof RollbackInterface) { + $this->collection->registerRollback(new CallableTask([$this->task, 'rollback'], $this->task)); + } + if ($this->task instanceof CompletionInterface) { + $this->collection->registerCompletion(new CallableTask([$this->task, 'complete'], $this->task)); + } + + return $this->task->run(); + } + + /** + * Make this wrapper object act like the class it wraps. + * + * @param string $function + * @param array $args + * + * @return mixed + */ + public function __call($function, $args) + { + return call_user_func_array(array($this->task, $function), $args); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Element.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Element.php new file mode 100644 index 00000000..b67b56bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Element.php @@ -0,0 +1,116 @@ +task = $task; + } + + /** + * @param mixed $before + * @param string $name + */ + public function before($before, $name) + { + if ($name) { + $this->before[$name] = $before; + } else { + $this->before[] = $before; + } + } + + /** + * @param mixed $after + * @param string $name + */ + public function after($after, $name) + { + if ($name) { + $this->after[$name] = $after; + } else { + $this->after[] = $after; + } + } + + /** + * @return array + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return array + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function getTask() + { + return $this->task; + } + + /** + * @return array + */ + public function getTaskList() + { + return array_merge($this->getBefore(), [$this->getTask()], $this->getAfter()); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + $steps = 0; + foreach ($this->getTaskList() as $task) { + if ($task instanceof WrappedTaskInterface) { + $task = $task->original(); + } + // If the task is a ProgressIndicatorAwareInterface, then it + // will advance the progress indicator a number of times. + if ($task instanceof ProgressIndicatorAwareInterface) { + $steps += $task->progressIndicatorSteps(); + } + // We also advance the progress indicator once regardless + // of whether it is progress-indicator aware or not. + $steps++; + } + return $steps; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/NestedCollectionInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/NestedCollectionInterface.php new file mode 100644 index 00000000..5e32cf37 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/NestedCollectionInterface.php @@ -0,0 +1,12 @@ +iterable = $iterable; + } + + /** + * @param string $message + * @param array $context + * + * @return $this + */ + public function iterationMessage($message, $context = []) + { + $this->message = $message; + $this->context = $context + ['name' => 'Progress']; + return $this; + } + + /** + * @param int|string $key + * @param mixed $value + */ + protected function showIterationMessage($key, $value) + { + if ($this->message) { + $context = ['key' => $key, 'value' => $value]; + $context += $this->context; + $context += TaskInfo::getTaskContext($this); + $this->printTaskInfo($this->message, $context); + } + } + + /** + * @param callable $fn + * + * @return $this + */ + public function withEachKeyValueCall(callable $fn) + { + $this->functionStack[] = $fn; + return $this; + } + + /** + * @param callable $fn + * + * @return \Robo\Collection\TaskForEach + */ + public function call(callable $fn) + { + return $this->withEachKeyValueCall( + function ($key, $value) use ($fn) { + return call_user_func($fn, $value); + } + ); + } + + /** + * @param callable $fn + * + * @return \Robo\Collection\TaskForEach + */ + public function withBuilder(callable $fn) + { + $this->countingStack[] = + function ($key, $value) use ($fn) { + // Create a new builder for every iteration + $builder = $this->collectionBuilder(); + // The user function should build task operations using + // the $key / $value parameters; we will call run() on + // the builder thus constructed. + call_user_func($fn, $builder, $key, $value); + return $builder->getCollection()->progressIndicatorSteps(); + }; + return $this->withEachKeyValueCall( + function ($key, $value) use ($fn) { + // Create a new builder for every iteration + $builder = $this->collectionBuilder() + ->setParentCollection($this->parentCollection); + // The user function should build task operations using + // the $key / $value parameters; we will call run() on + // the builder thus constructed. + call_user_func($fn, $builder, $key, $value); + return $builder->run(); + } + ); + } + + /** + * {@inheritdoc} + */ + public function setParentCollection(NestedCollectionInterface $parentCollection) + { + $this->parentCollection = $parentCollection; + return $this; + } + + /** + * {@inheritdoc} + */ + public function progressIndicatorSteps() + { + $multiplier = count($this->functionStack); + if (!empty($this->countingStack)) { + $value = reset($this->iterable); + $key = key($this->iterable); + foreach ($this->countingStack as $fn) { + $multiplier += call_user_func($fn, $key, $value); + } + } + return count($this->iterable) * $multiplier; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $finalResult = Result::success($this); + $this->startProgressIndicator(); + foreach ($this->iterable as $key => $value) { + $this->showIterationMessage($key, $value); + try { + foreach ($this->functionStack as $fn) { + $result = call_user_func($fn, $key, $value); + $this->advanceProgressIndicator(); + if (!isset($result)) { + $result = Result::success($this); + } + // If the function returns a result, it must either return + // a \Robo\Result or an exit code. In the later case, we + // convert it to a \Robo\Result. + if (!$result instanceof Result) { + $result = new Result($this, $result); + } + if (!$result->wasSuccessful()) { + return $result; + } + $finalResult = $result->merge($finalResult); + } + } catch (\Exception $e) { + return Result::fromException($result, $e); + } + } + $this->stopProgressIndicator(); + return $finalResult; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Temporary.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Temporary.php new file mode 100644 index 00000000..dad25e34 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/Temporary.php @@ -0,0 +1,57 @@ +get('collection'); + register_shutdown_function(function () { + static::complete(); + }); + } + + return static::$collection; + } + + /** + * Call the complete method of all of the registered objects. + */ + public static function complete() + { + // Run the collection of tasks. This will also run the + // completion tasks. + $collection = static::getCollection(); + $collection->run(); + // Make sure that our completion functions do not run twice. + $collection->reset(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/loadTasks.php new file mode 100644 index 00000000..03f68823 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Collection/loadTasks.php @@ -0,0 +1,17 @@ +task(TaskForEach::class, $collection); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/BuilderAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/BuilderAwareTrait.php new file mode 100644 index 00000000..915ff008 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/BuilderAwareTrait.php @@ -0,0 +1,45 @@ +builder = $builder; + + return $this; + } + + /** + * @see \Robo\Contract\BuilderAwareInterface::getBuilder() + * + * @return \Robo\Collection\CollectionBuilder + */ + public function getBuilder() + { + return $this->builder; + } + + /** + * @return \Robo\Collection\CollectionBuilder + */ + protected function collectionBuilder() + { + return $this->getBuilder()->newBuilder(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandArguments.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandArguments.php new file mode 100644 index 00000000..12c2e89f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandArguments.php @@ -0,0 +1,130 @@ +args($arg); + } + + /** + * Pass methods parameters as arguments to executable. Argument values + * are automatically escaped. + * + * @param string|string[] $args + * + * @return $this + */ + public function args($args) + { + if (!is_array($args)) { + $args = func_get_args(); + } + $this->arguments .= ' ' . implode(' ', array_map('static::escape', $args)); + return $this; + } + + /** + * Pass the provided string in its raw (as provided) form as an argument to executable. + * + * @param string $arg + * + * @return $this + */ + public function rawArg($arg) + { + $this->arguments .= " $arg"; + + return $this; + } + + /** + * Escape the provided value, unless it contains only alphanumeric + * plus a few other basic characters. + * + * @param string $value + * + * @return string + */ + public static function escape($value) + { + if (preg_match('/^[a-zA-Z0-9\/\.@~_-]+$/', $value)) { + return $value; + } + return ProcessUtils::escapeArgument($value); + } + + /** + * Pass option to executable. Options are prefixed with `--` , value can be provided in second parameter. + * Option values are automatically escaped. + * + * @param string $option + * @param string $value + * @param string $separator + * + * @return $this + */ + public function option($option, $value = null, $separator = ' ') + { + if ($option !== null and strpos($option, '-') !== 0) { + $option = "--$option"; + } + $this->arguments .= null == $option ? '' : " " . $option; + $this->arguments .= null == $value ? '' : $separator . static::escape($value); + return $this; + } + + /** + * Pass multiple options to executable. The associative array contains + * the key:value pairs that become `--key value`, for each item in the array. + * Values are automatically escaped. + */ + public function options(array $options, $separator = ' ') + { + foreach ($options as $option => $value) { + $this->option($option, $value, $separator); + } + return $this; + } + + /** + * Pass an option with multiple values to executable. Value can be a string or array. + * Option values are automatically escaped. + * + * @param string $option + * @param string|array $value + * @param string $separator + * + * @return $this + */ + public function optionList($option, $value = array(), $separator = ' ') + { + if (is_array($value)) { + foreach ($value as $item) { + $this->optionList($option, $item, $separator); + } + } else { + $this->option($option, $value, $separator); + } + + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandReceiver.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandReceiver.php new file mode 100644 index 00000000..03b20fce --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/CommandReceiver.php @@ -0,0 +1,30 @@ +getCommand(); + } else { + throw new TaskException($this, get_class($command) . " does not implement CommandInterface, so can't be passed into this task"); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ConfigAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ConfigAwareTrait.php new file mode 100644 index 00000000..d6d45788 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ConfigAwareTrait.php @@ -0,0 +1,109 @@ +config = $config; + + return $this; + } + + /** + * Get the config management object. + * + * @return ConfigInterface + * + * @see \Robo\Contract\ConfigAwareInterface::getConfig() + */ + public function getConfig() + { + return $this->config; + } + + /** + * Any class that uses ConfigAwareTrait SHOULD override this method + * , and define a prefix for its configuration items. This is usually + * done in a base class. When used, this method should return a string + * that ends with a "."; see BaseTask::configPrefix(). + * + * @return string + */ + protected static function configPrefix() + { + return ''; + } + + protected static function configClassIdentifier($classname) + { + $configIdentifier = strtr($classname, '\\', '.'); + $configIdentifier = preg_replace('#^(.*\.Task\.|\.)#', '', $configIdentifier); + + return $configIdentifier; + } + + protected static function configPostfix() + { + return ''; + } + + /** + * @param string $key + * + * @return string + */ + private static function getClassKey($key) + { + $configPrefix = static::configPrefix(); // task. + $configClass = static::configClassIdentifier(get_called_class()); // PARTIAL_NAMESPACE.CLASSNAME + $configPostFix = static::configPostfix(); // .settings + + return sprintf('%s%s%s.%s', $configPrefix, $configClass, $configPostFix, $key); + } + + /** + * @param string $key + * @param mixed $value + * @param Config|null $config + */ + public static function configure($key, $value, $config = null) + { + if (!$config) { + $config = Robo::config(); + } + $config->setDefault(static::getClassKey($key), $value); + } + + /** + * @param string $key + * @param mixed|null $default + * + * @return mixed|null + */ + protected function getConfigValue($key, $default = null) + { + if (!$this->getConfig()) { + return $default; + } + return $this->getConfig()->get(static::getClassKey($key), $default); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/DynamicParams.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/DynamicParams.php new file mode 100644 index 00000000..28a1d150 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/DynamicParams.php @@ -0,0 +1,45 @@ +$property))) { + $this->$property = !$this->$property; + return $this; + } + + // append item to array + if (is_array($this->$property)) { + if (is_array($args[0])) { + $this->$property = $args[0]; + } else { + array_push($this->$property, $args[0]); + } + return $this; + } + + $this->$property = $args[0]; + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecCommand.php new file mode 100644 index 00000000..c3e6c3af --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecCommand.php @@ -0,0 +1,148 @@ +execTimer)) { + $this->execTimer = new TimeKeeper(); + } + return $this->execTimer; + } + + /** + * Look for a "{$cmd}.phar" in the current working + * directory; return a string to exec it if it is + * found. Otherwise, look for an executable command + * of the same name via findExecutable. + * + * @param string $cmd + * + * @return bool|string + */ + protected function findExecutablePhar($cmd) + { + if (file_exists("{$cmd}.phar")) { + return "php {$cmd}.phar"; + } + return $this->findExecutable($cmd); + } + + /** + * Return the best path to the executable program + * with the provided name. Favor vendor/bin in the + * current project. If not found there, use + * whatever is on the $PATH. + * + * @param string $cmd + * + * @return bool|string + */ + protected function findExecutable($cmd) + { + $pathToCmd = $this->searchForExecutable($cmd); + if ($pathToCmd) { + return $this->useCallOnWindows($pathToCmd); + } + return false; + } + + /** + * @param string $cmd + * + * @return string + */ + private function searchForExecutable($cmd) + { + $projectBin = $this->findProjectBin(); + + $localComposerInstallation = $projectBin . DIRECTORY_SEPARATOR . $cmd; + if (file_exists($localComposerInstallation)) { + return $localComposerInstallation; + } + $finder = new ExecutableFinder(); + return $finder->find($cmd, null, []); + } + + /** + * @return bool|string + */ + protected function findProjectBin() + { + $cwd = getcwd(); + $candidates = [ __DIR__ . '/../../vendor/bin', __DIR__ . '/../../bin', $cwd . '/vendor/bin' ]; + + // If this project is inside a vendor directory, give highest priority + // to that directory. + $vendorDirContainingUs = realpath(__DIR__ . '/../../../..'); + if (is_dir($vendorDirContainingUs) && (basename($vendorDirContainingUs) == 'vendor')) { + array_unshift($candidates, $vendorDirContainingUs . '/bin'); + } + + foreach ($candidates as $dir) { + if (is_dir("$dir")) { + return realpath($dir); + } + } + return false; + } + + /** + * Wrap Windows executables in 'call' per 7a88757d + * + * @param string $cmd + * + * @return string + */ + protected function useCallOnWindows($cmd) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if (file_exists("{$cmd}.bat")) { + $cmd = "{$cmd}.bat"; + } + return "call $cmd"; + } + return $cmd; + } + + protected function getCommandDescription() + { + return $this->process->getCommandLine(); + } + + /** + * @param string $command + * + * @return \Robo\Result + */ + protected function executeCommand($command) + { + // TODO: Symfony 4 requires that we supply the working directory. + $result_data = $this->execute(new Process($command, getcwd())); + return new Result( + $this, + $result_data->getExitCode(), + $result_data->getMessage(), + $result_data->getData() + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecOneCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecOneCommand.php new file mode 100644 index 00000000..60137514 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ExecOneCommand.php @@ -0,0 +1,12 @@ +interactive() based on posix_isatty(). + * + * @return $this + */ + public function detectInteractive() + { + // If the caller did not explicity set the 'interactive' mode, + // and output should be produced by this task (verbosityMeetsThreshold), + // then we will automatically set interactive mode based on whether + // or not output was redirected when robo was executed. + if (!isset($this->interactive) && function_exists('posix_isatty') && $this->verbosityMeetsThreshold()) { + $this->interactive = posix_isatty(STDOUT); + } + + return $this; + } + + /** + * Executes command in background mode (asynchronously) + * + * @return $this + */ + public function background($arg = true) + { + $this->background = $arg; + return $this; + } + + /** + * Stop command if it runs longer then $timeout in seconds + * + * @param int $timeout + * + * @return $this + */ + public function timeout($timeout) + { + $this->timeout = $timeout; + return $this; + } + + /** + * Stops command if it does not output something for a while + * + * @param int $timeout + * + * @return $this + */ + public function idleTimeout($timeout) + { + $this->idleTimeout = $timeout; + return $this; + } + + /** + * Set a single environment variable, or multiple. + */ + public function env($env, $value = null) + { + if (!is_array($env)) { + $env = [$env => ($value ? $value : true)]; + } + return $this->envVars($env); + } + + /** + * Sets the environment variables for the command + * + * @param array $env + * + * @return $this + */ + public function envVars(array $env) + { + $this->env = $env; + return $this; + } + + /** + * Pass an input to the process. Can be resource created with fopen() or string + * + * @param resource|string $input + * + * @return $this + */ + public function setInput($input) + { + $this->input = $input; + return $this; + } + + /** + * Attach tty to process for interactive input + * + * @param $interactive bool + * + * @return $this + */ + public function interactive($interactive = true) + { + $this->interactive = $interactive; + return $this; + } + + + /** + * Is command printing its output to screen + * + * @return bool + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * Changes working directory of command + * + * @param string $dir + * + * @return $this + */ + public function dir($dir) + { + $this->workingDirectory = $dir; + return $this; + } + + /** + * Shortcut for setting isPrinted() and isMetadataPrinted() to false. + * + * @param bool $arg + * + * @return $this + */ + public function silent($arg) + { + if (is_bool($arg)) { + $this->isPrinted = !$arg; + $this->isMetadataPrinted = !$arg; + } + return $this; + } + + /** + * Should command output be printed + * + * @param bool $arg + * + * @return $this + * + * @deprecated + */ + public function printed($arg) + { + $this->logger->warning("printed() is deprecated. Please use printOutput()."); + return $this->printOutput($arg); + } + + /** + * Should command output be printed + * + * @param bool $arg + * + * @return $this + */ + public function printOutput($arg) + { + if (is_bool($arg)) { + $this->isPrinted = $arg; + } + return $this; + } + + /** + * Should command metadata be printed. I,e., command and timer. + * + * @param bool $arg + * + * @return $this + */ + public function printMetadata($arg) + { + if (is_bool($arg)) { + $this->isMetadataPrinted = $arg; + } + return $this; + } + + /** + * @param Process $process + * @param callable $output_callback + * + * @return \Robo\ResultData + */ + protected function execute($process, $output_callback = null) + { + $this->process = $process; + + if (!$output_callback) { + $output_callback = function ($type, $buffer) { + $progressWasVisible = $this->hideTaskProgress(); + $this->writeMessage($buffer); + $this->showTaskProgress($progressWasVisible); + }; + } + + $this->detectInteractive(); + + if ($this->isMetadataPrinted) { + $this->printAction(); + } + $this->process->setTimeout($this->timeout); + $this->process->setIdleTimeout($this->idleTimeout); + if ($this->workingDirectory) { + $this->process->setWorkingDirectory($this->workingDirectory); + } + if ($this->input) { + $this->process->setInput($this->input); + } + + if ($this->interactive && $this->isPrinted) { + $this->process->setTty(true); + } + + if (isset($this->env)) { + $this->process->setEnv($this->env); + } + + if (!$this->background && !$this->isPrinted) { + $this->startTimer(); + $this->process->run(); + $this->stopTimer(); + $output = rtrim($this->process->getOutput()); + return new ResultData( + $this->process->getExitCode(), + $output, + $this->getResultData() + ); + } + + if (!$this->background && $this->isPrinted) { + $this->startTimer(); + $this->process->run($output_callback); + $this->stopTimer(); + return new ResultData( + $this->process->getExitCode(), + $this->process->getOutput(), + $this->getResultData() + ); + } + + try { + $this->process->start(); + } catch (\Exception $e) { + return new ResultData( + $this->process->getExitCode(), + $e->getMessage(), + $this->getResultData() + ); + } + return new ResultData($this->process->getExitCode()); + } + + /** + * + */ + protected function stop() + { + if ($this->background && isset($this->process) && $this->process->isRunning()) { + $this->process->stop(); + $this->printTaskInfo( + "Stopped {command}", + ['command' => $this->getCommandDescription()] + ); + } + } + + /** + * @param array $context + */ + protected function printAction($context = []) + { + $command = $this->getCommandDescription(); + $formatted_command = $this->formatCommandDisplay($command); + + $dir = $this->workingDirectory ? " in {dir}" : ""; + $this->printTaskInfo("Running {command}$dir", [ + 'command' => $formatted_command, + 'dir' => $this->workingDirectory + ] + $context); + } + + /** + * @param $command + * + * @return mixed + */ + protected function formatCommandDisplay($command) + { + $formatted_command = str_replace("&&", "&&\n", $command); + $formatted_command = str_replace("||", "||\n", $formatted_command); + + return $formatted_command; + } + + /** + * Gets the data array to be passed to Result(). + * + * @return array + * The data array passed to Result(). + */ + protected function getResultData() + { + if ($this->isMetadataPrinted) { + return ['time' => $this->getExecutionTime()]; + } + + return []; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/IO.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/IO.php new file mode 100644 index 00000000..d6c77bff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/IO.php @@ -0,0 +1,171 @@ +io) { + $this->io = new SymfonyStyle($this->input(), $this->output()); + } + return $this->io; + } + + /** + * @param string $nonDecorated + * @param string $decorated + * + * @return string + */ + protected function decorationCharacter($nonDecorated, $decorated) + { + if (!$this->output()->isDecorated() || (strncasecmp(PHP_OS, 'WIN', 3) == 0)) { + return $nonDecorated; + } + return $decorated; + } + + /** + * @param string $text + */ + protected function say($text) + { + $char = $this->decorationCharacter('>', '➜'); + $this->writeln("$char $text"); + } + + /** + * @param string $text + * @param int $length + * @param string $color + */ + protected function yell($text, $length = 40, $color = 'green') + { + $char = $this->decorationCharacter(' ', '➜'); + $format = "$char %s"; + $this->formattedOutput($text, $length, $format); + } + + /** + * @param string $text + * @param int $length + * @param string $format + */ + protected function formattedOutput($text, $length, $format) + { + $lines = explode("\n", trim($text, "\n")); + $maxLineLength = array_reduce(array_map('strlen', $lines), 'max'); + $length = max($length, $maxLineLength); + $len = $length + 2; + $space = str_repeat(' ', $len); + $this->writeln(sprintf($format, $space)); + foreach ($lines as $line) { + $line = str_pad($line, $length, ' ', STR_PAD_BOTH); + $this->writeln(sprintf($format, " $line ")); + } + $this->writeln(sprintf($format, $space)); + } + + /** + * @param string $question + * @param bool $hideAnswer + * + * @return string + */ + protected function ask($question, $hideAnswer = false) + { + if ($hideAnswer) { + return $this->askHidden($question); + } + return $this->doAsk(new Question($this->formatQuestion($question))); + } + + /** + * @param string $question + * + * @return string + */ + protected function askHidden($question) + { + $question = new Question($this->formatQuestion($question)); + $question->setHidden(true); + return $this->doAsk($question); + } + + /** + * @param string $question + * @param string $default + * + * @return string + */ + protected function askDefault($question, $default) + { + return $this->doAsk(new Question($this->formatQuestion("$question [$default]"), $default)); + } + + /** + * @param string $question + * + * @return string + */ + protected function confirm($question) + { + return $this->doAsk(new ConfirmationQuestion($this->formatQuestion($question . ' (y/n)'), false)); + } + + /** + * @param \Symfony\Component\Console\Question\Question $question + * + * @return string + */ + protected function doAsk(Question $question) + { + return $this->getDialog()->ask($this->input(), $this->output(), $question); + } + + /** + * @param string $message + * + * @return string + */ + protected function formatQuestion($message) + { + return "? $message "; + } + + /** + * @return \Symfony\Component\Console\Helper\QuestionHelper + */ + protected function getDialog() + { + return new QuestionHelper(); + } + + /** + * @param $text + */ + protected function writeln($text) + { + $this->output()->writeln($text); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InflectionTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InflectionTrait.php new file mode 100644 index 00000000..8bc4e831 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InflectionTrait.php @@ -0,0 +1,21 @@ +injectDependencies($this); + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InputAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InputAwareTrait.php new file mode 100644 index 00000000..bae58c17 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/InputAwareTrait.php @@ -0,0 +1,51 @@ +input = $input; + + return $this; + } + + /** + * @return \Symfony\Component\Console\Input\InputInterface + */ + protected function input() + { + if (!isset($this->input)) { + $this->setInput(new ArgvInput()); + } + return $this->input; + } + + /** + * Backwards compatibility. + * + * @return \Symfony\Component\Console\Input\InputInterface + * + * @deprecated + */ + protected function getInput() + { + return $this->input(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAdapter.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAdapter.php new file mode 100644 index 00000000..b8e795f2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAdapter.php @@ -0,0 +1,38 @@ + OutputInterface::VERBOSITY_NORMAL, + VerbosityThresholdInterface::VERBOSITY_VERBOSE => OutputInterface::VERBOSITY_VERBOSE, + VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE, + VerbosityThresholdInterface::VERBOSITY_DEBUG => OutputInterface::VERBOSITY_DEBUG, + ]; + + public function verbosityMeetsThreshold($verbosityThreshold) + { + if (!isset($this->verbosityMap[$verbosityThreshold])) { + return true; + } + $verbosityThreshold = $this->verbosityMap[$verbosityThreshold]; + $verbosity = $this->output()->getVerbosity(); + + return $verbosity >= $verbosityThreshold; + } + + public function writeMessage($message) + { + $this->output()->write($message); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAwareTrait.php new file mode 100644 index 00000000..48082cb3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/OutputAwareTrait.php @@ -0,0 +1,51 @@ +output = $output; + + return $this; + } + + /** + * @return \Symfony\Component\Console\Output\OutputInterface + */ + protected function output() + { + if (!isset($this->output)) { + $this->setOutput(new NullOutput()); + } + return $this->output; + } + + /** + * Backwards compatibility + * + * @return \Symfony\Component\Console\Output\OutputInterface + * + * @deprecated + */ + protected function getOutput() + { + return $this->output(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessExecutor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessExecutor.php new file mode 100644 index 00000000..f78a4775 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessExecutor.php @@ -0,0 +1,51 @@ +process = $process; + } + + public static function create($container, $process) + { + $processExecutor = new self($process); + + $processExecutor->setLogger($container->get('logger')); + $processExecutor->setProgressIndicator($container->get('progressIndicator')); + $processExecutor->setConfig($container->get('config')); + $processExecutor->setOutputAdapter($container->get('outputAdapter')); + + return $processExecutor; + } + + /** + * @return string + */ + protected function getCommandDescription() + { + return $this->process->getCommandLine(); + } + + public function run() + { + return $this->execute($this->process); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessUtils.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessUtils.php new file mode 100644 index 00000000..7dc4e553 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProcessUtils.php @@ -0,0 +1,79 @@ + + */ + +namespace Robo\Common; + +use Symfony\Component\Process\Exception\InvalidArgumentException; + +/** + * ProcessUtils is a bunch of utility methods. We want to allow Robo 1.x + * to work with Symfony 4.x while remaining backwards compatibility. This + * requires us to replace some deprecated functionality removed in Symfony. + */ +class ProcessUtils +{ + /** + * This class should not be instantiated. + */ + private function __construct() + { + } + + /** + * Escapes a string to be used as a shell argument. + * + * @param string $argument The argument that will be escaped + * + * @return string The escaped argument + * + * @deprecated since version 3.3, to be removed in 4.0. Use a command line array or give env vars to the `Process::start/run()` method instead. + */ + public static function escapeArgument($argument) + { + @trigger_error('The '.__METHOD__.'() method is a copy of a method that was deprecated by Symfony 3.3 and removed in Symfony 4; it will be removed in Robo 2.0.', E_USER_DEPRECATED); + + //Fix for PHP bug #43784 escapeshellarg removes % from given string + //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows + //@see https://bugs.php.net/bug.php?id=43784 + //@see https://bugs.php.net/bug.php?id=49446 + if ('\\' === DIRECTORY_SEPARATOR) { + if ('' === $argument) { + return escapeshellarg($argument); + } + + $escapedArgument = ''; + $quote = false; + foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' === $part) { + $escapedArgument .= '\\"'; + } elseif (self::isSurroundedBy($part, '%')) { + // Avoid environment variable expansion + $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%'; + } else { + // escape trailing backslash + if ('\\' === substr($part, -1)) { + $part .= '\\'; + } + $quote = true; + $escapedArgument .= $part; + } + } + if ($quote) { + $escapedArgument = '"'.$escapedArgument.'"'; + } + + return $escapedArgument; + } + + return "'".str_replace("'", "'\\''", $argument)."'"; + } + + private static function isSurroundedBy($arg, $char) + { + return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicator.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicator.php new file mode 100644 index 00000000..050250e5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicator.php @@ -0,0 +1,201 @@ +progressBar = $progressBar; + $this->output = $output; + } + + /** + * @param int $interval + */ + public function setProgressBarAutoDisplayInterval($interval) + { + if ($this->progressIndicatorRunning) { + return; + } + $this->autoDisplayInterval = $interval; + } + + /** + * @return bool + */ + public function hideProgressIndicator() + { + $result = $this->progressBarDisplayed; + if ($this->progressIndicatorRunning && $this->progressBarDisplayed) { + $this->progressBar->clear(); + // Hack: progress indicator does not reset cursor to beginning of line on 'clear' + $this->output->write("\x0D"); + $this->progressBarDisplayed = false; + } + return $result; + } + + public function showProgressIndicator() + { + if ($this->progressIndicatorRunning && !$this->progressBarDisplayed && isset($this->progressBar)) { + $this->progressBar->display(); + $this->progressBarDisplayed = true; + $this->advanceProgressIndicatorCachedSteps(); + } + } + + /** + * @param bool $visible + */ + public function restoreProgressIndicator($visible) + { + if ($visible) { + $this->showProgressIndicator(); + } + } + + /** + * @param int $totalSteps + * @param \Robo\Contract\TaskInterface $owner + */ + public function startProgressIndicator($totalSteps, $owner) + { + if (!isset($this->progressBar)) { + return; + } + + $this->progressIndicatorRunning = true; + if (!isset($this->owner)) { + $this->owner = $owner; + $this->startTimer(); + $this->totalSteps = $totalSteps; + $this->autoShowProgressIndicator(); + } + } + + public function autoShowProgressIndicator() + { + if (($this->autoDisplayInterval < 0) || !isset($this->progressBar) || !$this->output->isDecorated()) { + return; + } + if ($this->autoDisplayInterval <= $this->getExecutionTime()) { + $this->autoDisplayInterval = -1; + $this->progressBar->start($this->totalSteps); + $this->showProgressIndicator(); + } + } + + /** + * @return bool + */ + public function inProgress() + { + return $this->progressIndicatorRunning; + } + + /** + * @param \Robo\Contract\TaskInterface $owner + */ + public function stopProgressIndicator($owner) + { + if ($this->progressIndicatorRunning && ($this->owner === $owner)) { + $this->cleanup(); + } + } + + protected function cleanup() + { + $this->progressIndicatorRunning = false; + $this->owner = null; + if ($this->progressBarDisplayed) { + $this->progressBar->finish(); + // Hack: progress indicator does not always finish cleanly + $this->output->writeln(''); + $this->progressBarDisplayed = false; + } + $this->stopTimer(); + } + + /** + * Erase progress indicator and ensure it never returns. Used + * only during error handlers. + */ + public function disableProgressIndicator() + { + $this->cleanup(); + // ProgressIndicator is shared, so this permanently removes + // the program's ability to display progress bars. + $this->progressBar = null; + } + + /** + * @param int $steps + */ + public function advanceProgressIndicator($steps = 1) + { + $this->cachedSteps += $steps; + if ($this->progressIndicatorRunning) { + $this->autoShowProgressIndicator(); + // We only want to call `advance` if the progress bar is visible, + // because it always displays itself when it is advanced. + if ($this->progressBarDisplayed) { + return $this->advanceProgressIndicatorCachedSteps(); + } + } + } + + protected function advanceProgressIndicatorCachedSteps() + { + $this->progressBar->advance($this->cachedSteps); + $this->cachedSteps = 0; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicatorAwareTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicatorAwareTrait.php new file mode 100644 index 00000000..060e039a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ProgressIndicatorAwareTrait.php @@ -0,0 +1,135 @@ +progressIndicator = $progressIndicator; + + return $this; + } + + /** + * @return null|bool + */ + protected function hideProgressIndicator() + { + if (!$this->progressIndicator) { + return; + } + return $this->progressIndicator->hideProgressIndicator(); + } + + protected function showProgressIndicator() + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->showProgressIndicator(); + } + + /** + * @param bool $visible + */ + protected function restoreProgressIndicator($visible) + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->restoreProgressIndicator($visible); + } + + /** + * @return int + */ + protected function getTotalExecutionTime() + { + if (!$this->progressIndicator) { + return 0; + } + return $this->progressIndicator->getExecutionTime(); + } + + protected function startProgressIndicator() + { + $this->startTimer(); + if ($this instanceof VerbosityThresholdInterface + && !$this->verbosityMeetsThreshold()) { + return; + } + if (!$this->progressIndicator) { + return; + } + $totalSteps = $this->progressIndicatorSteps(); + $this->progressIndicator->startProgressIndicator($totalSteps, $this); + } + + /** + * @return bool + */ + protected function inProgress() + { + if (!$this->progressIndicator) { + return false; + } + return $this->progressIndicator->inProgress(); + } + + protected function stopProgressIndicator() + { + $this->stopTimer(); + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->stopProgressIndicator($this); + } + + protected function disableProgressIndicator() + { + $this->stopTimer(); + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->disableProgressIndicator(); + } + + protected function detatchProgressIndicator() + { + $this->setProgressIndicator(null); + } + + /** + * @param int $steps + */ + protected function advanceProgressIndicator($steps = 1) + { + if (!$this->progressIndicator) { + return; + } + $this->progressIndicator->advanceProgressIndicator($steps); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ResourceExistenceChecker.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ResourceExistenceChecker.php new file mode 100644 index 00000000..233f90a9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/ResourceExistenceChecker.php @@ -0,0 +1,116 @@ +printTaskError(sprintf('Invalid glob "%s"!', $resource), $this); + $success = false; + continue; + } + foreach ($glob as $resource) { + if (!$this->checkResource($resource, $type)) { + $success = false; + } + } + } + return $success; + } + + /** + * Checks a single resource, file or directory. + * + * It will print an error as well on the console. + * + * @param string $resource File or folder. + * @param string $type "file", "dir", "fileAndDir" + * + * @return bool + */ + protected function checkResource($resource, $type) + { + switch ($type) { + case 'file': + if (!$this->isFile($resource)) { + $this->printTaskError(sprintf('File "%s" does not exist!', $resource), $this); + return false; + } + return true; + case 'dir': + if (!$this->isDir($resource)) { + $this->printTaskError(sprintf('Directory "%s" does not exist!', $resource), $this); + return false; + } + return true; + case 'fileAndDir': + if (!$this->isDir($resource) && !$this->isFile($resource)) { + $this->printTaskError(sprintf('File or directory "%s" does not exist!', $resource), $this); + return false; + } + return true; + } + } + + /** + * Convenience method to check the often uses "source => target" file / folder arrays. + * + * @param string|array $resources + */ + protected function checkSourceAndTargetResource($resources) + { + if (is_string($resources)) { + $resources = [$resources]; + } + $sources = []; + $targets = []; + foreach ($resources as $source => $target) { + $sources[] = $source; + $target[] = $target; + } + $this->checkResources($sources); + $this->checkResources($targets); + } + + /** + * Wrapper method around phps is_dir() + * + * @param string $directory + * + * @return bool + */ + protected function isDir($directory) + { + return is_dir($directory); + } + + /** + * Wrapper method around phps file_exists() + * + * @param string $file + * + * @return bool + */ + protected function isFile($file) + { + return file_exists($file); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TaskIO.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TaskIO.php new file mode 100644 index 00000000..49b5ccd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TaskIO.php @@ -0,0 +1,237 @@ +logger should always be set in Robo core tasks. + if ($this->logger) { + return $this->logger; + } + + // TODO: Remove call to Robo::logger() once maintaining backwards + // compatibility with legacy external Robo tasks is no longer desired. + if (!Robo::logger()) { + return null; + } + + static $gaveDeprecationWarning = false; + if (!$gaveDeprecationWarning) { + trigger_error('No logger set for ' . get_class($this) . '. Use $this->task(Foo::class) rather than new Foo() in loadTasks to ensure the builder can initialize task the task, or use $this->collectionBuilder()->taskFoo() if creating one task from within another.', E_USER_DEPRECATED); + $gaveDeprecationWarning = true; + } + return Robo::logger(); + } + + /** + * Print information about a task in progress. + * + * With the Symfony Console logger, NOTICE is displayed at VERBOSITY_VERBOSE + * and INFO is displayed at VERBOSITY_VERY_VERBOSE. + * + * Robo overrides the default such that NOTICE is displayed at + * VERBOSITY_NORMAL and INFO is displayed at VERBOSITY_VERBOSE. + * + * n.b. We should probably have printTaskNotice for our ordinary + * output, and use printTaskInfo for less interesting messages. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskInfo($text, $context = null) + { + // The 'note' style is used for both 'notice' and 'info' log levels; + // However, 'notice' is printed at VERBOSITY_NORMAL, whereas 'info' + // is only printed at VERBOSITY_VERBOSE. + $this->printTaskOutput(LogLevel::NOTICE, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that some part of the task succeeded. + * + * With the Symfony Console logger, success messages are remapped to NOTICE, + * and displayed in VERBOSITY_VERBOSE. When used with the Robo logger, + * success messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskSuccess($text, $context = null) + { + // Not all loggers will recognize ConsoleLogLevel::SUCCESS. + // We therefore log as LogLevel::NOTICE, and apply a '_level' + // override in the context so that this message will be + // logged as SUCCESS if that log level is recognized. + $context['_level'] = ConsoleLogLevel::SUCCESS; + $this->printTaskOutput(LogLevel::NOTICE, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that there is something wrong, but + * execution can continue. + * + * Warning messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskWarning($text, $context = null) + { + $this->printTaskOutput(LogLevel::WARNING, $text, $this->getTaskContext($context)); + } + + /** + * Provide notification that some operation in the task failed, + * and the task cannot continue. + * + * Error messages are displayed at VERBOSITY_NORMAL. + * + * @param string $text + * @param null|array $context + */ + protected function printTaskError($text, $context = null) + { + $this->printTaskOutput(LogLevel::ERROR, $text, $this->getTaskContext($context)); + } + + /** + * Provide debugging notification. These messages are only + * displayed if the log level is VERBOSITY_DEBUG. + * + * @param string$text + * @param null|array $context + */ + protected function printTaskDebug($text, $context = null) + { + $this->printTaskOutput(LogLevel::DEBUG, $text, $this->getTaskContext($context)); + } + + /** + * @param string $level + * One of the \Psr\Log\LogLevel constant + * @param string $text + * @param null|array $context + */ + protected function printTaskOutput($level, $text, $context) + { + if (!$this->verbosityMeetsThreshold()) { + return; + } + $logger = $this->logger(); + if (!$logger) { + return; + } + // Hide the progress indicator, if it is visible. + $inProgress = $this->hideTaskProgress(); + $logger->log($level, $text, $this->getTaskContext($context)); + // After we have printed our log message, redraw the progress indicator. + $this->showTaskProgress($inProgress); + } + + /** + * @return bool + */ + protected function hideTaskProgress() + { + $inProgress = false; + if ($this instanceof ProgressIndicatorAwareInterface) { + $inProgress = $this->inProgress(); + } + + // If a progress indicator is running on this task, then we mush + // hide it before we print anything, or its display will be overwritten. + if ($inProgress) { + $inProgress = $this->hideProgressIndicator(); + } + return $inProgress; + } + + /** + * @param $inProgress + */ + protected function showTaskProgress($inProgress) + { + if ($inProgress) { + $this->restoreProgressIndicator($inProgress); + } + } + + /** + * Format a quantity of bytes. + * + * @param int $size + * @param int $precision + * + * @return string + */ + protected function formatBytes($size, $precision = 2) + { + if ($size === 0) { + return 0; + } + $base = log($size, 1024); + $suffixes = array('', 'k', 'M', 'G', 'T'); + return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + } + + /** + * Get the formatted task name for use in task output. + * This is placed in the task context under 'name', and + * used as the log label by Robo\Common\RoboLogStyle, + * which is inserted at the head of log messages by + * Robo\Common\CustomLogStyle::formatMessage(). + * + * @param null|object $task + * + * @return string + */ + protected function getPrintedTaskName($task = null) + { + if (!$task) { + $task = $this; + } + return TaskInfo::formatTaskName($task); + } + + /** + * @param null|array $context + * + * @return array with context information + */ + protected function getTaskContext($context = null) + { + if (!$context) { + $context = []; + } + if (!is_array($context)) { + $context = ['task' => $context]; + } + if (!array_key_exists('task', $context)) { + $context['task'] = $this; + } + + return $context + TaskInfo::getTaskContext($context['task']); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TimeKeeper.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TimeKeeper.php new file mode 100644 index 00000000..1cd3e334 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/TimeKeeper.php @@ -0,0 +1,69 @@ +startedAt) { + return; + } + // Get time in seconds as a float, accurate to the microsecond. + $this->startedAt = microtime(true); + } + + public function stop() + { + $this->finishedAt = microtime(true); + } + + /** + * @return float|null + */ + public function elapsed() + { + $finished = $this->finishedAt ? $this->finishedAt : microtime(true); + if ($finished - $this->startedAt <= 0) { + return null; + } + return $finished - $this->startedAt; + } + + /** + * Format a duration into a human-readable time + * + * @param float $duration Duration in seconds, with fractional component + * + * @return string + */ + public static function formatDuration($duration) + { + if ($duration >= self::DAY * 2) { + return gmdate('z \d\a\y\s H:i:s', $duration); + } + if ($duration > self::DAY) { + return gmdate('\1 \d\a\y H:i:s', $duration); + } + if ($duration > self::HOUR) { + return gmdate("H:i:s", $duration); + } + if ($duration > self::MINUTE) { + return gmdate("i:s", $duration); + } + return round($duration, 3).'s'; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/Timer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/Timer.php new file mode 100644 index 00000000..955eb5bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/Timer.php @@ -0,0 +1,37 @@ +timer)) { + $this->timer = new TimeKeeper(); + } + $this->timer->start(); + } + + protected function stopTimer() + { + if (!isset($this->timer)) { + return; + } + $this->timer->stop(); + } + + /** + * @return float|null + */ + protected function getExecutionTime() + { + if (!isset($this->timer)) { + return null; + } + return $this->timer->elapsed(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/VerbosityThresholdTrait.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/VerbosityThresholdTrait.php new file mode 100644 index 00000000..2fc51c22 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Common/VerbosityThresholdTrait.php @@ -0,0 +1,79 @@ +verbosityThreshold = $verbosityThreshold; + return $this; + } + + public function verbosityThreshold() + { + return $this->verbosityThreshold; + } + + public function setOutputAdapter(OutputAdapterInterface $outputAdapter) + { + $this->outputAdapter = $outputAdapter; + } + + /** + * @return OutputAdapterInterface + */ + public function outputAdapter() + { + return $this->outputAdapter; + } + + public function hasOutputAdapter() + { + return isset($this->outputAdapter); + } + + public function verbosityMeetsThreshold() + { + if ($this->hasOutputAdapter()) { + return $this->outputAdapter()->verbosityMeetsThreshold($this->verbosityThreshold()); + } + return true; + } + + /** + * Print a message if the selected verbosity level is over this task's + * verbosity threshhold. + */ + public function writeMessage($message) + { + if (!$this->verbosityMeetsThreshold()) { + return; + } + $this->outputAdapter()->writeMessage($message); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config.php new file mode 100644 index 00000000..9e9370d8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config.php @@ -0,0 +1,9 @@ +defaults = $this->getGlobalOptionDefaultValues(); + } + + /** + * Return an associative array containing all of the global configuration + * options and their default values. + * + * @return array + */ + public function getGlobalOptionDefaultValues() + { + $globalOptions = + [ + self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL => self::DEFAULT_PROGRESS_DELAY, + self::SIMULATE => false, + ]; + return $this->trimPrefixFromGlobalOptions($globalOptions); + } + + /** + * Remove the 'options.' prefix from the global options list. + */ + protected function trimPrefixFromGlobalOptions($globalOptions) + { + $result = []; + foreach ($globalOptions as $option => $value) { + $option = str_replace('options.', '', $option); + $result[$option] = $value; + } + return $result; + } + + /** + * @deprecated Use $config->get(Config::SIMULATE) + * + * @return bool + */ + public function isSimulated() + { + return $this->get(self::SIMULATE); + } + + /** + * @deprecated Use $config->set(Config::SIMULATE, true) + * + * @param bool $simulated + * + * @return $this + */ + public function setSimulated($simulated = true) + { + return $this->set(self::SIMULATE, $simulated); + } + + /** + * @deprecated Use $config->get(Config::INTERACTIVE) + * + * @return bool + */ + public function isInteractive() + { + return $this->get(self::INTERACTIVE); + } + + /** + * @deprecated Use $config->set(Config::INTERACTIVE, true) + * + * @param bool $interactive + * + * @return $this + */ + public function setInteractive($interactive = true) + { + return $this->set(self::INTERACTIVE, $interactive); + } + + /** + * @deprecated Use $config->get(Config::DECORATED) + * + * @return bool + */ + public function isDecorated() + { + return $this->get(self::DECORATED); + } + + /** + * @deprecated Use $config->set(Config::DECORATED, true) + * + * @param bool $decorated + * + * @return $this + */ + public function setDecorated($decorated = true) + { + return $this->set(self::DECORATED, $decorated); + } + + /** + * @deprecated Use $config->set(Config::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval) + * + * @param int $interval + * + * @return $this + */ + public function setProgressBarAutoDisplayInterval($interval) + { + return $this->set(self::PROGRESS_BAR_AUTO_DISPLAY_INTERVAL, $interval); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config/GlobalOptionDefaultValuesInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config/GlobalOptionDefaultValuesInterface.php new file mode 100644 index 00000000..f7639455 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Config/GlobalOptionDefaultValuesInterface.php @@ -0,0 +1,17 @@ +inflect($this) + * ->initializer() + * ->... + * + * Instead of: + * + * (new SomeTask($args)) + * ->setLogger($this->logger) + * ->initializer() + * ->... + * + * The reason `inflect` is better than the more explicit alternative is + * that subclasses of BaseTask that implement a new FooAwareInterface + * can override injectDependencies() as explained below, and add more + * dependencies that can be injected as needed. + * + * @param \Robo\Contract\InflectionInterface $parent + */ + public function inflect(InflectionInterface $parent); + + /** + * Take all dependencies availble to this task and inject any that are + * needed into the provided task. The general pattern is that, for every + * FooAwareInterface that this class implements, it should test to see + * if the child also implements the same interface, and if so, should call + * $child->setFoo($this->foo). + * + * The benefits of this are pretty large. Any time an object that implements + * InflectionInterface is created, just call `$child->inflect($this)`, and + * any available optional dependencies will be hooked up via setter injection. + * + * The required dependencies of an object should be provided via constructor + * injection, not inflection. + * + * @param InflectionInterface $child An object created by this class that + * should have its dependencies injected. + * + * @see https://mwop.net/blog/2016-04-26-on-locators.html + */ + public function injectDependencies(InflectionInterface $child); +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Contract/OutputAdapterInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Contract/OutputAdapterInterface.php new file mode 100644 index 00000000..948d384c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Contract/OutputAdapterInterface.php @@ -0,0 +1,11 @@ +prefix = 'options'; + } + + /** + * Add a reference to the Symfony Console application object. + */ + public function setApplication($application) + { + $this->application = $application; + return $this; + } + + /** + * Stipulate the prefix to use for option injection. + * @param string $prefix + */ + public function setGlobalOptionsPrefix($prefix) + { + $this->prefix = $prefix; + return $this; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return [ConsoleEvents::COMMAND => 'handleCommandEvent']; + } + + /** + * Run all of our individual operations when a command event is received. + */ + public function handleCommandEvent(ConsoleCommandEvent $event) + { + $this->setGlobalOptions($event); + $this->setConfigurationValues($event); + } + + /** + * Before a Console command runs, examine the global + * commandline options from the event Input, and set + * configuration values as appropriate. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function setGlobalOptions(ConsoleCommandEvent $event) + { + $config = $this->getConfig(); + $input = $event->getInput(); + + $globalOptions = $config->get($this->prefix, []); + if ($config instanceof \Consolidation\Config\GlobalOptionDefaultValuesInterface) { + $globalOptions += $config->getGlobalOptionDefaultValues(); + } + + $globalOptions += $this->applicationOptionDefaultValues(); + + // Set any config value that has a defined global option (e.g. --simulate) + foreach ($globalOptions as $option => $default) { + $value = $input->hasOption($option) ? $input->getOption($option) : null; + // Unfortunately, the `?:` operator does not differentate between `0` and `null` + if (!isset($value)) { + $value = $default; + } + $config->set($this->prefix . '.' . $option, $value); + } + } + + /** + * Examine the commandline --define / -D options, and apply the provided + * values to the active configuration. + * + * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event + */ + public function setConfigurationValues(ConsoleCommandEvent $event) + { + $config = $this->getConfig(); + $input = $event->getInput(); + + // Also set any `-D config.key=value` options from the commandline. + if ($input->hasOption('define')) { + $configDefinitions = $input->getOption('define'); + foreach ($configDefinitions as $value) { + list($key, $value) = $this->splitConfigKeyValue($value); + $config->set($key, $value); + } + } + } + + /** + * Split up the key=value config setting into its component parts. If + * the input string contains no '=' character, then the value will be 'true'. + * + * @param string $value + * @return array + */ + protected function splitConfigKeyValue($value) + { + $parts = explode('=', $value, 2); + $parts[] = true; + return $parts; + } + + /** + * Get default option values from the Symfony Console application, if + * it is available. + */ + protected function applicationOptionDefaultValues() + { + if (!$this->application) { + return []; + } + + $result = []; + foreach ($this->application->getDefinition()->getOptions() as $key => $option) { + $result[$key] = $option->acceptValue() ? $option->getDefault() : null; + } + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/LoadAllTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/LoadAllTasks.php new file mode 100644 index 00000000..3183d5b6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/LoadAllTasks.php @@ -0,0 +1,39 @@ +getTask(); + if ($task instanceof VerbosityThresholdInterface && !$task->verbosityMeetsThreshold()) { + return; + } + if (!$result->wasSuccessful()) { + return $this->printError($result); + } else { + return $this->printSuccess($result); + } + } + + /** + * Log that we are about to abort due to an error being encountered + * in 'stop on fail' mode. + * + * @param \Robo\Result $result + */ + public function printStopOnFail($result) + { + $this->printMessage(LogLevel::NOTICE, 'Stopping on fail. Exiting....'); + $this->printMessage(LogLevel::ERROR, 'Exit Code: {code}', ['code' => $result->getExitCode()]); + } + + /** + * Log the result of a Robo task that returned an error. + * + * @param \Robo\Result $result + * + * @return bool + */ + protected function printError(Result $result) + { + $task = $result->getTask(); + $context = $result->getContext() + ['timer-label' => 'Time', '_style' => []]; + $context['_style']['message'] = ''; + + $printOutput = true; + if ($task instanceof PrintedInterface) { + $printOutput = !$task->getPrinted(); + } + if ($printOutput) { + $this->printMessage(LogLevel::ERROR, "{message}", $context); + } + $this->printMessage(LogLevel::ERROR, 'Exit code {code}', $context); + return true; + } + + /** + * Log the result of a Robo task that was successful. + * + * @param \Robo\Result $result + * + * @return bool + */ + protected function printSuccess(Result $result) + { + $task = $result->getTask(); + $context = $result->getContext() + ['timer-label' => 'in']; + $time = $result->getExecutionTime(); + if ($time) { + $this->printMessage(ConsoleLogLevel::SUCCESS, 'Done', $context); + } + return false; + } + + /** + * @param string $level + * @param string $message + * @param array $context + */ + protected function printMessage($level, $message, $context = []) + { + $inProgress = $this->hideProgressIndicator(); + $this->logger->log($level, $message, $context); + if ($inProgress) { + $this->restoreProgressIndicator($inProgress); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogLevel.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogLevel.php new file mode 100644 index 00000000..d7d5eb0a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogLevel.php @@ -0,0 +1,11 @@ +labelStyles += [ + RoboLogLevel::SIMULATED_ACTION => self::TASK_STYLE_SIMULATED, + ]; + $this->messageStyles += [ + RoboLogLevel::SIMULATED_ACTION => '', + ]; + } + + /** + * Log style customization for Robo: replace the log level with + * the task name. + * + * @param string $level + * @param string $message + * @param array $context + * + * @return string + */ + protected function formatMessageByLevel($level, $message, $context) + { + $label = $level; + if (array_key_exists('name', $context)) { + $label = $context['name']; + } + return $this->formatMessage($label, $message, $context, $this->labelStyles[$level], $this->messageStyles[$level]); + } + + /** + * Log style customization for Robo: add the time indicator to the + * end of the log message if it exists in the context. + * + * @param string $label + * @param string $message + * @param array $context + * @param string $taskNameStyle + * @param string $messageStyle + * + * @return string + */ + protected function formatMessage($label, $message, $context, $taskNameStyle, $messageStyle = '') + { + $message = parent::formatMessage($label, $message, $context, $taskNameStyle, $messageStyle); + + if (array_key_exists('time', $context) && !empty($context['time']) && array_key_exists('timer-label', $context)) { + $duration = TimeKeeper::formatDuration($context['time']); + $message .= ' ' . $context['timer-label'] . ' ' . $this->wrapFormatString($duration, 'fg=yellow'); + } + + return $message; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogger.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogger.php new file mode 100644 index 00000000..75cf23f7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Log/RoboLogger.php @@ -0,0 +1,29 @@ + OutputInterface::VERBOSITY_NORMAL, // Default is "verbose" + LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, // Default is "verbose" + LogLevel::INFO => OutputInterface::VERBOSITY_VERBOSE, // Default is "very verbose" + ]; + parent::__construct($output, $roboVerbosityOverrides); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Result.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Result.php new file mode 100644 index 00000000..7d779352 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Result.php @@ -0,0 +1,258 @@ +task = $task; + $this->printResult(); + + if (self::$stopOnFail) { + $this->stopOnFail(); + } + } + + /** + * Tasks should always return a Result. However, they are also + * allowed to return NULL or an array to indicate success. + */ + public static function ensureResult($task, $result) + { + if ($result instanceof Result) { + return $result; + } + if (!isset($result)) { + return static::success($task); + } + if ($result instanceof Data) { + return static::success($task, $result->getMessage(), $result->getData()); + } + if ($result instanceof ResultData) { + return new Result($task, $result->getExitCode(), $result->getMessage(), $result->getData()); + } + if (is_array($result)) { + return static::success($task, '', $result); + } + throw new \Exception(sprintf('Task %s returned a %s instead of a \Robo\Result.', get_class($task), get_class($result))); + } + + protected function printResult() + { + // For historic reasons, the Result constructor is responsible + // for printing task results. + // TODO: Make IO the responsibility of some other class. Maintaining + // existing behavior for backwards compatibility. This is undesirable + // in the long run, though, as it can result in unwanted repeated input + // in task collections et. al. + $resultPrinter = Robo::resultPrinter(); + if ($resultPrinter) { + if ($resultPrinter->printResult($this)) { + $this->alreadyPrinted(); + } + } + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $extension + * @param string $service + * + * @return \Robo\Result + */ + public static function errorMissingExtension(TaskInterface $task, $extension, $service) + { + $messageTpl = 'PHP extension required for %s. Please enable %s'; + $message = sprintf($messageTpl, $service, $extension); + + return self::error($task, $message); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $class + * @param string $package + * + * @return \Robo\Result + */ + public static function errorMissingPackage(TaskInterface $task, $class, $package) + { + $messageTpl = 'Class %s not found. Please install %s Composer package'; + $message = sprintf($messageTpl, $class, $package); + + return self::error($task, $message); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $message + * @param array $data + * + * @return \Robo\Result + */ + public static function error(TaskInterface $task, $message, $data = []) + { + return new self($task, self::EXITCODE_ERROR, $message, $data); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param \Exception $e + * @param array $data + * + * @return \Robo\Result + */ + public static function fromException(TaskInterface $task, \Exception $e, $data = []) + { + $exitCode = $e->getCode(); + if (!$exitCode) { + $exitCode = self::EXITCODE_ERROR; + } + return new self($task, $exitCode, $e->getMessage(), $data); + } + + /** + * @param \Robo\Contract\TaskInterface $task + * @param string $message + * @param array $data + * + * @return \Robo\Result + */ + public static function success(TaskInterface $task, $message = '', $data = []) + { + return new self($task, self::EXITCODE_OK, $message, $data); + } + + /** + * Return a context useful for logging messages. + * + * @return array + */ + public function getContext() + { + $task = $this->getTask(); + + return TaskInfo::getTaskContext($task) + [ + 'code' => $this->getExitCode(), + 'data' => $this->getArrayCopy(), + 'time' => $this->getExecutionTime(), + 'message' => $this->getMessage(), + ]; + } + + /** + * Add the results from the most recent task to the accumulated + * results from all tasks that have run so far, merging data + * as necessary. + * + * @param int|string $key + * @param \Robo\Result $taskResult + */ + public function accumulate($key, Result $taskResult) + { + // If the task is unnamed, then all of its data elements + // just get merged in at the top-level of the final Result object. + if (static::isUnnamed($key)) { + $this->merge($taskResult); + } elseif (isset($this[$key])) { + // There can only be one task with a given name; however, if + // there are tasks added 'before' or 'after' the named task, + // then the results from these will be stored under the same + // name unless they are given a name of their own when added. + $current = $this[$key]; + $this[$key] = $taskResult->merge($current); + } else { + $this[$key] = $taskResult; + } + } + + /** + * We assume that named values (e.g. for associative array keys) + * are non-numeric; numeric keys are presumed to simply be the + * index of an array, and therefore insignificant. + * + * @param int|string $key + * + * @return bool + */ + public static function isUnnamed($key) + { + return is_numeric($key); + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function getTask() + { + return $this->task; + } + + /** + * @return \Robo\Contract\TaskInterface + */ + public function cloneTask() + { + $reflect = new \ReflectionClass(get_class($this->task)); + return $reflect->newInstanceArgs(func_get_args()); + } + + /** + * @return bool + * + * @deprecated since 1.0. + * + * @see wasSuccessful() + */ + public function __invoke() + { + trigger_error(__METHOD__ . ' is deprecated: use wasSuccessful() instead.', E_USER_DEPRECATED); + return $this->wasSuccessful(); + } + + /** + * @return $this + */ + public function stopOnFail() + { + if (!$this->wasSuccessful()) { + $resultPrinter = Robo::resultPrinter(); + if ($resultPrinter) { + $resultPrinter->printStopOnFail($this); + } + $this->exitEarly($this->getExitCode()); + } + return $this; + } + + /** + * @param int $status + * + * @throws \Robo\Exception\TaskExitException + */ + private function exitEarly($status) + { + throw new TaskExitException($this->getTask(), $this->getMessage(), $status); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/ResultData.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/ResultData.php new file mode 100644 index 00000000..90baf6e9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/ResultData.php @@ -0,0 +1,110 @@ +exitCode = $exitCode; + parent::__construct($message, $data); + } + + /** + * @param string $message + * @param array $data + * + * @return \Robo\ResultData + */ + public static function message($message, $data = []) + { + return new self(self::EXITCODE_OK, $message, $data); + } + + /** + * @param string $message + * @param array $data + * + * @return \Robo\ResultData + */ + public static function cancelled($message = '', $data = []) + { + return new ResultData(self::EXITCODE_USER_CANCEL, $message, $data); + } + + /** + * @return int + */ + public function getExitCode() + { + return $this->exitCode; + } + + /** + * @return null|string + */ + public function getOutputData() + { + if (!empty($this->message) && !isset($this['already-printed']) && isset($this['provide-outputdata'])) { + return $this->message; + } + } + + /** + * Indicate that the message in this data has already been displayed. + */ + public function alreadyPrinted() + { + $this['already-printed'] = true; + } + + /** + * Opt-in to providing the result message as the output data + */ + public function provideOutputdata() + { + $this['provide-outputdata'] = true; + } + + /** + * @return bool + */ + public function wasSuccessful() + { + return $this->exitCode === self::EXITCODE_OK; + } + + /** + * @return bool + */ + public function wasCancelled() + { + return $this->exitCode == self::EXITCODE_USER_CANCEL; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Robo.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Robo.php new file mode 100644 index 00000000..0f427707 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Robo.php @@ -0,0 +1,394 @@ +setSelfUpdateRepository($repository); + $statusCode = $runner->execute($argv, $appName, $appVersion, $output); + return $statusCode; + } + + /** + * Sets a new global container. + * + * @param ContainerInterface $container + * A new container instance to replace the current. + */ + public static function setContainer(ContainerInterface $container) + { + static::$container = $container; + } + + /** + * Unsets the global container. + */ + public static function unsetContainer() + { + static::$container = null; + } + + /** + * Returns the currently active global container. + * + * @return \League\Container\ContainerInterface + * + * @throws \RuntimeException + */ + public static function getContainer() + { + if (static::$container === null) { + throw new \RuntimeException('container is not initialized yet. \Robo\Robo::setContainer() must be called with a real container.'); + } + return static::$container; + } + + /** + * Returns TRUE if the container has been initialized, FALSE otherwise. + * + * @return bool + */ + public static function hasContainer() + { + return static::$container !== null; + } + + /** + * Create a config object and load it from the provided paths. + */ + public static function createConfiguration($paths) + { + $config = new \Robo\Config\Config(); + static::loadConfiguration($paths, $config); + return $config; + } + + /** + * Use a simple config loader to load configuration values from specified paths + */ + public static function loadConfiguration($paths, $config = null) + { + if ($config == null) { + $config = static::config(); + } + $loader = new YamlConfigLoader(); + $processor = new ConfigProcessor(); + $processor->add($config->export()); + foreach ($paths as $path) { + $processor->extend($loader->load($path)); + } + $config->import($processor->export()); + } + + /** + * Create a container and initiailze it. If you wish to *change* + * anything defined in the container, then you should call + * \Robo::configureContainer() instead of this function. + * + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * @param null|\Robo\Application $app + * @param null|ConfigInterface $config + * + * @return \League\Container\Container|\League\Container\ContainerInterface + */ + public static function createDefaultContainer($input = null, $output = null, $app = null, $config = null) + { + // Do not allow this function to be called more than once. + if (static::hasContainer()) { + return static::getContainer(); + } + + if (!$app) { + $app = static::createDefaultApplication(); + } + + if (!$config) { + $config = new \Robo\Config\Config(); + } + + // Set up our dependency injection container. + $container = new Container(); + static::configureContainer($container, $app, $config, $input, $output); + + // Set the application dispatcher + $app->setDispatcher($container->get('eventDispatcher')); + + return $container; + } + + /** + * Initialize a container with all of the default Robo services. + * IMPORTANT: after calling this method, clients MUST call: + * + * $dispatcher = $container->get('eventDispatcher'); + * $app->setDispatcher($dispatcher); + * + * Any modification to the container should be done prior to fetching + * objects from it. + * + * It is recommended to use \Robo::createDefaultContainer() + * instead, which does all required setup for the caller, but has + * the limitation that the container it creates can only be + * extended, not modified. + * + * @param \League\Container\ContainerInterface $container + * @param \Symfony\Component\Console\Application $app + * @param ConfigInterface $config + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + */ + public static function configureContainer(ContainerInterface $container, SymfonyApplication $app, ConfigInterface $config, $input = null, $output = null) + { + // Self-referential container refernce for the inflector + $container->add('container', $container); + static::setContainer($container); + + // Create default input and output objects if they were not provided + if (!$input) { + $input = new StringInput(''); + } + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + $config->set(Config::DECORATED, $output->isDecorated()); + $config->set(Config::INTERACTIVE, $input->isInteractive()); + + $container->share('application', $app); + $container->share('config', $config); + $container->share('input', $input); + $container->share('output', $output); + $container->share('outputAdapter', \Robo\Common\OutputAdapter::class); + + // Register logging and related services. + $container->share('logStyler', \Robo\Log\RoboLogStyle::class); + $container->share('logger', \Robo\Log\RoboLogger::class) + ->withArgument('output') + ->withMethodCall('setLogOutputStyler', ['logStyler']); + $container->add('progressBar', \Symfony\Component\Console\Helper\ProgressBar::class) + ->withArgument('output'); + $container->share('progressIndicator', \Robo\Common\ProgressIndicator::class) + ->withArgument('progressBar') + ->withArgument('output'); + $container->share('resultPrinter', \Robo\Log\ResultPrinter::class); + $container->add('simulator', \Robo\Task\Simulator::class); + $container->share('globalOptionsEventListener', \Robo\GlobalOptionsEventListener::class) + ->withMethodCall('setApplication', ['application']); + $container->share('injectConfigEventListener', \Consolidation\Config\Inject\ConfigForCommand::class) + ->withArgument('config') + ->withMethodCall('setApplication', ['application']); + $container->share('collectionProcessHook', \Robo\Collection\CollectionProcessHook::class); + $container->share('alterOptionsCommandEvent', \Consolidation\AnnotatedCommand\Options\AlterOptionsCommandEvent::class) + ->withArgument('application'); + $container->share('hookManager', \Consolidation\AnnotatedCommand\Hooks\HookManager::class) + ->withMethodCall('addCommandEvent', ['alterOptionsCommandEvent']) + ->withMethodCall('addCommandEvent', ['injectConfigEventListener']) + ->withMethodCall('addCommandEvent', ['globalOptionsEventListener']) + ->withMethodCall('addResultProcessor', ['collectionProcessHook', '*']); + $container->share('eventDispatcher', \Symfony\Component\EventDispatcher\EventDispatcher::class) + ->withMethodCall('addSubscriber', ['hookManager']); + $container->share('formatterManager', \Consolidation\OutputFormatters\FormatterManager::class) + ->withMethodCall('addDefaultFormatters', []) + ->withMethodCall('addDefaultSimplifiers', []); + $container->share('prepareTerminalWidthOption', \Consolidation\AnnotatedCommand\Options\PrepareTerminalWidthOption::class) + ->withMethodCall('setApplication', ['application']); + $container->share('commandProcessor', \Consolidation\AnnotatedCommand\CommandProcessor::class) + ->withArgument('hookManager') + ->withMethodCall('setFormatterManager', ['formatterManager']) + ->withMethodCall('addPrepareFormatter', ['prepareTerminalWidthOption']) + ->withMethodCall( + 'setDisplayErrorFunction', + [ + function ($output, $message) use ($container) { + $logger = $container->get('logger'); + $logger->error($message); + } + ] + ); + $container->share('commandFactory', \Consolidation\AnnotatedCommand\AnnotatedCommandFactory::class) + ->withMethodCall('setCommandProcessor', ['commandProcessor']); + + // Deprecated: favor using collection builders to direct use of collections. + $container->add('collection', \Robo\Collection\Collection::class); + // Deprecated: use CollectionBuilder::create() instead -- or, better + // yet, BuilderAwareInterface::collectionBuilder() if available. + $container->add('collectionBuilder', \Robo\Collection\CollectionBuilder::class); + + static::addInflectors($container); + + // Make sure the application is appropriately initialized. + $app->setAutoExit(false); + } + + /** + * @param null|string $appName + * @param null|string $appVersion + * + * @return \Robo\Application + */ + public static function createDefaultApplication($appName = null, $appVersion = null) + { + $appName = $appName ?: self::APPLICATION_NAME; + $appVersion = $appVersion ?: self::VERSION; + + $app = new \Robo\Application($appName, $appVersion); + $app->setAutoExit(false); + return $app; + } + + /** + * Add the Robo League\Container inflectors to the container + * + * @param \League\Container\ContainerInterface $container + */ + public static function addInflectors($container) + { + // Register our various inflectors. + $container->inflector(\Robo\Contract\ConfigAwareInterface::class) + ->invokeMethod('setConfig', ['config']); + $container->inflector(\Psr\Log\LoggerAwareInterface::class) + ->invokeMethod('setLogger', ['logger']); + $container->inflector(\League\Container\ContainerAwareInterface::class) + ->invokeMethod('setContainer', ['container']); + $container->inflector(\Symfony\Component\Console\Input\InputAwareInterface::class) + ->invokeMethod('setInput', ['input']); + $container->inflector(\Robo\Contract\OutputAwareInterface::class) + ->invokeMethod('setOutput', ['output']); + $container->inflector(\Robo\Contract\ProgressIndicatorAwareInterface::class) + ->invokeMethod('setProgressIndicator', ['progressIndicator']); + $container->inflector(\Consolidation\AnnotatedCommand\Events\CustomEventAwareInterface::class) + ->invokeMethod('setHookManager', ['hookManager']); + $container->inflector(\Robo\Contract\VerbosityThresholdInterface::class) + ->invokeMethod('setOutputAdapter', ['outputAdapter']); + } + + /** + * Retrieves a service from the container. + * + * Use this method if the desired service is not one of those with a dedicated + * accessor method below. If it is listed below, those methods are preferred + * as they can return useful type hints. + * + * @param string $id + * The ID of the service to retrieve. + * + * @return mixed + * The specified service. + */ + public static function service($id) + { + return static::getContainer()->get($id); + } + + /** + * Indicates if a service is defined in the container. + * + * @param string $id + * The ID of the service to check. + * + * @return bool + * TRUE if the specified service exists, FALSE otherwise. + */ + public static function hasService($id) + { + // Check hasContainer() first in order to always return a Boolean. + return static::hasContainer() && static::getContainer()->has($id); + } + + /** + * Return the result printer object. + * + * @return \Robo\Log\ResultPrinter + */ + public static function resultPrinter() + { + return static::service('resultPrinter'); + } + + /** + * @return ConfigInterface + */ + public static function config() + { + return static::service('config'); + } + + /** + * @return \Consolidation\Log\Logger + */ + public static function logger() + { + return static::service('logger'); + } + + /** + * @return \Robo\Application + */ + public static function application() + { + return static::service('application'); + } + + /** + * Return the output object. + * + * @return \Symfony\Component\Console\Output\OutputInterface + */ + public static function output() + { + return static::service('output'); + } + + /** + * Return the input object. + * + * @return \Symfony\Component\Console\Input\InputInterface + */ + public static function input() + { + return static::service('input'); + } + + public static function process(Process $process) + { + return ProcessExecutor::create(static::getContainer(), $process); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Runner.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Runner.php new file mode 100644 index 00000000..800ad281 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Runner.php @@ -0,0 +1,465 @@ +roboClass = $roboClass ? $roboClass : self::ROBOCLASS ; + $this->roboFile = $roboFile ? $roboFile : self::ROBOFILE; + $this->dir = getcwd(); + } + + protected function errorCondtion($msg, $errorType) + { + $this->errorConditions[$msg] = $errorType; + } + + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return bool + */ + protected function loadRoboFile($output) + { + // If we have not been provided an output object, make a temporary one. + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + + // If $this->roboClass is a single class that has not already + // been loaded, then we will try to obtain it from $this->roboFile. + // If $this->roboClass is an array, we presume all classes requested + // are available via the autoloader. + if (is_array($this->roboClass) || class_exists($this->roboClass)) { + return true; + } + if (!file_exists($this->dir)) { + $this->errorCondtion("Path `{$this->dir}` is invalid; please provide a valid absolute path to the Robofile to load.", 'red'); + return false; + } + + $realDir = realpath($this->dir); + + $roboFilePath = $realDir . DIRECTORY_SEPARATOR . $this->roboFile; + if (!file_exists($roboFilePath)) { + $requestedRoboFilePath = $this->dir . DIRECTORY_SEPARATOR . $this->roboFile; + $this->errorCondtion("Requested RoboFile `$requestedRoboFilePath` is invalid, please provide valid absolute path to load Robofile.", 'red'); + return false; + } + require_once $roboFilePath; + + if (!class_exists($this->roboClass)) { + $this->errorCondtion("Class {$this->roboClass} was not loaded.", 'red'); + return false; + } + return true; + } + + /** + * @param array $argv + * @param null|string $appName + * @param null|string $appVersion + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * + * @return int + */ + public function execute($argv, $appName = null, $appVersion = null, $output = null) + { + $argv = $this->shebang($argv); + $argv = $this->processRoboOptions($argv); + $app = null; + if ($appName && $appVersion) { + $app = Robo::createDefaultApplication($appName, $appVersion); + } + $commandFiles = $this->getRoboFileCommands($output); + return $this->run($argv, $output, $app, $commandFiles); + } + + /** + * @param null|\Symfony\Component\Console\Input\InputInterface $input + * @param null|\Symfony\Component\Console\Output\OutputInterface $output + * @param null|\Robo\Application $app + * @param array[] $commandFiles + * + * @return int + */ + public function run($input = null, $output = null, $app = null, $commandFiles = []) + { + // Create default input and output objects if they were not provided + if (!$input) { + $input = new StringInput(''); + } + if (is_array($input)) { + $input = new ArgvInput($input); + } + if (!$output) { + $output = new \Symfony\Component\Console\Output\ConsoleOutput(); + } + $this->setInput($input); + $this->setOutput($output); + + // If we were not provided a container, then create one + if (!$this->getContainer()) { + $userConfig = 'robo.yml'; + $roboAppConfig = dirname(__DIR__) . '/robo.yml'; + $config = Robo::createConfiguration([$userConfig, $roboAppConfig]); + $container = Robo::createDefaultContainer($input, $output, $app, $config); + $this->setContainer($container); + // Automatically register a shutdown function and + // an error handler when we provide the container. + $this->installRoboHandlers(); + } + + if (!$app) { + $app = Robo::application(); + } + if ($app instanceof \Robo\Application) { + $app->addSelfUpdateCommand($this->getSelfUpdateRepository()); + if (!isset($commandFiles)) { + $this->errorCondtion("Robo is not initialized here. Please run `robo init` to create a new RoboFile.", 'yellow'); + $app->addInitRoboFileCommand($this->roboFile, $this->roboClass); + $commandFiles = []; + } + } + $this->registerCommandClasses($app, $commandFiles); + + try { + $statusCode = $app->run($input, $output); + } catch (TaskExitException $e) { + $statusCode = $e->getCode() ?: 1; + } + + // If there were any error conditions in bootstrapping Robo, + // print them only if the requested command did not complete + // successfully. + if ($statusCode) { + foreach ($this->errorConditions as $msg => $color) { + $this->yell($msg, 40, $color); + } + } + return $statusCode; + } + + /** + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return null|string + */ + protected function getRoboFileCommands($output) + { + if (!$this->loadRoboFile($output)) { + return; + } + return $this->roboClass; + } + + /** + * @param \Robo\Application $app + * @param array $commandClasses + */ + public function registerCommandClasses($app, $commandClasses) + { + foreach ((array)$commandClasses as $commandClass) { + $this->registerCommandClass($app, $commandClass); + } + } + + /** + * @param \Robo\Application $app + * @param string|BuilderAwareInterface|ContainerAwareInterface $commandClass + * + * @return mixed|void + */ + public function registerCommandClass($app, $commandClass) + { + $container = Robo::getContainer(); + $roboCommandFileInstance = $this->instantiateCommandClass($commandClass); + if (!$roboCommandFileInstance) { + return; + } + + // Register commands for all of the public methods in the RoboFile. + $commandFactory = $container->get('commandFactory'); + $commandList = $commandFactory->createCommandsFromClass($roboCommandFileInstance); + foreach ($commandList as $command) { + $app->add($command); + } + return $roboCommandFileInstance; + } + + /** + * @param string|BuilderAwareInterface|ContainerAwareInterface $commandClass + * + * @return null|object + */ + protected function instantiateCommandClass($commandClass) + { + $container = Robo::getContainer(); + + // Register the RoboFile with the container and then immediately + // fetch it; this ensures that all of the inflectors will run. + // If the command class is already an instantiated object, then + // just use it exactly as it was provided to us. + if (is_string($commandClass)) { + if (!class_exists($commandClass)) { + return; + } + $reflectionClass = new \ReflectionClass($commandClass); + if ($reflectionClass->isAbstract()) { + return; + } + + $commandFileName = "{$commandClass}Commands"; + $container->share($commandFileName, $commandClass); + $commandClass = $container->get($commandFileName); + } + // If the command class is a Builder Aware Interface, then + // ensure that it has a builder. Every command class needs + // its own collection builder, as they have references to each other. + if ($commandClass instanceof BuilderAwareInterface) { + $builder = CollectionBuilder::create($container, $commandClass); + $commandClass->setBuilder($builder); + } + if ($commandClass instanceof ContainerAwareInterface) { + $commandClass->setContainer($container); + } + return $commandClass; + } + + public function installRoboHandlers() + { + register_shutdown_function(array($this, 'shutdown')); + set_error_handler(array($this, 'handleError')); + } + + /** + * Process a shebang script, if one was used to launch this Runner. + * + * @param array $args + * + * @return array $args with shebang script removed + */ + protected function shebang($args) + { + // Option 1: Shebang line names Robo, but includes no parameters. + // #!/bin/env robo + // The robo class may contain multiple commands; the user may + // select which one to run, or even get a list of commands or + // run 'help' on any of the available commands as usual. + if ((count($args) > 1) && $this->isShebangFile($args[1])) { + return array_merge([$args[0]], array_slice($args, 2)); + } + // Option 2: Shebang line stipulates which command to run. + // #!/bin/env robo mycommand + // The robo class must contain a public method named 'mycommand'. + // This command will be executed every time. Arguments and options + // may be provided on the commandline as usual. + if ((count($args) > 2) && $this->isShebangFile($args[2])) { + return array_merge([$args[0]], explode(' ', $args[1]), array_slice($args, 3)); + } + return $args; + } + + /** + * Determine if the specified argument is a path to a shebang script. + * If so, load it. + * + * @param string $filepath file to check + * + * @return bool Returns TRUE if shebang script was processed + */ + protected function isShebangFile($filepath) + { + if (!is_file($filepath)) { + return false; + } + $fp = fopen($filepath, "r"); + if ($fp === false) { + return false; + } + $line = fgets($fp); + $result = $this->isShebangLine($line); + if ($result) { + while ($line = fgets($fp)) { + $line = trim($line); + if ($line == 'roboClass = $matches[1]; + eval($script); + $result = true; + } + } + } + } + fclose($fp); + + return $result; + } + + /** + * Test to see if the provided line is a robo 'shebang' line. + * + * @param string $line + * + * @return bool + */ + protected function isShebangLine($line) + { + return ((substr($line, 0, 2) == '#!') && (strstr($line, 'robo') !== false)); + } + + /** + * Check for Robo-specific arguments such as --load-from, process them, + * and remove them from the array. We have to process --load-from before + * we set up Symfony Console. + * + * @param array $argv + * + * @return array + */ + protected function processRoboOptions($argv) + { + // loading from other directory + $pos = $this->arraySearchBeginsWith('--load-from', $argv) ?: array_search('-f', $argv); + if ($pos === false) { + return $argv; + } + + $passThru = array_search('--', $argv); + if (($passThru !== false) && ($passThru < $pos)) { + return $argv; + } + + if (substr($argv[$pos], 0, 12) == '--load-from=') { + $this->dir = substr($argv[$pos], 12); + } elseif (isset($argv[$pos +1])) { + $this->dir = $argv[$pos +1]; + unset($argv[$pos +1]); + } + unset($argv[$pos]); + // Make adjustments if '--load-from' points at a file. + if (is_file($this->dir) || (substr($this->dir, -4) == '.php')) { + $this->roboFile = basename($this->dir); + $this->dir = dirname($this->dir); + $className = basename($this->roboFile, '.php'); + if ($className != $this->roboFile) { + $this->roboClass = $className; + } + } + // Convert directory to a real path, but only if the + // path exists. We do not want to lose the original + // directory if the user supplied a bad value. + $realDir = realpath($this->dir); + if ($realDir) { + chdir($realDir); + $this->dir = $realDir; + } + + return $argv; + } + + /** + * @param string $needle + * @param string[] $haystack + * + * @return bool|int + */ + protected function arraySearchBeginsWith($needle, $haystack) + { + for ($i = 0; $i < count($haystack); ++$i) { + if (substr($haystack[$i], 0, strlen($needle)) == $needle) { + return $i; + } + } + return false; + } + + public function shutdown() + { + $error = error_get_last(); + if (!is_array($error)) { + return; + } + $this->writeln(sprintf("ERROR: %s \nin %s:%d\n", $error['message'], $error['file'], $error['line'])); + } + + /** + * This is just a proxy error handler that checks the current error_reporting level. + * In case error_reporting is disabled the error is marked as handled, otherwise + * the normal internal error handling resumes. + * + * @return bool + */ + public function handleError() + { + if (error_reporting() === 0) { + return true; + } + return false; + } + + /** + * @return string + */ + public function getSelfUpdateRepository() + { + return $this->selfUpdateRepository; + } + + /** + * @param string $selfUpdateRepository + */ + public function setSelfUpdateRepository($selfUpdateRepository) + { + $this->selfUpdateRepository = $selfUpdateRepository; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/SelfUpdateCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/SelfUpdateCommand.php new file mode 100644 index 00000000..d07ee71f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/SelfUpdateCommand.php @@ -0,0 +1,152 @@ + + */ +class SelfUpdateCommand extends Command +{ + const SELF_UPDATE_COMMAND_NAME = 'self:update'; + + protected $gitHubRepository; + + protected $currentVersion; + + protected $applicationName; + + public function __construct($applicationName = null, $currentVersion = null, $gitHubRepository = null) + { + parent::__construct(self::SELF_UPDATE_COMMAND_NAME); + + $this->applicationName = $applicationName; + $this->currentVersion = $currentVersion; + $this->gitHubRepository = $gitHubRepository; + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setAliases(array('update')) + ->setDescription('Updates the robo.phar to the latest version.') + ->setHelp( + <<self-update command checks github for newer +versions of robo and if found, installs the latest. +EOT + ); + } + + protected function getLatestReleaseFromGithub() + { + $opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => [ + 'User-Agent: ' . $this->applicationName . ' (' . $this->gitHubRepository . ')' . ' Self-Update (PHP)' + ] + ] + ]; + + $context = stream_context_create($opts); + + $releases = file_get_contents('https://api.github.com/repos/' . $this->gitHubRepository . '/releases', false, $context); + $releases = json_decode($releases); + + if (! isset($releases[0])) { + throw new \Exception('API error - no release found at GitHub repository ' . $this->gitHubRepository); + } + + $version = $releases[0]->tag_name; + $url = $releases[0]->assets[0]->browser_download_url; + + return [ $version, $url ]; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if (empty(\Phar::running())) { + throw new \Exception(self::SELF_UPDATE_COMMAND_NAME . ' only works when running the phar version of ' . $this->applicationName . '.'); + } + + $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0]; + $programName = basename($localFilename); + $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar') . '-temp.phar'; + + // check for permissions in local filesystem before start connection process + if (! is_writable($tempDirectory = dirname($tempFilename))) { + throw new \Exception( + $programName . ' update failed: the "' . $tempDirectory . + '" directory used to download the temp file could not be written' + ); + } + + if (! is_writable($localFilename)) { + throw new \Exception( + $programName . ' update failed: the "' . $localFilename . '" file could not be written (execute with sudo)' + ); + } + + list( $latest, $downloadUrl ) = $this->getLatestReleaseFromGithub(); + + + if ($this->currentVersion == $latest) { + $output->writeln('No update available'); + return; + } + + $fs = new sfFilesystem(); + + $output->writeln('Downloading ' . $this->applicationName . ' (' . $this->gitHubRepository . ') ' . $latest); + + $fs->copy($downloadUrl, $tempFilename); + + $output->writeln('Download finished'); + + try { + \error_reporting(E_ALL); // supress notices + + @chmod($tempFilename, 0777 & ~umask()); + // test the phar validity + $phar = new \Phar($tempFilename); + // free the variable to unlock the file + unset($phar); + @rename($tempFilename, $localFilename); + $output->writeln('Successfully updated ' . $programName . ''); + $this->_exit(); + } catch (\Exception $e) { + @unlink($tempFilename); + if (! $e instanceof \UnexpectedValueException && ! $e instanceof \PharException) { + throw $e; + } + $output->writeln('The download is corrupted (' . $e->getMessage() . ').'); + $output->writeln('Please re-run the self-update command to try again.'); + } + } + + /** + * Stop execution + * + * This is a workaround to prevent warning of dispatcher after replacing + * the phar file. + * + * @return void + */ + protected function _exit() + { + exit; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/Consumer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/Consumer.php new file mode 100644 index 00000000..ab9c0e27 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/Consumer.php @@ -0,0 +1,12 @@ +message = $message; + parent::__construct($data); + } + + /** + * @return array + */ + public function getData() + { + return $this->getArrayCopy(); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @param string message + */ + public function setMessage($message) + { + $this->message = $message; + } + + /** + * Merge another result into this result. Data already + * existing in this result takes precedence over the + * data in the Result being merged. + * + * @param \Robo\ResultData $result + * + * @return $this + */ + public function merge(Data $result) + { + $mergedData = $this->getArrayCopy() + $result->getArrayCopy(); + $this->exchangeArray($mergedData); + return $this; + } + + /** + * Update the current data with the data provided in the parameter. + * Provided data takes precedence. + * + * @param \ArrayObject $update + * + * @return $this + */ + public function update(\ArrayObject $update) + { + $iterator = $update->getIterator(); + + while ($iterator->valid()) { + $this[$iterator->key()] = $iterator->current(); + $iterator->next(); + } + + return $this; + } + + /** + * Merge another result into this result. Data already + * existing in this result takes precedence over the + * data in the Result being merged. + * + * $data['message'] is handled specially, and is appended + * to $this->message if set. + * + * @param array $data + * + * @return array + */ + public function mergeData(array $data) + { + $mergedData = $this->getArrayCopy() + $data; + $this->exchangeArray($mergedData); + return $mergedData; + } + + /** + * @return bool + */ + public function hasExecutionTime() + { + return isset($this['time']); + } + + /** + * @return null|float + */ + public function getExecutionTime() + { + if (!$this->hasExecutionTime()) { + return null; + } + return $this['time']; + } + + /** + * Accumulate execution time + */ + public function accumulateExecutionTime($duration) + { + // Convert data arrays to scalar + if (is_array($duration)) { + $duration = isset($duration['time']) ? $duration['time'] : 0; + } + $this['time'] = $this->getExecutionTime() + $duration; + return $this->getExecutionTime(); + } + + /** + * Accumulate the message. + */ + public function accumulateMessage($message) + { + if (!empty($this->message)) { + $this->message .= "\n"; + } + $this->message .= $message; + return $this->getMessage(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/StateAwareInterface.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/StateAwareInterface.php new file mode 100644 index 00000000..f86bccb8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/State/StateAwareInterface.php @@ -0,0 +1,30 @@ +state; + } + + /** + * {@inheritdoc} + */ + public function setState(Data $state) + { + $this->state = $state; + } + + /** + * {@inheritdoc} + */ + public function setStateValue($key, $value) + { + $this->state[$key] = $value; + } + + /** + * {@inheritdoc} + */ + public function updateState(Data $update) + { + $this->state->update($update); + } + + /** + * {@inheritdoc} + */ + public function resetState() + { + $this->state = new Data(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/ApiGen.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/ApiGen.php new file mode 100644 index 00000000..11ff764c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/ApiGen.php @@ -0,0 +1,518 @@ +taskApiGen('./vendor/apigen/apigen.phar') + * ->config('./apigen.neon') + * ->templateConfig('vendor/apigen/apigen/templates/bootstrap/config.neon') + * ->wipeout(true) + * ->run(); + * ?> + * ``` + */ +class ApiGen extends BaseTask implements CommandInterface +{ + use \Robo\Common\ExecOneCommand; + + const BOOL_NO = 'no'; + const BOOL_YES = 'yes'; + + /** + * @var string + */ + protected $command; + protected $operation = 'generate'; + + /** + * @param null|string $pathToApiGen + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToApiGen = null) + { + $this->command = $pathToApiGen; + $command_parts = []; + preg_match('/((?:.+)?apigen(?:\.phar)?) ?( \w+)? ?(.+)?/', $this->command, $command_parts); + if (count($command_parts) === 3) { + list(, $this->command, $this->operation) = $command_parts; + } + if (count($command_parts) === 4) { + list(, $this->command, $this->operation, $arg) = $command_parts; + $this->arg($arg); + } + if (!$this->command) { + $this->command = $this->findExecutablePhar('apigen'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "No apigen installation found"); + } + } + + /** + * Pass methods parameters as arguments to executable. Argument values + * are automatically escaped. + * + * @param string|string[] $args + * + * @return $this + */ + public function args($args) + { + if (!is_array($args)) { + $args = func_get_args(); + } + $args = array_map(function ($arg) { + if (preg_match('/^\w+$/', trim($arg)) === 1) { + $this->operation = $arg; + return null; + } + return $arg; + }, $args); + $args = array_filter($args); + $this->arguments .= ' ' . implode(' ', array_map('static::escape', $args)); + return $this; + } + + /** + * @param array|Traversable|string $arg a single object or something traversable + * + * @return array|Traversable the provided argument if it was already traversable, or the given + * argument returned as a one-element array + */ + protected static function forceTraversable($arg) + { + $traversable = $arg; + if (!is_array($traversable) && !($traversable instanceof \Traversable)) { + $traversable = array($traversable); + } + return $traversable; + } + + /** + * @param array|string $arg a single argument or an array of multiple string values + * + * @return string a comma-separated string of all of the provided arguments, suitable + * as a command-line "list" type argument for ApiGen + */ + protected static function asList($arg) + { + $normalized = is_array($arg) ? $arg : array($arg); + return implode(',', $normalized); + } + + /** + * @param bool|string $val an argument to be normalized + * @param string $default one of self::BOOL_YES or self::BOOK_NO if the provided + * value could not deterministically be converted to a + * yes or no value + * + * @return string the given value as a command-line "yes|no" type of argument for ApiGen, + * or the default value if none could be determined + */ + protected static function asTextBool($val, $default) + { + if ($val === self::BOOL_YES || $val === self::BOOL_NO) { + return $val; + } + if (!$val) { + return self::BOOL_NO; + } + if ($val === true) { + return self::BOOL_YES; + } + if (is_numeric($val) && $val != 0) { + return self::BOOL_YES; + } + if (strcasecmp($val[0], 'y') === 0) { + return self::BOOL_YES; + } + if (strcasecmp($val[0], 'n') === 0) { + return self::BOOL_NO; + } + // meh, good enough, let apigen sort it out + return $default; + } + + /** + * @param string $config + * + * @return $this + */ + public function config($config) + { + $this->option('config', $config); + return $this; + } + + /** + * @param array|string|Traversable $src one or more source values + * + * @return $this + */ + public function source($src) + { + foreach (self::forceTraversable($src) as $source) { + $this->option('source', $source); + } + return $this; + } + + /** + * @param string $dest + * + * @return $this + */ + public function destination($dest) + { + $this->option('destination', $dest); + return $this; + } + + /** + * @param array|string $exts one or more extensions + * + * @return $this + */ + public function extensions($exts) + { + $this->option('extensions', self::asList($exts)); + return $this; + } + + /** + * @param array|string $exclude one or more exclusions + * + * @return $this + */ + public function exclude($exclude) + { + foreach (self::forceTraversable($exclude) as $excl) { + $this->option('exclude', $excl); + } + return $this; + } + + /** + * @param array|string|Traversable $path one or more skip-doc-path values + * + * @return $this + */ + public function skipDocPath($path) + { + foreach (self::forceTraversable($path) as $skip) { + $this->option('skip-doc-path', $skip); + } + return $this; + } + + /** + * @param array|string|Traversable $prefix one or more skip-doc-prefix values + * + * @return $this + */ + public function skipDocPrefix($prefix) + { + foreach (self::forceTraversable($prefix) as $skip) { + $this->option('skip-doc-prefix', $skip); + } + return $this; + } + + /** + * @param array|string $charset one or more charsets + * + * @return $this + */ + public function charset($charset) + { + $this->option('charset', self::asList($charset)); + return $this; + } + + /** + * @param string $name + * + * @return $this + */ + public function mainProjectNamePrefix($name) + { + $this->option('main', $name); + return $this; + } + + /** + * @param string $title + * + * @return $this + */ + public function title($title) + { + $this->option('title', $title); + return $this; + } + + /** + * @param string $baseUrl + * + * @return $this + */ + public function baseUrl($baseUrl) + { + $this->option('base-url', $baseUrl); + return $this; + } + + /** + * @param string $id + * + * @return $this + */ + public function googleCseId($id) + { + $this->option('google-cse-id', $id); + return $this; + } + + /** + * @param string $trackingCode + * + * @return $this + */ + public function googleAnalytics($trackingCode) + { + $this->option('google-analytics', $trackingCode); + return $this; + } + + /** + * @param mixed $templateConfig + * + * @return $this + */ + public function templateConfig($templateConfig) + { + $this->option('template-config', $templateConfig); + return $this; + } + + /** + * @param array|string $tags one or more supported html tags + * + * @return $this + */ + public function allowedHtml($tags) + { + $this->option('allowed-html', self::asList($tags)); + return $this; + } + + /** + * @param string $groups + * + * @return $this + */ + public function groups($groups) + { + $this->option('groups', $groups); + return $this; + } + + /** + * @param array|string $types or more supported autocomplete types + * + * @return $this + */ + public function autocomplete($types) + { + $this->option('autocomplete', self::asList($types)); + return $this; + } + + /** + * @param array|string $levels one or more access levels + * + * @return $this + */ + public function accessLevels($levels) + { + $this->option('access-levels', self::asList($levels)); + return $this; + } + + /** + * @param boolean|string $internal 'yes' or true if internal, 'no' or false if not + * + * @return $this + */ + public function internal($internal) + { + $this->option('internal', self::asTextBool($internal, self::BOOL_NO)); + return $this; + } + + /** + * @param boolean|string $php 'yes' or true to generate documentation for internal php classes, + * 'no' or false otherwise + * + * @return $this + */ + public function php($php) + { + $this->option('php', self::asTextBool($php, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $tree 'yes' or true to generate a tree view of classes, 'no' or false otherwise + * + * @return $this + */ + public function tree($tree) + { + $this->option('tree', self::asTextBool($tree, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $dep 'yes' or true to generate documentation for deprecated classes, 'no' or false otherwise + * + * @return $this + */ + public function deprecated($dep) + { + $this->option('deprecated', self::asTextBool($dep, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $todo 'yes' or true to document tasks, 'no' or false otherwise + * + * @return $this + */ + public function todo($todo) + { + $this->option('todo', self::asTextBool($todo, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $src 'yes' or true to generate highlighted source code, 'no' or false otherwise + * + * @return $this + */ + public function sourceCode($src) + { + $this->option('source-code', self::asTextBool($src, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $zipped 'yes' or true to generate downloadable documentation, 'no' or false otherwise + * + * @return $this + */ + public function download($zipped) + { + $this->option('download', self::asTextBool($zipped, self::BOOL_NO)); + return $this; + } + + public function report($path) + { + $this->option('report', $path); + return $this; + } + + /** + * @param bool|string $wipeout 'yes' or true to clear out the destination directory, 'no' or false otherwise + * + * @return $this + */ + public function wipeout($wipeout) + { + $this->option('wipeout', self::asTextBool($wipeout, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $quiet 'yes' or true for quiet, 'no' or false otherwise + * + * @return $this + */ + public function quiet($quiet) + { + $this->option('quiet', self::asTextBool($quiet, self::BOOL_NO)); + return $this; + } + + /** + * @param bool|string $bar 'yes' or true to display a progress bar, 'no' or false otherwise + * + * @return $this + */ + public function progressbar($bar) + { + $this->option('progressbar', self::asTextBool($bar, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $colors 'yes' or true colorize the output, 'no' or false otherwise + * + * @return $this + */ + public function colors($colors) + { + $this->option('colors', self::asTextBool($colors, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $check 'yes' or true to check for updates, 'no' or false otherwise + * + * @return $this + */ + public function updateCheck($check) + { + $this->option('update-check', self::asTextBool($check, self::BOOL_YES)); + return $this; + } + + /** + * @param bool|string $debug 'yes' or true to enable debug mode, 'no' or false otherwise + * + * @return $this + */ + public function debug($debug) + { + $this->option('debug', self::asTextBool($debug, self::BOOL_NO)); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return "$this->command $this->operation$this->arguments"; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running ApiGen {args}', ['args' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/loadTasks.php new file mode 100644 index 00000000..e8cd372a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/ApiGen/loadTasks.php @@ -0,0 +1,15 @@ +task(ApiGen::class, $pathToApiGen); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Extract.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Extract.php new file mode 100644 index 00000000..a00a0baf --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Extract.php @@ -0,0 +1,279 @@ +taskExtract($archivePath) + * ->to($destination) + * ->preserveTopDirectory(false) // the default + * ->run(); + * ?> + * ``` + */ +class Extract extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $filename; + + /** + * @var string + */ + protected $to; + + /** + * @var bool + */ + private $preserveTopDirectory = false; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * Location to store extracted files. + * + * @param string $to + * + * @return $this + */ + public function to($to) + { + $this->to = $to; + return $this; + } + + /** + * @param bool $preserve + * + * @return $this + */ + public function preserveTopDirectory($preserve = true) + { + $this->preserveTopDirectory = $preserve; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!file_exists($this->filename)) { + $this->printTaskError("File {filename} does not exist", ['filename' => $this->filename]); + + return false; + } + if (!($mimetype = static::archiveType($this->filename))) { + $this->printTaskError("Could not determine type of archive for {filename}", ['filename' => $this->filename]); + + return false; + } + + // We will first extract to $extractLocation and then move to $this->to + $extractLocation = static::getTmpDir(); + @mkdir($extractLocation); + @mkdir(dirname($this->to)); + + $this->startTimer(); + + $this->printTaskInfo("Extracting {filename}", ['filename' => $this->filename]); + + $result = $this->extractAppropriateType($mimetype, $extractLocation); + if ($result->wasSuccessful()) { + $this->printTaskInfo("{filename} extracted", ['filename' => $this->filename]); + // Now, we want to move the extracted files to $this->to. There + // are two possibilities that we must consider: + // + // (1) Archived files were encapsulated in a folder with an arbitrary name + // (2) There was no encapsulating folder, and all the files in the archive + // were extracted into $extractLocation + // + // In the case of (1), we want to move and rename the encapsulating folder + // to $this->to. + // + // In the case of (2), we will just move and rename $extractLocation. + $filesInExtractLocation = glob("$extractLocation/*"); + $hasEncapsulatingFolder = ((count($filesInExtractLocation) == 1) && is_dir($filesInExtractLocation[0])); + if ($hasEncapsulatingFolder && !$this->preserveTopDirectory) { + $result = (new FilesystemStack()) + ->inflect($this) + ->rename($filesInExtractLocation[0], $this->to) + ->run(); + (new DeleteDir($extractLocation)) + ->inflect($this) + ->run(); + } else { + $result = (new FilesystemStack()) + ->inflect($this) + ->rename($extractLocation, $this->to) + ->run(); + } + } + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * @param string $mimetype + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractAppropriateType($mimetype, $extractLocation) + { + // Perform the extraction of a zip file. + if (($mimetype == 'application/zip') || ($mimetype == 'application/x-zip')) { + return $this->extractZip($extractLocation); + } + return $this->extractTar($extractLocation); + } + + /** + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractZip($extractLocation) + { + if (!extension_loaded('zlib')) { + return Result::errorMissingExtension($this, 'zlib', 'zip extracting'); + } + + $zip = new \ZipArchive(); + if (($status = $zip->open($this->filename)) !== true) { + return Result::error($this, "Could not open zip archive {$this->filename}"); + } + if (!$zip->extractTo($extractLocation)) { + return Result::error($this, "Could not extract zip archive {$this->filename}"); + } + $zip->close(); + + return Result::success($this); + } + + /** + * @param string $extractLocation + * + * @return \Robo\Result + */ + protected function extractTar($extractLocation) + { + if (!class_exists('Archive_Tar')) { + return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar'); + } + $tar_object = new \Archive_Tar($this->filename); + if (!$tar_object->extract($extractLocation)) { + return Result::error($this, "Could not extract tar archive {$this->filename}"); + } + + return Result::success($this); + } + + /** + * @param string $filename + * + * @return bool|string + */ + protected static function archiveType($filename) + { + $content_type = false; + if (class_exists('finfo')) { + $finfo = new \finfo(FILEINFO_MIME_TYPE); + $content_type = $finfo->file($filename); + // If finfo cannot determine the content type, then we will try other methods + if ($content_type == 'application/octet-stream') { + $content_type = false; + } + } + // Examing the file's magic header bytes. + if (!$content_type) { + if ($file = fopen($filename, 'rb')) { + $first = fread($file, 2); + fclose($file); + if ($first !== false) { + // Interpret the two bytes as a little endian 16-bit unsigned int. + $data = unpack('v', $first); + switch ($data[1]) { + case 0x8b1f: + // First two bytes of gzip files are 0x1f, 0x8b (little-endian). + // See http://www.gzip.org/zlib/rfc-gzip.html#header-trailer + $content_type = 'application/x-gzip'; + break; + + case 0x4b50: + // First two bytes of zip files are 0x50, 0x4b ('PK') (little-endian). + // See http://en.wikipedia.org/wiki/Zip_(file_format)#File_headers + $content_type = 'application/zip'; + break; + + case 0x5a42: + // First two bytes of bzip2 files are 0x5a, 0x42 ('BZ') (big-endian). + // See http://en.wikipedia.org/wiki/Bzip2#File_format + $content_type = 'application/x-bzip2'; + break; + } + } + } + } + // 3. Lastly if above methods didn't work, try to guess the mime type from + // the file extension. This is useful if the file has no identificable magic + // header bytes (for example tarballs). + if (!$content_type) { + // Remove querystring from the filename, if present. + $filename = basename(current(explode('?', $filename, 2))); + $extension_mimetype = array( + '.tar.gz' => 'application/x-gzip', + '.tgz' => 'application/x-gzip', + '.tar' => 'application/x-tar', + ); + foreach ($extension_mimetype as $extension => $ct) { + if (substr($filename, -strlen($extension)) === $extension) { + $content_type = $ct; + break; + } + } + } + + return $content_type; + } + + /** + * @return string + */ + protected static function getTmpDir() + { + return getcwd().'/tmp'.rand().time(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Pack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Pack.php new file mode 100644 index 00000000..0970f8e8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/Pack.php @@ -0,0 +1,257 @@ +taskPack( + * ) + * ->add('README') // Puts file 'README' in archive at the root + * ->add('project') // Puts entire contents of directory 'project' in archinve inside 'project' + * ->addFile('dir/file.txt', 'file.txt') // Takes 'file.txt' from cwd and puts it in archive inside 'dir'. + * ->run(); + * ?> + * ``` + */ +class Pack extends BaseTask implements PrintedInterface +{ + /** + * The list of items to be packed into the archive. + * + * @var array + */ + private $items = []; + + /** + * The full path to the archive to be created. + * + * @var string + */ + private $archiveFile; + + /** + * Construct the class. + * + * @param string $archiveFile The full path and name of the archive file to create. + * + * @since 1.0 + */ + public function __construct($archiveFile) + { + $this->archiveFile = $archiveFile; + } + + /** + * Satisfy the parent requirement. + * + * @return bool Always returns true. + * + * @since 1.0 + */ + public function getPrinted() + { + return true; + } + + /** + * @param string $archiveFile + * + * @return $this + */ + public function archiveFile($archiveFile) + { + $this->archiveFile = $archiveFile; + return $this; + } + + /** + * Add an item to the archive. Like file_exists(), the parameter + * may be a file or a directory. + * + * @var string + * Relative path and name of item to store in archive + * @var string + * Absolute or relative path to file or directory's location in filesystem + * + * @return $this + */ + public function addFile($placementLocation, $filesystemLocation) + { + $this->items[$placementLocation] = $filesystemLocation; + + return $this; + } + + /** + * Alias for addFile, in case anyone has angst about using + * addFile with a directory. + * + * @var string + * Relative path and name of directory to store in archive + * @var string + * Absolute or relative path to directory or directory's location in filesystem + * + * @return $this + */ + public function addDir($placementLocation, $filesystemLocation) + { + $this->addFile($placementLocation, $filesystemLocation); + + return $this; + } + + /** + * Add a file or directory, or list of same to the archive. + * + * @var string|array + * If given a string, should contain the relative filesystem path to the + * the item to store in archive; this will also be used as the item's + * path in the archive, so absolute paths should not be used here. + * If given an array, the key of each item should be the path to store + * in the archive, and the value should be the filesystem path to the + * item to store. + * @return $this + */ + public function add($item) + { + if (is_array($item)) { + $this->items = array_merge($this->items, $item); + } else { + $this->addFile($item, $item); + } + + return $this; + } + + /** + * Create a zip archive for distribution. + * + * @return \Robo\Result + * + * @since 1.0 + */ + public function run() + { + $this->startTimer(); + + // Use the file extension to determine what kind of archive to create. + $fileInfo = new \SplFileInfo($this->archiveFile); + $extension = strtolower($fileInfo->getExtension()); + if (empty($extension)) { + return Result::error($this, "Archive filename must use an extension (e.g. '.zip') to specify the kind of archive to create."); + } + + try { + // Inform the user which archive we are creating + $this->printTaskInfo("Creating archive {filename}", ['filename' => $this->archiveFile]); + if ($extension == 'zip') { + $result = $this->archiveZip($this->archiveFile, $this->items); + } else { + $result = $this->archiveTar($this->archiveFile, $this->items); + } + $this->printTaskSuccess("{filename} created.", ['filename' => $this->archiveFile]); + } catch (\Exception $e) { + $this->printTaskError("Could not create {filename}. {exception}", ['filename' => $this->archiveFile, 'exception' => $e->getMessage(), '_style' => ['exception' => '']]); + $result = Result::error($this, sprintf('Could not create %s. %s', $this->archiveFile, $e->getMessage())); + } + $this->stopTimer(); + $result['time'] = $this->getExecutionTime(); + + return $result; + } + + /** + * @param string $archiveFile + * @param array $items + * + * @return \Robo\Result + */ + protected function archiveTar($archiveFile, $items) + { + if (!class_exists('Archive_Tar')) { + return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar'); + } + + $tar_object = new \Archive_Tar($archiveFile); + foreach ($items as $placementLocation => $filesystemLocation) { + $p_remove_dir = $filesystemLocation; + $p_add_dir = $placementLocation; + if (is_file($filesystemLocation)) { + $p_remove_dir = dirname($filesystemLocation); + $p_add_dir = dirname($placementLocation); + if (basename($filesystemLocation) != basename($placementLocation)) { + return Result::error($this, "Tar archiver does not support renaming files during extraction; could not add $filesystemLocation as $placementLocation."); + } + } + + if (!$tar_object->addModify([$filesystemLocation], $p_add_dir, $p_remove_dir)) { + return Result::error($this, "Could not add $filesystemLocation to the archive."); + } + } + + return Result::success($this); + } + + /** + * @param string $archiveFile + * @param array $items + * + * @return \Robo\Result + */ + protected function archiveZip($archiveFile, $items) + { + if (!extension_loaded('zlib')) { + return Result::errorMissingExtension($this, 'zlib', 'zip packing'); + } + + $zip = new \ZipArchive($archiveFile, \ZipArchive::CREATE); + if (!$zip->open($archiveFile, \ZipArchive::CREATE)) { + return Result::error($this, "Could not create zip archive {$archiveFile}"); + } + $result = $this->addItemsToZip($zip, $items); + $zip->close(); + + return $result; + } + + /** + * @param \ZipArchive $zip + * @param array $items + * + * @return \Robo\Result + */ + protected function addItemsToZip($zip, $items) + { + foreach ($items as $placementLocation => $filesystemLocation) { + if (is_dir($filesystemLocation)) { + $finder = new Finder(); + $finder->files()->in($filesystemLocation)->ignoreDotFiles(false); + + foreach ($finder as $file) { + // Replace Windows slashes or resulting zip will have issues on *nixes. + $relativePathname = str_replace('\\', '/', $file->getRelativePathname()); + + if (!$zip->addFile($file->getRealpath(), "{$placementLocation}/{$relativePathname}")) { + return Result::error($this, "Could not add directory $filesystemLocation to the archive; error adding {$file->getRealpath()}."); + } + } + } elseif (is_file($filesystemLocation)) { + if (!$zip->addFile($filesystemLocation, $placementLocation)) { + return Result::error($this, "Could not add file $filesystemLocation to the archive."); + } + } else { + return Result::error($this, "Could not find $filesystemLocation for the archive."); + } + } + + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/loadTasks.php new file mode 100644 index 00000000..cf846fdf --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Archive/loadTasks.php @@ -0,0 +1,25 @@ +task(Pack::class, $filename); + } + + /** + * @param $filename + * + * @return Extract + */ + protected function taskExtract($filename) + { + return $this->task(Extract::class, $filename); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/CssPreprocessor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/CssPreprocessor.php new file mode 100644 index 00000000..a15d2078 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/CssPreprocessor.php @@ -0,0 +1,214 @@ +files = $input; + + $this->setDefaultCompiler(); + } + + protected function setDefaultCompiler() + { + if (isset($this->compilers[0])) { + //set first compiler as default + $this->compiler = $this->compilers[0]; + } + } + + /** + * Sets import directories + * Alias for setImportPaths + * @see CssPreprocessor::setImportPaths + * + * @param array|string $dirs + * + * @return $this + */ + public function importDir($dirs) + { + return $this->setImportPaths($dirs); + } + + /** + * Adds import directory + * + * @param string $dir + * + * @return $this + */ + public function addImportPath($dir) + { + if (!isset($this->compilerOptions['importDirs'])) { + $this->compilerOptions['importDirs'] = []; + } + + if (!in_array($dir, $this->compilerOptions['importDirs'], true)) { + $this->compilerOptions['importDirs'][] = $dir; + } + + return $this; + } + + /** + * Sets import directories + * + * @param array|string $dirs + * + * @return $this + */ + public function setImportPaths($dirs) + { + if (!is_array($dirs)) { + $dirs = [$dirs]; + } + + $this->compilerOptions['importDirs'] = $dirs; + + return $this; + } + + /** + * @param string $formatterName + * + * @return $this + */ + public function setFormatter($formatterName) + { + $this->compilerOptions['formatter'] = $formatterName; + + return $this; + } + + /** + * Sets the compiler. + * + * @param string $compiler + * @param array $options + * + * @return $this + */ + public function compiler($compiler, array $options = []) + { + $this->compiler = $compiler; + $this->compilerOptions = array_merge($this->compilerOptions, $options); + + return $this; + } + + /** + * Compiles file + * + * @param $file + * + * @return bool|mixed + */ + protected function compile($file) + { + if (is_callable($this->compiler)) { + return call_user_func($this->compiler, $file, $this->compilerOptions); + } + + if (method_exists($this, $this->compiler)) { + return $this->{$this->compiler}($file); + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!in_array($this->compiler, $this->compilers, true) + && !is_callable($this->compiler) + ) { + $message = sprintf('Invalid ' . static::FORMAT_NAME . ' compiler %s!', $this->compiler); + + return Result::error($this, $message); + } + + foreach ($this->files as $in => $out) { + if (!file_exists($in)) { + $message = sprintf('File %s not found.', $in); + + return Result::error($this, $message); + } + if (file_exists($out) && !is_writable($out)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + } + + foreach ($this->files as $in => $out) { + $css = $this->compile($in); + + if ($css instanceof Result) { + return $css; + } elseif (false === $css) { + $message = sprintf( + ucfirst(static::FORMAT_NAME) . ' compilation failed for %s.', + $in + ); + + return Result::error($this, $message); + } + + $dst = $out . '.part'; + $write_result = file_put_contents($dst, $css); + + if (false === $write_result) { + $message = sprintf('File write failed: %s', $out); + + @unlink($dst); + return Result::error($this, $message); + } + + // Cannot be cross-volume: should always succeed + @rename($dst, $out); + + $this->printTaskSuccess('Wrote CSS to {filename}', ['filename' => $out]); + } + + return Result::success($this, 'All ' . static::FORMAT_NAME . ' files compiled.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/ImageMinify.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/ImageMinify.php new file mode 100644 index 00000000..1aa62593 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/ImageMinify.php @@ -0,0 +1,716 @@ +taskImageMinify('assets/images/*') + * ->to('dist/images/') + * ->run(); + * ``` + * + * This will use the following minifiers: + * + * - PNG: optipng + * - GIF: gifsicle + * - JPG, JPEG: jpegtran + * - SVG: svgo + * + * When the minifier is specified the task will use that for all the input files. In that case + * it is useful to filter the files with the extension: + * + * ```php + * $this->taskImageMinify('assets/images/*.png') + * ->to('dist/images/') + * ->minifier('pngcrush'); + * ->run(); + * ``` + * + * The task supports the following minifiers: + * + * - optipng + * - pngquant + * - advpng + * - pngout + * - zopflipng + * - pngcrush + * - gifsicle + * - jpegoptim + * - jpeg-recompress + * - jpegtran + * - svgo (only minification, no downloading) + * + * You can also specifiy extra options for the minifiers: + * + * ```php + * $this->taskImageMinify('assets/images/*.jpg') + * ->to('dist/images/') + * ->minifier('jpegtran', ['-progressive' => null, '-copy' => 'none']) + * ->run(); + * ``` + * + * This will execute as: + * `jpegtran -copy none -progressive -optimize -outfile "dist/images/test.jpg" "/var/www/test/assets/images/test.jpg"` + */ +class ImageMinify extends BaseTask +{ + /** + * Destination directory for the minified images. + * + * @var string + */ + protected $to; + + /** + * Array of the source files. + * + * @var array + */ + protected $dirs = []; + + /** + * Symfony 2 filesystem. + * + * @var sfFilesystem + */ + protected $fs; + + /** + * Target directory for the downloaded binary executables. + * + * @var string + */ + protected $executableTargetDir; + + /** + * Array for the downloaded binary executables. + * + * @var array + */ + protected $executablePaths = []; + + /** + * Array for the individual results of all the files. + * + * @var array + */ + protected $results = []; + + /** + * Default minifier to use. + * + * @var string + */ + protected $minifier; + + /** + * Array for minifier options. + * + * @var array + */ + protected $minifierOptions = []; + + /** + * Supported minifiers. + * + * @var array + */ + protected $minifiers = [ + // Default 4 + 'optipng', + 'gifsicle', + 'jpegtran', + 'svgo', + // PNG + 'pngquant', + 'advpng', + 'pngout', + 'zopflipng', + 'pngcrush', + // JPG + 'jpegoptim', + 'jpeg-recompress', + ]; + + /** + * Binary repositories of Imagemin. + * + * @link https://github.com/imagemin + * + * @var array + */ + protected $imageminRepos = [ + // PNG + 'optipng' => 'https://github.com/imagemin/optipng-bin', + 'pngquant' => 'https://github.com/imagemin/pngquant-bin', + 'advpng' => 'https://github.com/imagemin/advpng-bin', + 'pngout' => 'https://github.com/imagemin/pngout-bin', + 'zopflipng' => 'https://github.com/imagemin/zopflipng-bin', + 'pngcrush' => 'https://github.com/imagemin/pngcrush-bin', + // Gif + 'gifsicle' => 'https://github.com/imagemin/gifsicle-bin', + // JPG + 'jpegtran' => 'https://github.com/imagemin/jpegtran-bin', + 'jpegoptim' => 'https://github.com/imagemin/jpegoptim-bin', + 'cjpeg' => 'https://github.com/imagemin/mozjpeg-bin', // note: we do not support this minifier because it creates JPG from non-JPG files + 'jpeg-recompress' => 'https://github.com/imagemin/jpeg-recompress-bin', + // WebP + 'cwebp' => 'https://github.com/imagemin/cwebp-bin', // note: we do not support this minifier because it creates WebP from non-WebP files + ]; + + public function __construct($dirs) + { + is_array($dirs) + ? $this->dirs = $dirs + : $this->dirs[] = $dirs; + + $this->fs = new sfFilesystem(); + + // guess the best path for the executables based on __DIR__ + if (($pos = strpos(__DIR__, 'consolidation/robo')) !== false) { + // the executables should be stored in vendor/bin + $this->executableTargetDir = substr(__DIR__, 0, $pos).'bin'; + } + + // check if the executables are already available + foreach ($this->imageminRepos as $exec => $url) { + $path = $this->executableTargetDir.'/'.$exec; + // if this is Windows add a .exe extension + if (substr($this->getOS(), 0, 3) == 'win') { + $path .= '.exe'; + } + if (is_file($path)) { + $this->executablePaths[$exec] = $path; + } + } + } + + /** + * {@inheritdoc} + */ + public function run() + { + // find the files + $files = $this->findFiles($this->dirs); + + // minify the files + $result = $this->minify($files); + // check if there was an error + if ($result instanceof Result) { + return $result; + } + + $amount = (count($files) == 1 ? 'image' : 'images'); + $message = "Minified {filecount} out of {filetotal} $amount into {destination}"; + $context = ['filecount' => count($this->results['success']), 'filetotal' => count($files), 'destination' => $this->to]; + + if (count($this->results['success']) == count($files)) { + $this->printTaskSuccess($message, $context); + + return Result::success($this, $message, $context); + } else { + return Result::error($this, $message, $context); + } + } + + /** + * Sets the target directory where the files will be copied to. + * + * @param string $target + * + * @return $this + */ + public function to($target) + { + $this->to = rtrim($target, '/'); + + return $this; + } + + /** + * Sets the minifier. + * + * @param string $minifier + * @param array $options + * + * @return $this + */ + public function minifier($minifier, array $options = []) + { + $this->minifier = $minifier; + $this->minifierOptions = array_merge($this->minifierOptions, $options); + + return $this; + } + + /** + * @param array $dirs + * + * @return array|\Robo\Result + * + * @throws \Robo\Exception\TaskException + */ + protected function findFiles($dirs) + { + $files = array(); + + // find the files + foreach ($dirs as $k => $v) { + // reset finder + $finder = new Finder(); + + $dir = $k; + $to = $v; + // check if target was given with the to() method instead of key/value pairs + if (is_int($k)) { + $dir = $v; + if (isset($this->to)) { + $to = $this->to; + } else { + throw new TaskException($this, 'target directory is not defined'); + } + } + + try { + $finder->files()->in($dir); + } catch (\InvalidArgumentException $e) { + // if finder cannot handle it, try with in()->name() + if (strpos($dir, '/') === false) { + $dir = './'.$dir; + } + $parts = explode('/', $dir); + $new_dir = implode('/', array_slice($parts, 0, -1)); + try { + $finder->files()->in($new_dir)->name(array_pop($parts)); + } catch (\InvalidArgumentException $e) { + return Result::fromException($this, $e); + } + } + + foreach ($finder as $file) { + // store the absolute path as key and target as value in the files array + $files[$file->getRealpath()] = $this->getTarget($file->getRealPath(), $to); + } + $fileNoun = count($finder) == 1 ? ' file' : ' files'; + $this->printTaskInfo("Found {filecount} $fileNoun in {dir}", ['filecount' => count($finder), 'dir' => $dir]); + } + + return $files; + } + + /** + * @param string $file + * @param string $to + * + * @return string + */ + protected function getTarget($file, $to) + { + $target = $to.'/'.basename($file); + + return $target; + } + + /** + * @param array $files + * + * @return \Robo\Result + */ + protected function minify($files) + { + // store the individual results into the results array + $this->results = [ + 'success' => [], + 'error' => [], + ]; + + // loop through the files + foreach ($files as $from => $to) { + if (!isset($this->minifier)) { + // check filetype based on the extension + $extension = strtolower(pathinfo($from, PATHINFO_EXTENSION)); + + // set the default minifiers based on the extension + switch ($extension) { + case 'png': + $minifier = 'optipng'; + break; + case 'jpg': + case 'jpeg': + $minifier = 'jpegtran'; + break; + case 'gif': + $minifier = 'gifsicle'; + break; + case 'svg': + $minifier = 'svgo'; + break; + } + } else { + if (!in_array($this->minifier, $this->minifiers, true) + && !is_callable(strtr($this->minifier, '-', '_')) + ) { + $message = sprintf('Invalid minifier %s!', $this->minifier); + + return Result::error($this, $message); + } + $minifier = $this->minifier; + } + + // Convert minifier name to camelCase (e.g. jpeg-recompress) + $funcMinifier = $this->camelCase($minifier); + + // call the minifier method which prepares the command + if (is_callable($funcMinifier)) { + $command = call_user_func($funcMinifier, $from, $to, $this->minifierOptions); + } elseif (method_exists($this, $funcMinifier)) { + $command = $this->{$funcMinifier}($from, $to); + } else { + $message = sprintf('Minifier method %s cannot be found!', $funcMinifier); + + return Result::error($this, $message); + } + + // launch the command + $this->printTaskInfo('Minifying {filepath} with {minifier}', ['filepath' => $from, 'minifier' => $minifier]); + $result = $this->executeCommand($command); + + // check the return code + if ($result->getExitCode() == 127) { + $this->printTaskError('The {minifier} executable cannot be found', ['minifier' => $minifier]); + // try to install from imagemin repository + if (array_key_exists($minifier, $this->imageminRepos)) { + $result = $this->installFromImagemin($minifier); + if ($result instanceof Result) { + if ($result->wasSuccessful()) { + $this->printTaskSuccess($result->getMessage()); + // retry the conversion with the downloaded executable + if (is_callable($minifier)) { + $command = call_user_func($minifier, $from, $to, $minifierOptions); + } elseif (method_exists($this, $minifier)) { + $command = $this->{$minifier}($from, $to); + } + // launch the command + $this->printTaskInfo('Minifying {filepath} with {minifier}', ['filepath' => $from, 'minifier' => $minifier]); + $result = $this->executeCommand($command); + } else { + $this->printTaskError($result->getMessage()); + // the download was not successful + return $result; + } + } + } else { + return $result; + } + } + + // check the success of the conversion + if ($result->getExitCode() !== 0) { + $this->results['error'][] = $from; + } else { + $this->results['success'][] = $from; + } + } + } + + /** + * @return string + */ + protected function getOS() + { + $os = php_uname('s'); + $os .= '/'.php_uname('m'); + // replace x86_64 to x64, because the imagemin repo uses that + $os = str_replace('x86_64', 'x64', $os); + // replace i386, i686, etc to x86, because of imagemin + $os = preg_replace('/i[0-9]86/', 'x86', $os); + // turn info to lowercase, because of imagemin + $os = strtolower($os); + + return $os; + } + + /** + * @param string $command + * + * @return \Robo\Result + */ + protected function executeCommand($command) + { + // insert the options into the command + $a = explode(' ', $command); + $executable = array_shift($a); + foreach ($this->minifierOptions as $key => $value) { + // first prepend the value + if (!empty($value)) { + array_unshift($a, $value); + } + // then add the key + if (!is_numeric($key)) { + array_unshift($a, $key); + } + } + // check if the executable can be replaced with the downloaded one + if (array_key_exists($executable, $this->executablePaths)) { + $executable = $this->executablePaths[$executable]; + } + array_unshift($a, $executable); + $command = implode(' ', $a); + + // execute the command + $exec = new Exec($command); + + return $exec->inflect($this)->printed(false)->run(); + } + + /** + * @param string $executable + * + * @return \Robo\Result + */ + protected function installFromImagemin($executable) + { + // check if there is an url defined for the executable + if (!array_key_exists($executable, $this->imageminRepos)) { + $message = sprintf('The executable %s cannot be found in the defined imagemin repositories', $executable); + + return Result::error($this, $message); + } + $this->printTaskInfo('Downloading the {executable} executable from the imagemin repository', ['executable' => $executable]); + + $os = $this->getOS(); + $url = $this->imageminRepos[$executable].'/blob/master/vendor/'.$os.'/'.$executable.'?raw=true'; + if (substr($os, 0, 3) == 'win') { + // if it is win, add a .exe extension + $url = $this->imageminRepos[$executable].'/blob/master/vendor/'.$os.'/'.$executable.'.exe?raw=true'; + } + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is something wrong with the url, try it without the version info + $url = preg_replace('/x[68][64]\//', '', $url); + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is still something wrong with the url if it is win, try with win32 + if (substr($os, 0, 3) == 'win') { + $url = preg_replace('win/', 'win32/', $url); + $data = @file_get_contents($url, false, null); + if ($data === false) { + // there is nothing more we can do + $message = sprintf('Could not download the executable %s', $executable); + + return Result::error($this, $message); + } + } + // if it is not windows there is nothing we can do + $message = sprintf('Could not download the executable %s', $executable); + + return Result::error($this, $message); + } + } + // check if target directory exists + if (!is_dir($this->executableTargetDir)) { + mkdir($this->executableTargetDir); + } + // save the executable into the target dir + $path = $this->executableTargetDir.'/'.$executable; + if (substr($os, 0, 3) == 'win') { + // if it is win, add a .exe extension + $path = $this->executableTargetDir.'/'.$executable.'.exe'; + } + $result = file_put_contents($path, $data); + if ($result === false) { + $message = sprintf('Could not copy the executable %s to %s', $executable, $target_dir); + + return Result::error($this, $message); + } + // set the binary to executable + chmod($path, 0755); + + // if everything successful, store the executable path + $this->executablePaths[$executable] = $this->executableTargetDir.'/'.$executable; + // if it is win, add a .exe extension + if (substr($os, 0, 3) == 'win') { + $this->executablePaths[$executable] .= '.exe'; + } + + $message = sprintf('Executable %s successfully downloaded', $executable); + + return Result::success($this, $message); + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function optipng($from, $to) + { + $command = sprintf('optipng -quiet -out "%s" -- "%s"', $to, $from); + if ($from != $to && is_file($to)) { + // earlier versions of optipng do not overwrite the target without a backup + // http://sourceforge.net/p/optipng/bugs/37/ + unlink($to); + } + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegtran($from, $to) + { + $command = sprintf('jpegtran -optimize -outfile "%s" "%s"', $to, $from); + + return $command; + } + + protected function gifsicle($from, $to) + { + $command = sprintf('gifsicle -o "%s" "%s"', $to, $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function svgo($from, $to) + { + $command = sprintf('svgo "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngquant($from, $to) + { + $command = sprintf('pngquant --force --output "%s" "%s"', $to, $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function advpng($from, $to) + { + // advpng does not have any output parameters, copy the file and then compress the copy + $command = sprintf('advpng --recompress --quiet "%s"', $to); + $this->fs->copy($from, $to, true); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngout($from, $to) + { + $command = sprintf('pngout -y -q "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function zopflipng($from, $to) + { + $command = sprintf('zopflipng -y "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function pngcrush($from, $to) + { + $command = sprintf('pngcrush -q -ow "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegoptim($from, $to) + { + // jpegoptim only takes the destination directory as an argument + $command = sprintf('jpegoptim --quiet -o --dest "%s" "%s"', dirname($to), $from); + + return $command; + } + + /** + * @param string $from + * @param string $to + * + * @return string + */ + protected function jpegRecompress($from, $to) + { + $command = sprintf('jpeg-recompress --quiet "%s" "%s"', $from, $to); + + return $command; + } + + /** + * @param string $text + * + * @return string + */ + public static function camelCase($text) + { + // non-alpha and non-numeric characters become spaces + $text = preg_replace('/[^a-z0-9]+/i', ' ', $text); + $text = trim($text); + // uppercase the first character of each word + $text = ucwords($text); + $text = str_replace(" ", "", $text); + $text = lcfirst($text); + + return $text; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Less.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Less.php new file mode 100644 index 00000000..4cfa0978 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Less.php @@ -0,0 +1,108 @@ +taskLess([ + * 'less/default.less' => 'css/default.css' + * ]) + * ->run(); + * ?> + * ``` + * + * Use one of both less compilers in your project: + * + * ``` + * "leafo/lessphp": "~0.5", + * "oyejorge/less.php": "~1.5" + * ``` + * + * Specify directory (string or array) for less imports lookup: + * + * ```php + * taskLess([ + * 'less/default.less' => 'css/default.css' + * ]) + * ->importDir('less') + * ->compiler('lessphp') + * ->run(); + * ?> + * ``` + * + * You can implement additional compilers by extending this task and adding a + * method named after them and overloading the lessCompilers() method to + * inject the name there. + */ +class Less extends CssPreprocessor +{ + const FORMAT_NAME = 'less'; + + /** + * @var string[] + */ + protected $compilers = [ + 'less', // https://github.com/oyejorge/less.php + 'lessphp', //https://github.com/leafo/lessphp + ]; + + /** + * lessphp compiler + * @link https://github.com/leafo/lessphp + * + * @param string $file + * + * @return string + */ + protected function lessphp($file) + { + if (!class_exists('\lessc')) { + return Result::errorMissingPackage($this, 'lessc', 'leafo/lessphp'); + } + + $lessCode = file_get_contents($file); + + $less = new \lessc(); + if (isset($this->compilerOptions['importDirs'])) { + $less->setImportDir($this->compilerOptions['importDirs']); + } + + return $less->compile($lessCode); + } + + /** + * less compiler + * @link https://github.com/oyejorge/less.php + * + * @param string $file + * + * @return string + */ + protected function less($file) + { + if (!class_exists('\Less_Parser')) { + return Result::errorMissingPackage($this, 'Less_Parser', 'oyejorge/less.php'); + } + + $lessCode = file_get_contents($file); + + $parser = new \Less_Parser(); + $parser->SetOptions($this->compilerOptions); + if (isset($this->compilerOptions['importDirs'])) { + $importDirs = []; + foreach ($this->compilerOptions['importDirs'] as $dir) { + $importDirs[$dir] = $dir; + } + $parser->SetImportDirs($importDirs); + } + + $parser->parse($lessCode); + + return $parser->getCss(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Minify.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Minify.php new file mode 100644 index 00000000..3187714e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Minify.php @@ -0,0 +1,297 @@ +taskMinify( 'web/assets/theme.css' ) + * ->run() + * ?> + * ``` + * Please install additional dependencies to use: + * + * ``` + * "patchwork/jsqueeze": "~1.0", + * "natxet/CssMin": "~3.0" + * ``` + */ +class Minify extends BaseTask +{ + /** + * @var array + */ + protected $types = ['css', 'js']; + + /** + * @var string + */ + protected $text; + + /** + * @var string + */ + protected $dst; + + /** + * @var string + */ + protected $type; + + /** + * @var array + */ + protected $squeezeOptions = [ + 'singleLine' => true, + 'keepImportantComments' => true, + 'specialVarRx' => false, + ]; + + /** + * Constructor. Accepts asset file path or string source. + * + * @param string $input + */ + public function __construct($input) + { + if (file_exists($input)) { + $this->fromFile($input); + return; + } + + $this->fromText($input); + } + + /** + * Sets destination. Tries to guess type from it. + * + * @param string $dst + * + * @return $this + */ + public function to($dst) + { + $this->dst = $dst; + + if (!empty($this->dst) && empty($this->type)) { + $this->type($this->getExtension($this->dst)); + } + + return $this; + } + + /** + * Sets type with validation. + * + * @param string $type css|js + * + * @return $this + */ + public function type($type) + { + $type = strtolower($type); + + if (in_array($type, $this->types)) { + $this->type = $type; + } + + return $this; + } + + /** + * Sets text from string source. + * + * @param string $text + * + * @return $this + */ + protected function fromText($text) + { + $this->text = (string)$text; + unset($this->type); + + return $this; + } + + /** + * Sets text from asset file path. Tries to guess type and set default destination. + * + * @param string $path + * + * @return $this + */ + protected function fromFile($path) + { + $this->text = file_get_contents($path); + + unset($this->type); + $this->type($this->getExtension($path)); + + if (empty($this->dst) && !empty($this->type)) { + $ext_length = strlen($this->type) + 1; + $this->dst = substr($path, 0, -$ext_length) . '.min.' . $this->type; + } + + return $this; + } + + /** + * Gets file extension from path. + * + * @param string $path + * + * @return string + */ + protected function getExtension($path) + { + return pathinfo($path, PATHINFO_EXTENSION); + } + + /** + * Minifies and returns text. + * + * @return string|bool + */ + protected function getMinifiedText() + { + switch ($this->type) { + case 'css': + if (!class_exists('\CssMin')) { + return Result::errorMissingPackage($this, 'CssMin', 'natxet/CssMin'); + } + + return \CssMin::minify($this->text); + break; + + case 'js': + if (!class_exists('\JSqueeze') && !class_exists('\Patchwork\JSqueeze')) { + return Result::errorMissingPackage($this, 'Patchwork\JSqueeze', 'patchwork/jsqueeze'); + } + + if (class_exists('\JSqueeze')) { + $jsqueeze = new \JSqueeze(); + } else { + $jsqueeze = new \Patchwork\JSqueeze(); + } + + return $jsqueeze->squeeze( + $this->text, + $this->squeezeOptions['singleLine'], + $this->squeezeOptions['keepImportantComments'], + $this->squeezeOptions['specialVarRx'] + ); + break; + } + + return false; + } + + /** + * Single line option for the JS minimisation. + * + * @param bool $singleLine + * + * @return $this + */ + public function singleLine($singleLine) + { + $this->squeezeOptions['singleLine'] = (bool)$singleLine; + return $this; + } + + /** + * keepImportantComments option for the JS minimisation. + * + * @param bool $keepImportantComments + * + * @return $this + */ + public function keepImportantComments($keepImportantComments) + { + $this->squeezeOptions['keepImportantComments'] = (bool)$keepImportantComments; + return $this; + } + + /** + * specialVarRx option for the JS minimisation. + * + * @param bool $specialVarRx + * + * @return $this ; + */ + public function specialVarRx($specialVarRx) + { + $this->squeezeOptions['specialVarRx'] = (bool)$specialVarRx; + return $this; + } + + /** + * @return string + */ + public function __toString() + { + return (string) $this->getMinifiedText(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->type)) { + return Result::error($this, 'Unknown asset type.'); + } + + if (empty($this->dst)) { + return Result::error($this, 'Unknown file destination.'); + } + + if (file_exists($this->dst) && !is_writable($this->dst)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + + $size_before = strlen($this->text); + $minified = $this->getMinifiedText(); + + if ($minified instanceof Result) { + return $minified; + } elseif (false === $minified) { + return Result::error($this, 'Minification failed.'); + } + + $size_after = strlen($minified); + + // Minification did not reduce file size, so use original file. + if ($size_after > $size_before) { + $minified = $this->text; + $size_after = $size_before; + } + + $dst = $this->dst . '.part'; + $write_result = file_put_contents($dst, $minified); + + if (false === $write_result) { + @unlink($dst); + return Result::error($this, 'File write failed.'); + } + // Cannot be cross-volume; should always succeed. + @rename($dst, $this->dst); + if ($size_before === 0) { + $minified_percent = 0; + } else { + $minified_percent = number_format(100 - ($size_after / $size_before * 100), 1); + } + $this->printTaskSuccess('Wrote {filepath}', ['filepath' => $this->dst]); + $context = [ + 'bytes' => $this->formatBytes($size_after), + 'reduction' => $this->formatBytes(($size_before - $size_after)), + 'percentage' => $minified_percent, + ]; + $this->printTaskSuccess('Wrote {bytes} (reduced by {reduction} / {percentage})', $context); + return Result::success($this, 'Asset minified.'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Scss.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Scss.php new file mode 100644 index 00000000..ffd39345 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/Scss.php @@ -0,0 +1,93 @@ +taskScss([ + * 'scss/default.scss' => 'css/default.css' + * ]) + * ->importDir('assets/styles') + * ->run(); + * ?> + * ``` + * + * Use the following scss compiler in your project: + * + * ``` + * "leafo/scssphp": "~0.1", + * ``` + * + * You can implement additional compilers by extending this task and adding a + * method named after them and overloading the scssCompilers() method to + * inject the name there. + */ +class Scss extends CssPreprocessor +{ + const FORMAT_NAME = 'scss'; + + /** + * @var string[] + */ + protected $compilers = [ + 'scssphp', // https://github.com/leafo/scssphp + ]; + + /** + * scssphp compiler + * @link https://github.com/leafo/scssphp + * + * @param string $file + * + * @return string + */ + protected function scssphp($file) + { + if (!class_exists('\Leafo\ScssPhp\Compiler')) { + return Result::errorMissingPackage($this, 'scssphp', 'leafo/scssphp'); + } + + $scssCode = file_get_contents($file); + $scss = new \Leafo\ScssPhp\Compiler(); + + // set options for the scssphp compiler + if (isset($this->compilerOptions['importDirs'])) { + $scss->setImportPaths($this->compilerOptions['importDirs']); + } + + if (isset($this->compilerOptions['formatter'])) { + $scss->setFormatter($this->compilerOptions['formatter']); + } + + return $scss->compile($scssCode); + } + + /** + * Sets the formatter for scssphp + * + * The method setFormatter($formatterName) sets the current formatter to $formatterName, + * the name of a class as a string that implements the formatting interface. See the source + * for Leafo\ScssPhp\Formatter\Expanded for an example. + * + * Five formatters are included with leafo/scssphp: + * - Leafo\ScssPhp\Formatter\Expanded + * - Leafo\ScssPhp\Formatter\Nested (default) + * - Leafo\ScssPhp\Formatter\Compressed + * - Leafo\ScssPhp\Formatter\Compact + * - Leafo\ScssPhp\Formatter\Crunched + * + * @link http://leafo.github.io/scssphp/docs/#output-formatting + * + * @param string $formatterName + * + * @return $this + */ + public function setFormatter($formatterName) + { + return parent::setFormatter($formatterName); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/loadTasks.php new file mode 100644 index 00000000..12192dd8 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Assets/loadTasks.php @@ -0,0 +1,45 @@ +task(Minify::class, $input); + } + + /** + * @param string|string[] $input + * + * @return \Robo\Task\Assets\ImageMinify + */ + protected function taskImageMinify($input) + { + return $this->task(ImageMinify::class, $input); + } + + /** + * @param array $input + * + * @return \Robo\Task\Assets\Less + */ + protected function taskLess($input) + { + return $this->task(Less::class, $input); + } + + /** + * @param array $input + * + * @return \Robo\Task\Assets\Scss + */ + protected function taskScss($input) + { + return $this->task(Scss::class, $input); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Exec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Exec.php new file mode 100644 index 00000000..c3e47917 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Exec.php @@ -0,0 +1,125 @@ +taskExec('compass')->arg('watch')->run(); + * // or use shortcut + * $this->_exec('compass watch'); + * + * $this->taskExec('compass watch')->background()->run(); + * + * if ($this->taskExec('phpunit .')->run()->wasSuccessful()) { + * $this->say('tests passed'); + * } + * + * ?> + * ``` + */ +class Exec extends BaseTask implements CommandInterface, PrintedInterface, SimulatedInterface +{ + use \Robo\Common\CommandReceiver; + use \Robo\Common\ExecOneCommand; + + /** + * @var static[] + */ + protected static $instances = []; + + /** + * @var string|\Robo\Contract\CommandInterface + */ + protected $command; + + /** + * @param string|\Robo\Contract\CommandInterface $command + */ + public function __construct($command) + { + $this->command = $this->receiveCommand($command); + } + + /** + * + */ + public function __destruct() + { + $this->stop(); + } + + /** + * Executes command in background mode (asynchronously) + * + * @return $this + */ + public function background($arg = true) + { + self::$instances[] = $this; + $this->background = $arg; + return $this; + } + + /** + * {@inheritdoc} + */ + protected function getCommandDescription() + { + return $this->getCommand(); + } + /** + * {@inheritdoc} + */ + public function getCommand() + { + return trim($this->command . $this->arguments); + } + + /** + * {@inheritdoc} + */ + public function simulate($context) + { + $this->printAction($context); + } + + public static function stopRunningJobs() + { + foreach (self::$instances as $instance) { + if ($instance) { + unset($instance); + } + } + } + + /** + * {@inheritdoc} + */ + public function run() + { + // TODO: Symfony 4 requires that we supply the working directory. + $result_data = $this->execute(new Process($this->getCommand(), getcwd())); + return new Result( + $this, + $result_data->getExitCode(), + $result_data->getMessage(), + $result_data->getData() + ); + } +} + +if (function_exists('pcntl_signal')) { + pcntl_signal(SIGTERM, ['Robo\Task\Base\Exec', 'stopRunningJobs']); +} + +register_shutdown_function(['Robo\Task\Base\Exec', 'stopRunningJobs']); diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ExecStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ExecStack.php new file mode 100644 index 00000000..51b39ef1 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ExecStack.php @@ -0,0 +1,23 @@ +taskExecStack() + * ->stopOnFail() + * ->exec('mkdir site') + * ->exec('cd site') + * ->run(); + * + * ?> + * ``` + */ +class ExecStack extends CommandStack +{ +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ParallelExec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ParallelExec.php new file mode 100644 index 00000000..c98b7841 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/ParallelExec.php @@ -0,0 +1,199 @@ +taskParallelExec() + * ->process('php ~/demos/script.php hey') + * ->process('php ~/demos/script.php hoy') + * ->process('php ~/demos/script.php gou') + * ->run(); + * ?> + * ``` + */ +class ParallelExec extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\CommandReceiver; + + /** + * @var Process[] + */ + protected $processes = []; + + /** + * @var null|int + */ + protected $timeout = null; + + /** + * @var null|int + */ + protected $idleTimeout = null; + + /** + * @var null|int + */ + protected $waitInterval = 0; + + /** + * @var bool + */ + protected $isPrinted = false; + + /** + * {@inheritdoc} + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * @param bool $isPrinted + * + * @return $this + */ + public function printed($isPrinted = true) + { + $this->isPrinted = $isPrinted; + return $this; + } + + /** + * @param string|\Robo\Contract\CommandInterface $command + * + * @return $this + */ + public function process($command) + { + // TODO: Symfony 4 requires that we supply the working directory. + $this->processes[] = new Process($this->receiveCommand($command), getcwd()); + return $this; + } + + /** + * Stops process if it runs longer then `$timeout` (seconds). + * + * @param int $timeout + * + * @return $this + */ + public function timeout($timeout) + { + $this->timeout = $timeout; + return $this; + } + + /** + * Stops process if it does not output for time longer then `$timeout` (seconds). + * + * @param int $idleTimeout + * + * @return $this + */ + public function idleTimeout($idleTimeout) + { + $this->idleTimeout = $idleTimeout; + return $this; + } + + /** + * Parallel processing will wait `$waitInterval` seconds after launching each process and before + * the next one. + * + * @param int $waitInterval + * + * @return $this + */ + public function waitInterval($waitInterval) + { + $this->waitInterval = $waitInterval; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return implode(' && ', $this->processes); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + return count($this->processes); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->startProgressIndicator(); + $running = []; + $queue = $this->processes; + $nextTime = time(); + while (true) { + if (($nextTime <= time()) && !empty($queue)) { + $process = array_shift($queue); + $process->setIdleTimeout($this->idleTimeout); + $process->setTimeout($this->timeout); + $process->start(); + $this->printTaskInfo($process->getCommandLine()); + $running[] = $process; + $nextTime = time() + $this->waitInterval; + } + foreach ($running as $k => $process) { + try { + $process->checkTimeout(); + } catch (ProcessTimedOutException $e) { + $this->printTaskWarning("Process timed out for {command}", ['command' => $process->getCommandLine(), '_style' => ['command' => 'fg=white;bg=magenta']]); + } + if (!$process->isRunning()) { + $this->advanceProgressIndicator(); + if ($this->isPrinted) { + $this->printTaskInfo("Output for {command}:\n\n{output}", ['command' => $process->getCommandLine(), 'output' => $process->getOutput(), '_style' => ['command' => 'fg=white;bg=magenta']]); + $errorOutput = $process->getErrorOutput(); + if ($errorOutput) { + $this->printTaskError(rtrim($errorOutput)); + } + } + unset($running[$k]); + } + } + if (empty($running) && empty($queue)) { + break; + } + usleep(1000); + } + $this->stopProgressIndicator(); + + $errorMessage = ''; + $exitCode = 0; + foreach ($this->processes as $p) { + if ($p->getExitCode() === 0) { + continue; + } + $errorMessage .= "'" . $p->getCommandLine() . "' exited with code ". $p->getExitCode()." \n"; + $exitCode = max($exitCode, $p->getExitCode()); + } + if (!$errorMessage) { + $this->printTaskSuccess('{process-count} processes finished running', ['process-count' => count($this->processes)]); + } + + return new Result($this, $exitCode, $errorMessage, ['time' => $this->getExecutionTime()]); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/SymfonyCommand.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/SymfonyCommand.php new file mode 100644 index 00000000..708ea845 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/SymfonyCommand.php @@ -0,0 +1,75 @@ +taskSymfonyCommand(new \Codeception\Command\Run('run')) + * ->arg('suite','acceptance') + * ->opt('debug') + * ->run(); + * + * // Artisan Command + * $this->taskSymfonyCommand(new ModelGeneratorCommand()) + * ->arg('name', 'User') + * ->run(); + * ?> + * ``` + */ +class SymfonyCommand extends BaseTask +{ + /** + * @var \Symfony\Component\Console\Command\Command + */ + protected $command; + + /** + * @var string[] + */ + protected $input; + + public function __construct(Command $command) + { + $this->command = $command; + $this->input = []; + } + + /** + * @param string $arg + * @param string $value + * + * @return $this + */ + public function arg($arg, $value) + { + $this->input[$arg] = $value; + return $this; + } + + public function opt($option, $value = null) + { + $this->input["--$option"] = $value; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running command {command}', ['command' => $this->command->getName()]); + return new Result( + $this, + $this->command->run(new ArrayInput($this->input), Robo::output()) + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Watch.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Watch.php new file mode 100644 index 00000000..d7940ac9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/Watch.php @@ -0,0 +1,89 @@ +taskWatch() + * ->monitor('composer.json', function() { + * $this->taskComposerUpdate()->run(); + * })->monitor('src', function() { + * $this->taskExec('phpunit')->run(); + * })->run(); + * ?> + * ``` + */ +class Watch extends BaseTask +{ + /** + * @var \Closure + */ + protected $closure; + + /** + * @var array + */ + protected $monitor = []; + + /** + * @var object + */ + protected $bindTo; + + /** + * @param $bindTo + */ + public function __construct($bindTo) + { + $this->bindTo = $bindTo; + } + + /** + * @param string|string[] $paths + * @param \Closure $callable + * + * @return $this + */ + public function monitor($paths, \Closure $callable) + { + if (!is_array($paths)) { + $paths = [$paths]; + } + $this->monitor[] = [$paths, $callable]; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!class_exists('Lurker\\ResourceWatcher')) { + return Result::errorMissingPackage($this, 'ResourceWatcher', 'henrikbjorn/lurker'); + } + + $watcher = new ResourceWatcher(); + + foreach ($this->monitor as $k => $monitor) { + /** @var \Closure $closure */ + $closure = $monitor[1]; + $closure->bindTo($this->bindTo); + foreach ($monitor[0] as $i => $dir) { + $watcher->track("fs.$k.$i", $dir, FilesystemEvent::MODIFY); + $this->printTaskInfo('Watching {dir} for changes...', ['dir' => $dir]); + $watcher->addListener("fs.$k.$i", $closure); + } + } + + $watcher->start(); + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadShortcuts.php new file mode 100644 index 00000000..dba0af66 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadShortcuts.php @@ -0,0 +1,17 @@ +taskExec($command)->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadTasks.php new file mode 100644 index 00000000..ab5301bb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Base/loadTasks.php @@ -0,0 +1,48 @@ +task(Exec::class, $command); + } + + /** + * @return ExecStack + */ + protected function taskExecStack() + { + return $this->task(ExecStack::class); + } + + /** + * @return ParallelExec + */ + protected function taskParallelExec() + { + return $this->task(ParallelExec::class); + } + + /** + * @param $command + * @return SymfonyCommand + */ + protected function taskSymfonyCommand($command) + { + return $this->task(SymfonyCommand::class, $command); + } + + /** + * @return Watch + */ + protected function taskWatch() + { + return $this->task(Watch::class, $this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/BaseTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/BaseTask.php new file mode 100644 index 00000000..66155c09 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/BaseTask.php @@ -0,0 +1,60 @@ +logger) { + $child->setLogger($this->logger); + } + if ($child instanceof ProgressIndicatorAwareInterface && $this->progressIndicator) { + $child->setProgressIndicator($this->progressIndicator); + } + if ($child instanceof ConfigAwareInterface && $this->getConfig()) { + $child->setConfig($this->getConfig()); + } + if ($child instanceof VerbosityThresholdInterface && $this->outputAdapter()) { + $child->setOutputAdapter($this->outputAdapter()); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Base.php new file mode 100644 index 00000000..9bc614c6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Base.php @@ -0,0 +1,88 @@ +option('allow-root'); + return $this; + } + + /** + * adds `force-latest` option to bower + * + * @return $this + */ + public function forceLatest() + { + $this->option('force-latest'); + return $this; + } + + /** + * adds `production` option to bower + * + * @return $this + */ + public function noDev() + { + $this->option('production'); + return $this; + } + + /** + * adds `offline` option to bower + * + * @return $this + */ + public function offline() + { + $this->option('offline'); + return $this; + } + + /** + * Base constructor. + * + * @param null|string $pathToBower + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToBower = null) + { + $this->command = $pathToBower; + if (!$this->command) { + $this->command = $this->findExecutable('bower'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Bower executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Install.php new file mode 100644 index 00000000..c3c0ce75 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Install.php @@ -0,0 +1,36 @@ +taskBowerInstall()->run(); + * + * // prefer dist with custom path + * $this->taskBowerInstall('path/to/my/bower') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Install extends Base implements CommandInterface +{ + /** + * {@inheritdoc} + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Install Bower packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Update.php new file mode 100644 index 00000000..f0dfa94e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/Update.php @@ -0,0 +1,34 @@ +taskBowerUpdate->run(); + * + * // prefer dist with custom path + * $this->taskBowerUpdate('path/to/my/bower') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Update Bower packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/loadTasks.php new file mode 100644 index 00000000..6e33f8ac --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Bower/loadTasks.php @@ -0,0 +1,25 @@ +task(Install::class, $pathToBower); + } + + /** + * @param null|string $pathToBower + * + * @return Update + */ + protected function taskBowerUpdate($pathToBower = null) + { + return $this->task(Update::class, $pathToBower); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/CommandStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/CommandStack.php new file mode 100644 index 00000000..f1cb4492 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/CommandStack.php @@ -0,0 +1,134 @@ +exec); + } + + /** + * @param string $executable + * + * @return $this + */ + public function executable($executable) + { + $this->executable = $executable; + return $this; + } + + /** + * @param string|string[] $command + * + * @return $this + */ + public function exec($command) + { + if (is_array($command)) { + $command = implode(' ', array_filter($command)); + } + + $command = $this->executable . ' ' . $this->stripExecutableFromCommand($command); + $this->exec[] = trim($command); + return $this; + } + + /** + * @param bool $stopOnFail + * + * @return $this + */ + public function stopOnFail($stopOnFail = true) + { + $this->stopOnFail = $stopOnFail; + return $this; + } + + public function result($result) + { + $this->result = $result; + return $this; + } + + /** + * @param string $command + * + * @return string + */ + protected function stripExecutableFromCommand($command) + { + $command = trim($command); + $executable = $this->executable . ' '; + if (strpos($command, $executable) === 0) { + $command = substr($command, strlen($executable)); + } + return $command; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->exec)) { + throw new TaskException($this, 'You must add at least one command'); + } + // If 'stopOnFail' is not set, or if there is only one command to run, + // then execute the single command to run. + if (!$this->stopOnFail || (count($this->exec) == 1)) { + $this->printTaskInfo('{command}', ['command' => $this->getCommand()]); + return $this->executeCommand($this->getCommand()); + } + + // When executing multiple commands in 'stopOnFail' mode, run them + // one at a time so that the result will have the exact command + // that failed available to the caller. This is at the expense of + // losing the output from all successful commands. + $data = []; + $message = ''; + $result = null; + foreach ($this->exec as $command) { + $this->printTaskInfo("Executing {command}", ['command' => $command]); + $result = $this->executeCommand($command); + $result->accumulateExecutionTime($data); + $message = $result->accumulateMessage($message); + $data = $result->mergeData($data); + if (!$result->wasSuccessful()) { + return $result; + } + } + + return $result; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Base.php new file mode 100644 index 00000000..de3fe217 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Base.php @@ -0,0 +1,248 @@ +command = $pathToComposer; + if (!$this->command) { + $this->command = $this->findExecutablePhar('composer'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Neither local composer.phar nor global composer installation could be found."); + } + } + + /** + * adds `prefer-dist` option to composer + * + * @return $this + */ + public function preferDist($preferDist = true) + { + if (!$preferDist) { + return $this->preferSource(); + } + $this->prefer = '--prefer-dist'; + return $this; + } + + /** + * adds `prefer-source` option to composer + * + * @return $this + */ + public function preferSource() + { + $this->prefer = '--prefer-source'; + return $this; + } + + /** + * adds `dev` option to composer + * + * @return $this + */ + public function dev($dev = true) + { + if (!$dev) { + return $this->noDev(); + } + $this->dev = '--dev'; + return $this; + } + + /** + * adds `no-dev` option to composer + * + * @return $this + */ + public function noDev() + { + $this->dev = '--no-dev'; + return $this; + } + + /** + * adds `ansi` option to composer + * + * @return $this + */ + public function ansi($ansi = true) + { + if (!$ansi) { + return $this->noAnsi(); + } + $this->ansi = '--ansi'; + return $this; + } + + /** + * adds `no-ansi` option to composer + * + * @return $this + */ + public function noAnsi() + { + $this->ansi = '--no-ansi'; + return $this; + } + + public function interaction($interaction = true) + { + if (!$interaction) { + return $this->noInteraction(); + } + return $this; + } + + /** + * adds `no-interaction` option to composer + * + * @return $this + */ + public function noInteraction() + { + $this->nointeraction = '--no-interaction'; + return $this; + } + + /** + * adds `optimize-autoloader` option to composer + * + * @return $this + */ + public function optimizeAutoloader($optimize = true) + { + if ($optimize) { + $this->option('--optimize-autoloader'); + } + return $this; + } + + /** + * adds `ignore-platform-reqs` option to composer + * + * @return $this + */ + public function ignorePlatformRequirements($ignore = true) + { + $this->option('--ignore-platform-reqs'); + return $this; + } + + /** + * disable plugins + * + * @return $this + */ + public function disablePlugins($disable = true) + { + if ($disable) { + $this->option('--no-plugins'); + } + return $this; + } + + /** + * skip scripts + * + * @return $this + */ + public function noScripts($disable = true) + { + if ($disable) { + $this->option('--no-scripts'); + } + return $this; + } + + /** + * adds `--working-dir $dir` option to composer + * + * @return $this + */ + public function workingDir($dir) + { + $this->option("--working-dir", $dir); + return $this; + } + + /** + * Copy class fields into command options as directed. + */ + public function buildCommand() + { + if (!isset($this->ansi) && $this->getConfig()->get(\Robo\Config\Config::DECORATED)) { + $this->ansi(); + } + if (!isset($this->nointeraction) && !$this->getConfig()->get(\Robo\Config\Config::INTERACTIVE)) { + $this->noInteraction(); + } + $this->option($this->prefer) + ->option($this->dev) + ->option($this->nointeraction) + ->option($this->ansi); + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + if (!$this->built) { + $this->buildCommand(); + $this->built = true; + } + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Config.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Config.php new file mode 100644 index 00000000..b5a6bbff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Config.php @@ -0,0 +1,93 @@ +taskComposerConfig()->set('bin-dir', 'bin/')->run(); + * ?> + * ``` + */ +class Config extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'config'; + + /** + * Set a configuration value + * @return $this + */ + public function set($key, $value) + { + $this->arg($key); + $this->arg($value); + return $this; + } + + /** + * Operate on the global repository + * @return $this + */ + public function useGlobal($useGlobal = true) + { + if ($useGlobal) { + $this->option('global'); + } + return $this; + } + + /** + * @return $this + */ + public function repository($id, $uri, $repoType = 'vcs') + { + $this->arg("repositories.$id"); + $this->arg($repoType); + $this->arg($uri); + return $this; + } + + /** + * @return $this + */ + public function removeRepository($id) + { + $this->option('unset', "repositories.$id"); + return $this; + } + + /** + * @return $this + */ + public function disableRepository($id) + { + $this->arg("repositories.$id"); + $this->arg('false'); + return $this; + } + + /** + * @return $this + */ + public function enableRepository($id) + { + $this->arg("repositories.$id"); + $this->arg('true'); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Configuring composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/CreateProject.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/CreateProject.php new file mode 100644 index 00000000..5f979a64 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/CreateProject.php @@ -0,0 +1,112 @@ +taskComposerCreateProject()->source('foo/bar')->target('myBar')->run(); + * ?> + * ``` + */ +class CreateProject extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'create-project'; + + protected $source; + protected $target = ''; + protected $version = ''; + + /** + * @return $this + */ + public function source($source) + { + $this->source = $source; + return $this; + } + + /** + * @return $this + */ + public function target($target) + { + $this->target = $target; + return $this; + } + + /** + * @return $this + */ + public function version($version) + { + $this->version = $version; + return $this; + } + + public function keepVcs($keep = true) + { + if ($keep) { + $this->option('--keep-vcs'); + } + return $this; + } + + public function noInstall($noInstall = true) + { + if ($noInstall) { + $this->option('--no-install'); + } + return $this; + } + + /** + * @return $this + */ + public function repository($repository) + { + if (!empty($repository)) { + $this->option('repository', $repository); + } + return $this; + } + + /** + * @return $this + */ + public function stability($stability) + { + if (!empty($stability)) { + $this->option('stability', $stability); + } + return $this; + } + + public function buildCommand() + { + $this->arg($this->source); + if (!empty($this->target)) { + $this->arg($this->target); + } + if (!empty($this->version)) { + $this->arg($this->version); + } + + return parent::buildCommand(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Creating project: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/DumpAutoload.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/DumpAutoload.php new file mode 100644 index 00000000..55b1ea00 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/DumpAutoload.php @@ -0,0 +1,62 @@ +taskComposerDumpAutoload()->run(); + * + * // dump auto loader with custom path + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader dump with custom path + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->optimize() + * ->run(); + * + * // optimize autoloader dump with custom path and no dev + * $this->taskComposerDumpAutoload('path/to/my/composer.phar') + * ->optimize() + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class DumpAutoload extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'dump-autoload'; + + /** + * @var string + */ + protected $optimize; + + /** + * @return $this + */ + public function optimize($optimize = true) + { + if ($optimize) { + $this->option("--optimize"); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Dumping Autoloader: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Init.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Init.php new file mode 100644 index 00000000..c841299d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Init.php @@ -0,0 +1,115 @@ +taskComposerInit()->run(); + * ?> + * ``` + */ +class Init extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'init'; + + /** + * @return $this + */ + public function projectName($projectName) + { + $this->option('name', $projectName); + return $this; + } + + /** + * @return $this + */ + public function description($description) + { + $this->option('description', $description); + return $this; + } + + /** + * @return $this + */ + public function author($author) + { + $this->option('author', $author); + return $this; + } + + /** + * @return $this + */ + public function projectType($type) + { + $this->option('type', $type); + return $this; + } + + /** + * @return $this + */ + public function homepage($homepage) + { + $this->option('homepage', $homepage); + return $this; + } + + /** + * 'require' is a keyword, so it cannot be a method name. + * @return $this + */ + public function dependency($project, $version = null) + { + if (isset($version)) { + $project .= ":$version"; + } + $this->option('require', $project); + return $this; + } + + /** + * @return $this + */ + public function stability($stability) + { + $this->option('stability', $stability); + return $this; + } + + /** + * @return $this + */ + public function license($license) + { + $this->option('license', $license); + return $this; + } + + /** + * @return $this + */ + public function repository($repository) + { + $this->option('repository', $repository); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Creating composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Install.php new file mode 100644 index 00000000..76cb9861 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Install.php @@ -0,0 +1,40 @@ +taskComposerInstall()->run(); + * + * // prefer dist with custom path + * $this->taskComposerInstall('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader with custom path + * $this->taskComposerInstall('path/to/my/composer.phar') + * ->optimizeAutoloader() + * ->run(); + * ?> + * ``` + */ +class Install extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Installing Packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Remove.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Remove.php new file mode 100644 index 00000000..b0316f05 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Remove.php @@ -0,0 +1,85 @@ +taskComposerRemove()->run(); + * ?> + * ``` + */ +class Remove extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'remove'; + + /** + * @return $this + */ + public function dev($dev = true) + { + if ($dev) { + $this->option('--dev'); + } + return $this; + } + + /** + * @return $this + */ + public function noProgress($noProgress = true) + { + if ($noProgress) { + $this->option('--no-progress'); + } + return $this; + } + + /** + * @return $this + */ + public function noUpdate($noUpdate = true) + { + if ($noUpdate) { + $this->option('--no-update'); + } + return $this; + } + + /** + * @return $this + */ + public function updateNoDev($updateNoDev = true) + { + if ($updateNoDev) { + $this->option('--update-no-dev'); + } + return $this; + } + + /** + * @return $this + */ + public function noUpdateWithDependencies($updateWithDependencies = true) + { + if ($updateWithDependencies) { + $this->option('--no-update-with-dependencies'); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Removing packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/RequireDependency.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/RequireDependency.php new file mode 100644 index 00000000..6cdbf613 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/RequireDependency.php @@ -0,0 +1,50 @@ +taskComposerRequire()->dependency('foo/bar', '^.2.4.8')->run(); + * ?> + * ``` + */ +class RequireDependency extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'require'; + + /** + * 'require' is a keyword, so it cannot be a method name. + * @return $this + */ + public function dependency($project, $version = null) + { + $project = (array)$project; + + if (isset($version)) { + $project = array_map( + function ($item) use ($version) { + return "$item:$version"; + }, + $project + ); + } + $this->args($project); + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Requiring packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Update.php new file mode 100644 index 00000000..3a0a64af --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Update.php @@ -0,0 +1,40 @@ +taskComposerUpdate()->run(); + * + * // prefer dist with custom path + * $this->taskComposerUpdate('path/to/my/composer.phar') + * ->preferDist() + * ->run(); + * + * // optimize autoloader with custom path + * $this->taskComposerUpdate('path/to/my/composer.phar') + * ->optimizeAutoloader() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Updating Packages: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Validate.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Validate.php new file mode 100644 index 00000000..adb15854 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/Validate.php @@ -0,0 +1,85 @@ +taskComposerValidate()->run(); + * ?> + * ``` + */ +class Validate extends Base +{ + /** + * {@inheritdoc} + */ + protected $action = 'validate'; + + /** + * @return $this + */ + public function noCheckAll($noCheckAll = true) + { + if ($noCheckAll) { + $this->option('--no-check-all'); + } + return $this; + } + + /** + * @return $this + */ + public function noCheckLock($noCheckLock = true) + { + if ($noCheckLock) { + $this->option('--no-check-lock'); + } + return $this; + } + + /** + * @return $this + */ + public function noCheckPublish($noCheckPublish = true) + { + if ($noCheckPublish) { + $this->option('--no-check-publish'); + } + return $this; + } + + /** + * @return $this + */ + public function withDependencies($withDependencies = true) + { + if ($withDependencies) { + $this->option('--with-dependencies'); + } + return $this; + } + + /** + * @return $this + */ + public function strict($strict = true) + { + if ($strict) { + $this->option('--strict'); + } + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Validating composer.json: {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/loadTasks.php new file mode 100644 index 00000000..6b074ba3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Composer/loadTasks.php @@ -0,0 +1,95 @@ +task(Install::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Update + */ + protected function taskComposerUpdate($pathToComposer = null) + { + return $this->task(Update::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return DumpAutoload + */ + protected function taskComposerDumpAutoload($pathToComposer = null) + { + return $this->task(DumpAutoload::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Init + */ + protected function taskComposerInit($pathToComposer = null) + { + return $this->task(Init::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Init + */ + protected function taskComposerConfig($pathToComposer = null) + { + return $this->task(Config::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Validate + */ + protected function taskComposerValidate($pathToComposer = null) + { + return $this->task(Validate::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerRemove($pathToComposer = null) + { + return $this->task(Remove::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerRequire($pathToComposer = null) + { + return $this->task(RequireDependency::class, $pathToComposer); + } + + /** + * @param null|string $pathToComposer + * + * @return Remove + */ + protected function taskComposerCreateProject($pathToComposer = null) + { + return $this->task(CreateProject::class, $pathToComposer); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/Changelog.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/Changelog.php new file mode 100644 index 00000000..44af6d82 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/Changelog.php @@ -0,0 +1,246 @@ +taskChangelog() + * ->version($version) + * ->change("released to github") + * ->run(); + * ?> + * ``` + * + * Changes can be asked from Console + * + * ``` php + * taskChangelog() + * ->version($version) + * ->askForChanges() + * ->run(); + * ?> + * ``` + */ +class Changelog extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $filename; + + /** + * @var array + */ + protected $log = []; + + /** + * @var string + */ + protected $anchor = "# Changelog"; + + /** + * @var string + */ + protected $version = ""; + + /** + * @var string + */ + protected $body = ""; + + /** + * @var string + */ + protected $header = ""; + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * Sets the changelog body text. + * + * This method permits the raw changelog text to be set directly If this is set, $this->log changes will be ignored. + * + * @param string $body + * + * @return $this + */ + public function setBody($body) + { + $this->body = $body; + return $this; + } + + /** + * @param string $header + * + * @return $this + */ + public function setHeader($header) + { + $this->header = $header; + return $this; + } + + /** + * @param string $item + * + * @return $this + */ + public function log($item) + { + $this->log[] = $item; + return $this; + } + + /** + * @param string $anchor + * + * @return $this + */ + public function anchor($anchor) + { + $this->anchor = $anchor; + return $this; + } + + /** + * @param string $version + * + * @return $this + */ + public function version($version) + { + $this->version = $version; + return $this; + } + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param array $data + * + * @return $this + */ + public function changes(array $data) + { + $this->log = array_merge($this->log, $data); + return $this; + } + + /** + * @param string $change + * + * @return $this + */ + public function change($change) + { + $this->log[] = $change; + return $this; + } + + /** + * @return array + */ + public function getChanges() + { + return $this->log; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (empty($this->body)) { + if (empty($this->log)) { + return Result::error($this, "Changelog is empty"); + } + $this->body = $this->generateBody(); + } + if (empty($this->header)) { + $this->header = $this->generateHeader(); + } + + $text = $this->header . $this->body; + + if (!file_exists($this->filename)) { + $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]); + $res = file_put_contents($this->filename, $this->anchor); + if ($res === false) { + return Result::error($this, "File {filename} cant be created", ['filename' => $this->filename]); + } + } + + /** @var \Robo\Result $result */ + // trying to append to changelog for today + $result = $this->collectionBuilder()->taskReplaceInFile($this->filename) + ->from($this->header) + ->to($text) + ->run(); + + if (!isset($result['replaced']) || !$result['replaced']) { + $result = $this->collectionBuilder()->taskReplaceInFile($this->filename) + ->from($this->anchor) + ->to($this->anchor . "\n\n" . $text) + ->run(); + } + + return new Result($this, $result->getExitCode(), $result->getMessage(), $this->log); + } + + /** + * @return \Robo\Result|string + */ + protected function generateBody() + { + $text = implode("\n", array_map([$this, 'processLogRow'], $this->log)); + $text .= "\n"; + + return $text; + } + + /** + * @return string + */ + protected function generateHeader() + { + return "#### {$this->version}\n\n"; + } + + /** + * @param $i + * + * @return string + */ + public function processLogRow($i) + { + return "* $i *" . date('Y-m-d') . "*"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateMarkdownDoc.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateMarkdownDoc.php new file mode 100644 index 00000000..0c3ec26c --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateMarkdownDoc.php @@ -0,0 +1,782 @@ +taskGenDoc('models.md') + * ->docClass('Model\User') // take class Model\User + * ->docClass('Model\Post') // take class Model\Post + * ->filterMethods(function(\ReflectionMethod $r) { + * return $r->isPublic() or $r->isProtected(); // process public and protected methods + * })->processClass(function(\ReflectionClass $r, $text) { + * return "Class ".$r->getName()."\n\n$text\n\n###Methods\n"; + * })->run(); + * ``` + * + * By default this task generates a documentation for each public method of a class. + * It combines method signature with a docblock. Both can be post-processed. + * + * ``` php + * taskGenDoc('models.md') + * ->docClass('Model\User') + * ->processClassSignature(false) // false can be passed to not include class signature + * ->processClassDocBlock(function(\ReflectionClass $r, $text) { + * return "[This is part of application model]\n" . $text; + * })->processMethodSignature(function(\ReflectionMethod $r, $text) { + * return "#### {$r->name}()"; + * })->processMethodDocBlock(function(\ReflectionMethod $r, $text) { + * return strpos($r->name, 'save')===0 ? "[Saves to the database]\n" . $text : $text; + * })->run(); + * ``` + */ +class GenerateMarkdownDoc extends BaseTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string[] + */ + protected $docClass = []; + + /** + * @var callable + */ + protected $filterMethods; + + /** + * @var callable + */ + protected $filterClasses; + + /** + * @var callable + */ + protected $filterProperties; + + /** + * @var callable + */ + protected $processClass; + + /** + * @var callable|false + */ + protected $processClassSignature; + + /** + * @var callable|false + */ + protected $processClassDocBlock; + + /** + * @var callable|false + */ + protected $processMethod; + + /** + * @var callable|false + */ + protected $processMethodSignature; + + /** + * @var callable|false + */ + protected $processMethodDocBlock; + + /** + * @var callable|false + */ + protected $processProperty; + + /** + * @var callable|false + */ + protected $processPropertySignature; + + /** + * @var callable|false + */ + protected $processPropertyDocBlock; + + /** + * @var callable + */ + protected $reorder; + + /** + * @var callable + */ + protected $reorderMethods; + + /** + * @todo Unused property. + * + * @var callable + */ + protected $reorderProperties; + + /** + * @var string + */ + protected $filename; + + /** + * @var string + */ + protected $prepend = ""; + + /** + * @var string + */ + protected $append = ""; + + /** + * @var string + */ + protected $text; + + /** + * @var string[] + */ + protected $textForClass = []; + + /** + * @param string $filename + * + * @return static + */ + public static function init($filename) + { + return new static($filename); + } + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * Put a class you want to be documented. + * + * @param string $item + * + * @return $this + */ + public function docClass($item) + { + $this->docClass[] = $item; + return $this; + } + + /** + * Using a callback function filter out methods that won't be documented. + * + * @param callable $filterMethods + * + * @return $this + */ + public function filterMethods($filterMethods) + { + $this->filterMethods = $filterMethods; + return $this; + } + + /** + * Using a callback function filter out classes that won't be documented. + * + * @param callable $filterClasses + * + * @return $this + */ + public function filterClasses($filterClasses) + { + $this->filterClasses = $filterClasses; + return $this; + } + + /** + * Using a callback function filter out properties that won't be documented. + * + * @param callable $filterProperties + * + * @return $this + */ + public function filterProperties($filterProperties) + { + $this->filterProperties = $filterProperties; + return $this; + } + + /** + * Post-process class documentation. + * + * @param callable $processClass + * + * @return $this + */ + public function processClass($processClass) + { + $this->processClass = $processClass; + return $this; + } + + /** + * Post-process class signature. Provide *false* to skip. + * + * @param callable|false $processClassSignature + * + * @return $this + */ + public function processClassSignature($processClassSignature) + { + $this->processClassSignature = $processClassSignature; + return $this; + } + + /** + * Post-process class docblock contents. Provide *false* to skip. + * + * @param callable|false $processClassDocBlock + * + * @return $this + */ + public function processClassDocBlock($processClassDocBlock) + { + $this->processClassDocBlock = $processClassDocBlock; + return $this; + } + + /** + * Post-process method documentation. Provide *false* to skip. + * + * @param callable|false $processMethod + * + * @return $this + */ + public function processMethod($processMethod) + { + $this->processMethod = $processMethod; + return $this; + } + + /** + * Post-process method signature. Provide *false* to skip. + * + * @param callable|false $processMethodSignature + * + * @return $this + */ + public function processMethodSignature($processMethodSignature) + { + $this->processMethodSignature = $processMethodSignature; + return $this; + } + + /** + * Post-process method docblock contents. Provide *false* to skip. + * + * @param callable|false $processMethodDocBlock + * + * @return $this + */ + public function processMethodDocBlock($processMethodDocBlock) + { + $this->processMethodDocBlock = $processMethodDocBlock; + return $this; + } + + /** + * Post-process property documentation. Provide *false* to skip. + * + * @param callable|false $processProperty + * + * @return $this + */ + public function processProperty($processProperty) + { + $this->processProperty = $processProperty; + return $this; + } + + /** + * Post-process property signature. Provide *false* to skip. + * + * @param callable|false $processPropertySignature + * + * @return $this + */ + public function processPropertySignature($processPropertySignature) + { + $this->processPropertySignature = $processPropertySignature; + return $this; + } + + /** + * Post-process property docblock contents. Provide *false* to skip. + * + * @param callable|false $processPropertyDocBlock + * + * @return $this + */ + public function processPropertyDocBlock($processPropertyDocBlock) + { + $this->processPropertyDocBlock = $processPropertyDocBlock; + return $this; + } + + /** + * Use a function to reorder classes. + * + * @param callable $reorder + * + * @return $this + */ + public function reorder($reorder) + { + $this->reorder = $reorder; + return $this; + } + + /** + * Use a function to reorder methods in class. + * + * @param callable $reorderMethods + * + * @return $this + */ + public function reorderMethods($reorderMethods) + { + $this->reorderMethods = $reorderMethods; + return $this; + } + + /** + * @param callable $reorderProperties + * + * @return $this + */ + public function reorderProperties($reorderProperties) + { + $this->reorderProperties = $reorderProperties; + return $this; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * Inserts text at the beginning of markdown file. + * + * @param string $prepend + * + * @return $this + */ + public function prepend($prepend) + { + $this->prepend = $prepend; + return $this; + } + + /** + * Inserts text at the end of markdown file. + * + * @param string $append + * + * @return $this + */ + public function append($append) + { + $this->append = $append; + return $this; + } + + /** + * @param string $text + * + * @return $this + */ + public function text($text) + { + $this->text = $text; + return $this; + } + + /** + * @param string $item + * + * @return $this + */ + public function textForClass($item) + { + $this->textForClass[] = $item; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + foreach ($this->docClass as $class) { + $this->printTaskInfo("Processing {class}", ['class' => $class]); + $this->textForClass[$class] = $this->documentClass($class); + } + + if (is_callable($this->reorder)) { + $this->printTaskInfo("Applying reorder function"); + call_user_func_array($this->reorder, [$this->textForClass]); + } + + $this->text = implode("\n", $this->textForClass); + + /** @var \Robo\Result $result */ + $result = $this->collectionBuilder()->taskWriteToFile($this->filename) + ->line($this->prepend) + ->text($this->text) + ->line($this->append) + ->run(); + + $this->printTaskSuccess('{filename} created. {class-count} classes documented', ['filename' => $this->filename, 'class-count' => count($this->docClass)]); + + return new Result($this, $result->getExitCode(), $result->getMessage(), $this->textForClass); + } + + /** + * @param string $class + * + * @return null|string + */ + protected function documentClass($class) + { + if (!class_exists($class)) { + return ""; + } + $refl = new \ReflectionClass($class); + + if (is_callable($this->filterClasses)) { + $ret = call_user_func($this->filterClasses, $refl); + if (!$ret) { + return; + } + } + $doc = $this->documentClassSignature($refl); + $doc .= "\n" . $this->documentClassDocBlock($refl); + $doc .= "\n"; + + if (is_callable($this->processClass)) { + $doc = call_user_func($this->processClass, $refl, $doc); + } + + $properties = []; + foreach ($refl->getProperties() as $reflProperty) { + $properties[] = $this->documentProperty($reflProperty); + } + + $properties = array_filter($properties); + $doc .= implode("\n", $properties); + + $methods = []; + foreach ($refl->getMethods() as $reflMethod) { + $methods[$reflMethod->name] = $this->documentMethod($reflMethod); + } + if (is_callable($this->reorderMethods)) { + call_user_func_array($this->reorderMethods, [&$methods]); + } + + $methods = array_filter($methods); + + $doc .= implode("\n", $methods)."\n"; + + return $doc; + } + + /** + * @param \ReflectionClass $reflectionClass + * + * @return string + */ + protected function documentClassSignature(\ReflectionClass $reflectionClass) + { + if ($this->processClassSignature === false) { + return ""; + } + + $signature = "## {$reflectionClass->name}\n\n"; + + if ($parent = $reflectionClass->getParentClass()) { + $signature .= "* *Extends* `{$parent->name}`"; + } + $interfaces = $reflectionClass->getInterfaceNames(); + if (count($interfaces)) { + $signature .= "\n* *Implements* `" . implode('`, `', $interfaces) . '`'; + } + $traits = $reflectionClass->getTraitNames(); + if (count($traits)) { + $signature .= "\n* *Uses* `" . implode('`, `', $traits) . '`'; + } + if (is_callable($this->processClassSignature)) { + $signature = call_user_func($this->processClassSignature, $reflectionClass, $signature); + } + + return $signature; + } + + /** + * @param \ReflectionClass $reflectionClass + * + * @return string + */ + protected function documentClassDocBlock(\ReflectionClass $reflectionClass) + { + if ($this->processClassDocBlock === false) { + return ""; + } + $doc = self::indentDoc($reflectionClass->getDocComment()); + if (is_callable($this->processClassDocBlock)) { + $doc = call_user_func($this->processClassDocBlock, $reflectionClass, $doc); + } + return $doc; + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethod(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethod === false) { + return ""; + } + if (is_callable($this->filterMethods)) { + $ret = call_user_func($this->filterMethods, $reflectedMethod); + if (!$ret) { + return ""; + } + } else { + if (!$reflectedMethod->isPublic()) { + return ""; + } + } + + $signature = $this->documentMethodSignature($reflectedMethod); + $docblock = $this->documentMethodDocBlock($reflectedMethod); + $methodDoc = "$signature $docblock"; + if (is_callable($this->processMethod)) { + $methodDoc = call_user_func($this->processMethod, $reflectedMethod, $methodDoc); + } + return $methodDoc; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentProperty(\ReflectionProperty $reflectedProperty) + { + if ($this->processProperty === false) { + return ""; + } + if (is_callable($this->filterProperties)) { + $ret = call_user_func($this->filterProperties, $reflectedProperty); + if (!$ret) { + return ""; + } + } else { + if (!$reflectedProperty->isPublic()) { + return ""; + } + } + $signature = $this->documentPropertySignature($reflectedProperty); + $docblock = $this->documentPropertyDocBlock($reflectedProperty); + $propertyDoc = $signature . $docblock; + if (is_callable($this->processProperty)) { + $propertyDoc = call_user_func($this->processProperty, $reflectedProperty, $propertyDoc); + } + return $propertyDoc; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentPropertySignature(\ReflectionProperty $reflectedProperty) + { + if ($this->processPropertySignature === false) { + return ""; + } + $modifiers = implode(' ', \Reflection::getModifierNames($reflectedProperty->getModifiers())); + $signature = "#### *$modifiers* {$reflectedProperty->name}"; + if (is_callable($this->processPropertySignature)) { + $signature = call_user_func($this->processPropertySignature, $reflectedProperty, $signature); + } + return $signature; + } + + /** + * @param \ReflectionProperty $reflectedProperty + * + * @return string + */ + protected function documentPropertyDocBlock(\ReflectionProperty $reflectedProperty) + { + if ($this->processPropertyDocBlock === false) { + return ""; + } + $propertyDoc = $reflectedProperty->getDocComment(); + // take from parent + if (!$propertyDoc) { + $parent = $reflectedProperty->getDeclaringClass(); + while ($parent = $parent->getParentClass()) { + if ($parent->hasProperty($reflectedProperty->name)) { + $propertyDoc = $parent->getProperty($reflectedProperty->name)->getDocComment(); + } + } + } + $propertyDoc = self::indentDoc($propertyDoc, 7); + $propertyDoc = preg_replace("~^@(.*?)([$\s])~", ' * `$1` $2', $propertyDoc); // format annotations + if (is_callable($this->processPropertyDocBlock)) { + $propertyDoc = call_user_func($this->processPropertyDocBlock, $reflectedProperty, $propertyDoc); + } + return ltrim($propertyDoc); + } + + /** + * @param \ReflectionParameter $param + * + * @return string + */ + protected function documentParam(\ReflectionParameter $param) + { + $text = ""; + if ($param->isArray()) { + $text .= 'array '; + } + if ($param->isCallable()) { + $text .= 'callable '; + } + $text .= '$' . $param->name; + if ($param->isDefaultValueAvailable()) { + if ($param->allowsNull()) { + $text .= ' = null'; + } else { + $text .= ' = ' . str_replace("\n", ' ', print_r($param->getDefaultValue(), true)); + } + } + + return $text; + } + + /** + * @param string $doc + * @param int $indent + * + * @return string + */ + public static function indentDoc($doc, $indent = 3) + { + if (!$doc) { + return $doc; + } + return implode( + "\n", + array_map( + function ($line) use ($indent) { + return substr($line, $indent); + }, + explode("\n", $doc) + ) + ); + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethodSignature(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethodSignature === false) { + return ""; + } + $modifiers = implode(' ', \Reflection::getModifierNames($reflectedMethod->getModifiers())); + $params = implode( + ', ', + array_map( + function ($p) { + return $this->documentParam($p); + }, + $reflectedMethod->getParameters() + ) + ); + $signature = "#### *$modifiers* {$reflectedMethod->name}($params)"; + if (is_callable($this->processMethodSignature)) { + $signature = call_user_func($this->processMethodSignature, $reflectedMethod, $signature); + } + return $signature; + } + + /** + * @param \ReflectionMethod $reflectedMethod + * + * @return string + */ + protected function documentMethodDocBlock(\ReflectionMethod $reflectedMethod) + { + if ($this->processMethodDocBlock === false) { + return ""; + } + $methodDoc = $reflectedMethod->getDocComment(); + // take from parent + if (!$methodDoc) { + $parent = $reflectedMethod->getDeclaringClass(); + while ($parent = $parent->getParentClass()) { + if ($parent->hasMethod($reflectedMethod->name)) { + $methodDoc = $parent->getMethod($reflectedMethod->name)->getDocComment(); + } + } + } + // take from interface + if (!$methodDoc) { + $interfaces = $reflectedMethod->getDeclaringClass()->getInterfaces(); + foreach ($interfaces as $interface) { + $i = new \ReflectionClass($interface->name); + if ($i->hasMethod($reflectedMethod->name)) { + $methodDoc = $i->getMethod($reflectedMethod->name)->getDocComment(); + break; + } + } + } + + $methodDoc = self::indentDoc($methodDoc, 7); + $methodDoc = preg_replace("~^@(.*?) ([$\s])~m", ' * `$1` $2', $methodDoc); // format annotations + if (is_callable($this->processMethodDocBlock)) { + $methodDoc = call_user_func($this->processMethodDocBlock, $reflectedMethod, $methodDoc); + } + + return $methodDoc; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateTask.php new file mode 100644 index 00000000..9d7a698e --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GenerateTask.php @@ -0,0 +1,107 @@ +taskGenerateTask('Symfony\Component\Filesystem\Filesystem', 'FilesystemStack') + * ->run(); + * ``` + */ +class GenerateTask extends BaseTask +{ + /** + * @var string + */ + protected $className; + + /** + * @var string + */ + protected $wrapperClassName; + + /** + * @param string $className + * @param string $wrapperClassName + */ + public function __construct($className, $wrapperClassName = '') + { + $this->className = $className; + $this->wrapperClassName = $wrapperClassName; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $delegate = new \ReflectionClass($this->className); + $replacements = []; + + $leadingCommentChars = " * "; + $methodDescriptions = []; + $methodImplementations = []; + $immediateMethods = []; + foreach ($delegate->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { + $methodName = $method->name; + $getter = preg_match('/^(get|has|is)/', $methodName); + $setter = preg_match('/^(set|unset)/', $methodName); + $argPrototypeList = []; + $argNameList = []; + $needsImplementation = false; + foreach ($method->getParameters() as $arg) { + $argDescription = '$' . $arg->name; + $argNameList[] = $argDescription; + if ($arg->isOptional()) { + $argDescription = $argDescription . ' = ' . str_replace("\n", "", var_export($arg->getDefaultValue(), true)); + // We will create wrapper methods for any method that + // has default parameters. + $needsImplementation = true; + } + $argPrototypeList[] = $argDescription; + } + $argPrototypeString = implode(', ', $argPrototypeList); + $argNameListString = implode(', ', $argNameList); + + if ($methodName[0] != '_') { + $methodDescriptions[] = "@method $methodName($argPrototypeString)"; + + if ($getter) { + $immediateMethods[] = " public function $methodName($argPrototypeString)\n {\n return \$this->delegate->$methodName($argNameListString);\n }"; + } elseif ($setter) { + $immediateMethods[] = " public function $methodName($argPrototypeString)\n {\n \$this->delegate->$methodName($argNameListString);\n return \$this;\n }"; + } elseif ($needsImplementation) { + // Include an implementation for the wrapper method if necessary + $methodImplementations[] = " protected function _$methodName($argPrototypeString)\n {\n \$this->delegate->$methodName($argNameListString);\n }"; + } + } + } + + $classNameParts = explode('\\', $this->className); + $delegate = array_pop($classNameParts); + $delegateNamespace = implode('\\', $classNameParts); + + if (empty($this->wrapperClassName)) { + $this->wrapperClassName = $delegate; + } + + $replacements['{delegateNamespace}'] = $delegateNamespace; + $replacements['{delegate}'] = $delegate; + $replacements['{wrapperClassName}'] = $this->wrapperClassName; + $replacements['{taskname}'] = "task$delegate"; + $replacements['{methodList}'] = $leadingCommentChars . implode("\n$leadingCommentChars", $methodDescriptions); + $replacements['{immediateMethods}'] = "\n\n" . implode("\n\n", $immediateMethods); + $replacements['{methodImplementations}'] = "\n\n" . implode("\n\n", $methodImplementations); + + $template = file_get_contents(__DIR__ . '/../../../data/Task/Development/GeneratedWrapper.tmpl'); + $template = str_replace(array_keys($replacements), array_values($replacements), $template); + + // Returning data in the $message will cause it to be printed. + return Result::success($this, $template); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHub.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHub.php new file mode 100644 index 00000000..9fc9909d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHub.php @@ -0,0 +1,157 @@ +repo = $repo; + return $this; + } + + /** + * @param string $owner + * + * @return $this + */ + public function owner($owner) + { + $this->owner = $owner; + return $this; + } + + /** + * @param string $uri + * + * @return $this + */ + public function uri($uri) + { + list($this->owner, $this->repo) = explode('/', $uri); + return $this; + } + + /** + * @return string + */ + protected function getUri() + { + return $this->owner . '/' . $this->repo; + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + $this->user = $user; + return $this; + } + + /** + * @param $password + * + * @return $this + */ + public function password($password) + { + $this->password = $password; + return $this; + } + + /** + * @param $accessToken + * + * @return $this + */ + public function accessToken($token) + { + $this->accessToken = $token; + return $this; + } + + /** + * @param string $uri + * @param array $params + * @param string $method + * + * @return array + * + * @throws \Robo\Exception\TaskException + */ + protected function sendRequest($uri, $params = [], $method = 'POST') + { + if (!$this->owner or !$this->repo) { + throw new TaskException($this, 'Repo URI is not set'); + } + + $ch = curl_init(); + $url = sprintf('%s/repos/%s/%s', self::GITHUB_URL, $this->getUri(), $uri); + $this->printTaskInfo($url); + $this->printTaskInfo('{method} {url}', ['method' => $method, 'url' => $url]); + + if (!empty($this->user)) { + curl_setopt($ch, CURLOPT_USERPWD, $this->user . ':' . $this->password); + } + + if (!empty($this->accessToken)) { + $url .= "?access_token=" . $this->accessToken; + } + + curl_setopt_array( + $ch, + array( + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => $method != 'GET', + CURLOPT_POSTFIELDS => json_encode($params), + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_USERAGENT => "Robo" + ) + ); + + $output = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $response = json_decode($output); + + $this->printTaskInfo($output); + return [$code, $response]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHubRelease.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHubRelease.php new file mode 100644 index 00000000..bf7a4889 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/GitHubRelease.php @@ -0,0 +1,208 @@ +taskGitHubRelease('0.1.0') + * ->uri('consolidation-org/Robo') + * ->description('Add stuff people need.') + * ->change('Fix #123') + * ->change('Add frobulation method to all widgets') + * ->run(); + * ?> + * ``` + */ +class GitHubRelease extends GitHub +{ + /** + * @var string + */ + protected $tag; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $description = ''; + + /** + * @var string[] + */ + protected $changes = []; + + /** + * @var bool + */ + protected $draft = false; + + /** + * @var bool + */ + protected $prerelease = false; + + /** + * @var string + */ + protected $comittish = 'master'; + + /** + * @param string $tag + */ + public function __construct($tag) + { + $this->tag = $tag; + } + + /** + * @param string $tag + * + * @return $this + */ + public function tag($tag) + { + $this->tag = $tag; + return $this; + } + + /** + * @param bool $draft + * + * @return $this + */ + public function draft($draft) + { + $this->draft = $draft; + return $this; + } + + /** + * @param string $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this; + } + + /** + * @param string $description + * + * @return $this + */ + public function description($description) + { + $this->description = $description; + return $this; + } + + /** + * @param bool $prerelease + * + * @return $this + */ + public function prerelease($prerelease) + { + $this->prerelease = $prerelease; + return $this; + } + + /** + * @param string $comittish + * + * @return $this + */ + public function comittish($comittish) + { + $this->comittish = $comittish; + return $this; + } + + /** + * @param string $description + * + * @return $this + */ + public function appendDescription($description) + { + if (!empty($this->description)) { + $this->description .= "\n\n"; + } + $this->description .= $description; + return $this; + } + + public function changes(array $changes) + { + $this->changes = array_merge($this->changes, $changes); + return $this; + } + + /** + * @param string $change + * + * @return $this + */ + public function change($change) + { + $this->changes[] = $change; + return $this; + } + + /** + * @return string + */ + protected function getBody() + { + $body = $this->description; + if (!empty($this->changes)) { + $changes = array_map( + function ($line) { + return "* $line"; + }, + $this->changes + ); + $changesText = implode("\n", $changes); + $body .= "### Changelog \n\n$changesText"; + } + return $body; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Releasing {tag}', ['tag' => $this->tag]); + $this->startTimer(); + list($code, $data) = $this->sendRequest( + 'releases', + [ + "tag_name" => $this->tag, + "target_commitish" => $this->comittish, + "name" => $this->name, + "body" => $this->getBody(), + "draft" => $this->draft, + "prerelease" => $this->prerelease + ] + ); + $this->stopTimer(); + + return new Result( + $this, + in_array($code, [200, 201]) ? 0 : 1, + isset($data->message) ? $data->message : '', + ['response' => $data, 'time' => $this->getExecutionTime()] + ); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/OpenBrowser.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/OpenBrowser.php new file mode 100644 index 00000000..ea01b326 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/OpenBrowser.php @@ -0,0 +1,80 @@ +taskOpenBrowser('http://localhost') + * ->run(); + * + * // open two browser windows + * $this->taskOpenBrowser([ + * 'http://localhost/mysite', + * 'http://localhost/mysite2' + * ]) + * ->run(); + * ``` + */ +class OpenBrowser extends BaseTask +{ + /** + * @var string[] + */ + protected $urls = []; + + /** + * @param string|array $url + */ + public function __construct($url) + { + $this->urls = (array) $url; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $openCommand = $this->getOpenCommand(); + + if (empty($openCommand)) { + return Result::error($this, 'no suitable browser opening command found'); + } + + foreach ($this->urls as $url) { + passthru(sprintf($openCommand, ProcessUtils::escapeArgument($url))); + $this->printTaskInfo('Opened {url}', ['url' => $url]); + } + + return Result::success($this); + } + + /** + * @return null|string + */ + private function getOpenCommand() + { + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + return 'start "web" explorer "%s"'; + } + + passthru('which xdg-open', $linux); + passthru('which open', $osx); + + if (0 === $linux) { + return 'xdg-open %s'; + } + + if (0 === $osx) { + return 'open %s'; + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PackPhar.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PackPhar.php new file mode 100644 index 00000000..6d0a04d7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PackPhar.php @@ -0,0 +1,252 @@ +taskPackPhar('package/codecept.phar') + * ->compress() + * ->stub('package/stub.php'); + * + * $finder = Finder::create() + * ->name('*.php') + * ->in('src'); + * + * foreach ($finder as $file) { + * $pharTask->addFile('src/'.$file->getRelativePathname(), $file->getRealPath()); + * } + * + * $finder = Finder::create()->files() + * ->name('*.php') + * ->in('vendor'); + * + * foreach ($finder as $file) { + * $pharTask->addStripped('vendor/'.$file->getRelativePathname(), $file->getRealPath()); + * } + * $pharTask->run(); + * + * // verify Phar is packed correctly + * $code = $this->_exec('php package/codecept.phar'); + * ?> + * ``` + */ +class PackPhar extends BaseTask implements PrintedInterface, ProgressIndicatorAwareInterface +{ + /** + * @var \Phar + */ + protected $phar; + + /** + * @var null|string + */ + protected $compileDir = null; + + /** + * @var string + */ + protected $filename; + + /** + * @var bool + */ + protected $compress = false; + + protected $stub; + + protected $bin; + + /** + * @var string + */ + protected $stubTemplate = <<filename = $filename; + if (file_exists($file->getRealPath())) { + @unlink($file->getRealPath()); + } + $this->phar = new \Phar($file->getPathname(), 0, $file->getFilename()); + } + + /** + * @param bool $compress + * + * @return $this + */ + public function compress($compress = true) + { + $this->compress = $compress; + return $this; + } + + /** + * @param string $stub + * + * @return $this + */ + public function stub($stub) + { + $this->phar->setStub(file_get_contents($stub)); + return $this; + } + + /** + * {@inheritdoc} + */ + public function progressIndicatorSteps() + { + // run() will call advanceProgressIndicator() once for each + // file, one after calling stopBuffering, and again after compression. + return count($this->files)+2; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]); + $this->phar->setSignatureAlgorithm(\Phar::SHA1); + $this->phar->startBuffering(); + + $this->printTaskInfo('Packing {file-count} files into phar', ['file-count' => count($this->files)]); + + $this->startProgressIndicator(); + foreach ($this->files as $path => $content) { + $this->phar->addFromString($path, $content); + $this->advanceProgressIndicator(); + } + $this->phar->stopBuffering(); + $this->advanceProgressIndicator(); + + if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) { + if (count($this->files) > 1000) { + $this->printTaskInfo('Too many files. Compression DISABLED'); + } else { + $this->printTaskInfo('{filename} compressed', ['filename' => $this->filename]); + $this->phar = $this->phar->compressFiles(\Phar::GZ); + } + } + $this->advanceProgressIndicator(); + $this->stopProgressIndicator(); + $this->printTaskSuccess('{filename} produced', ['filename' => $this->filename]); + return Result::success($this, '', ['time' => $this->getExecutionTime()]); + } + + /** + * @param string $path + * @param string $file + * + * @return $this + */ + public function addStripped($path, $file) + { + $this->files[$path] = $this->stripWhitespace(file_get_contents($file)); + return $this; + } + + /** + * @param string $path + * @param string $file + * + * @return $this + */ + public function addFile($path, $file) + { + $this->files[$path] = file_get_contents($file); + return $this; + } + + /** + * @param \Symfony\Component\Finder\SplFileInfo[] $files + */ + public function addFiles($files) + { + foreach ($files as $file) { + $this->addFile($file->getRelativePathname(), $file->getRealPath()); + } + } + + /** + * @param string $file + * + * @return $this + */ + public function executable($file) + { + $source = file_get_contents($file); + if (strpos($source, '#!/usr/bin/env php') === 0) { + $source = substr($source, strpos($source, 'phar->setStub(sprintf($this->stubTemplate, $source)); + return $this; + } + + /** + * Strips whitespace from source. Taken from composer + * + * @param string $source + * + * @return string + */ + private function stripWhitespace($source) + { + if (!function_exists('token_get_all')) { + return $source; + } + + $output = ''; + foreach (token_get_all($source) as $token) { + if (is_string($token)) { + $output .= $token; + } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + // $output .= $token[1]; + $output .= str_repeat("\n", substr_count($token[1], "\n")); + } elseif (T_WHITESPACE === $token[0]) { + // reduce wide spaces + $whitespace = preg_replace('{[ \t]+}', ' ', $token[1]); + // normalize newlines to \n + $whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace); + // trim leading spaces + $whitespace = preg_replace('{\n +}', "\n", $whitespace); + $output .= $whitespace; + } else { + $output .= $token[1]; + } + } + + return $output; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PhpServer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PhpServer.php new file mode 100644 index 00000000..6dd36680 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/PhpServer.php @@ -0,0 +1,86 @@ +taskServer(8000) + * ->dir('public') + * ->run(); + * + * // run with IP 0.0.0.0 + * $this->taskServer(8000) + * ->host('0.0.0.0') + * ->run(); + * + * // execute server in background + * $this->taskServer(8000) + * ->background() + * ->run(); + * ?> + * ``` + */ +class PhpServer extends Exec +{ + /** + * @var int + */ + protected $port; + + /** + * @var string + */ + protected $host = '127.0.0.1'; + + /** + * {@inheritdoc} + */ + protected $command = 'php -S %s:%d '; + + /** + * @param int $port + */ + public function __construct($port) + { + $this->port = $port; + + if (strtolower(PHP_OS) === 'linux') { + $this->command = 'exec php -S %s:%d '; + } + } + + /** + * @param string $host + * + * @return $this + */ + public function host($host) + { + $this->host = $host; + return $this; + } + + /** + * @param string $path + * + * @return $this + */ + public function dir($path) + { + $this->command .= "-t $path"; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return sprintf($this->command . $this->arguments, $this->host, $this->port); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/SemVer.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/SemVer.php new file mode 100644 index 00000000..6c807d89 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/SemVer.php @@ -0,0 +1,255 @@ +taskSemVer('.semver') + * ->increment() + * ->run(); + * ?> + * ``` + * + */ +class SemVer implements TaskInterface +{ + const SEMVER = "---\n:major: %d\n:minor: %d\n:patch: %d\n:special: '%s'\n:metadata: '%s'"; + + const REGEX = "/^\-\-\-\n:major:\s(0|[1-9]\d*)\n:minor:\s(0|[1-9]\d*)\n:patch:\s(0|[1-9]\d*)\n:special:\s'([a-zA-z0-9]*\.?(?:0|[1-9]\d*)?)'\n:metadata:\s'((?:0|[1-9]\d*)?(?:\.[a-zA-z0-9\.]*)?)'/"; + + const REGEX_STRING = '/^(?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(|-(?[0-9a-zA-Z.]+))(|\+(?[0-9a-zA-Z.]+))$/'; + + /** + * @var string + */ + protected $format = 'v%M.%m.%p%s'; + + /** + * @var string + */ + protected $specialSeparator = '-'; + + /** + * @var string + */ + protected $metadataSeparator = '+'; + + /** + * @var string + */ + protected $path; + + /** + * @var array + */ + protected $version = [ + 'major' => 0, + 'minor' => 0, + 'patch' => 0, + 'special' => '', + 'metadata' => '' + ]; + + /** + * @param string $filename + */ + public function __construct($filename = '') + { + $this->path = $filename; + + if (file_exists($this->path)) { + $semverFileContents = file_get_contents($this->path); + $this->parseFile($semverFileContents); + } + } + + /** + * @return string + */ + public function __toString() + { + $search = ['%M', '%m', '%p', '%s']; + $replace = $this->version + ['extra' => '']; + + foreach (['special', 'metadata'] as $key) { + if (!empty($replace[$key])) { + $separator = $key . 'Separator'; + $replace['extra'] .= $this->{$separator} . $replace[$key]; + } + unset($replace[$key]); + } + + return str_replace($search, $replace, $this->format); + } + + public function version($version) + { + $this->parseString($version); + return $this; + } + + /** + * @param string $format + * + * @return $this + */ + public function setFormat($format) + { + $this->format = $format; + return $this; + } + + /** + * @param string $separator + * + * @return $this + */ + public function setMetadataSeparator($separator) + { + $this->metadataSeparator = $separator; + return $this; + } + + /** + * @param string $separator + * + * @return $this + */ + public function setPrereleaseSeparator($separator) + { + $this->specialSeparator = $separator; + return $this; + } + + /** + * @param string $what + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function increment($what = 'patch') + { + switch ($what) { + case 'major': + $this->version['major']++; + $this->version['minor'] = 0; + $this->version['patch'] = 0; + break; + case 'minor': + $this->version['minor']++; + $this->version['patch'] = 0; + break; + case 'patch': + $this->version['patch']++; + break; + default: + throw new TaskException( + $this, + 'Bad argument, only one of the following is allowed: major, minor, patch' + ); + } + return $this; + } + + /** + * @param string $tag + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function prerelease($tag = 'RC') + { + if (!is_string($tag)) { + throw new TaskException($this, 'Bad argument, only strings allowed.'); + } + + $number = 0; + + if (!empty($this->version['special'])) { + list($current, $number) = explode('.', $this->version['special']); + if ($tag != $current) { + $number = 0; + } + } + + $number++; + + $this->version['special'] = implode('.', [$tag, $number]); + return $this; + } + + /** + * @param array|string $data + * + * @return $this + */ + public function metadata($data) + { + if (is_array($data)) { + $data = implode('.', $data); + } + + $this->version['metadata'] = $data; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $written = $this->dump(); + return new Result($this, (int)($written === false), $this->__toString()); + } + + /** + * @return bool + * + * @throws \Robo\Exception\TaskException + */ + protected function dump() + { + if (empty($this->path)) { + return true; + } + extract($this->version); + $semver = sprintf(self::SEMVER, $major, $minor, $patch, $special, $metadata); + if (is_writeable($this->path) === false || file_put_contents($this->path, $semver) === false) { + throw new TaskException($this, 'Failed to write semver file.'); + } + return true; + } + + protected function parseString($semverString) + { + if (!preg_match_all(self::REGEX_STRING, $semverString, $matches)) { + throw new TaskException($this, 'Bad semver value: ' . $semverString); + } + + $this->version = array_intersect_key($matches, $this->version); + $this->version = array_map(function ($item) { + return $item[0]; + }, $this->version); + } + + /** + * @throws \Robo\Exception\TaskException + */ + protected function parseFile($semverFileContents) + { + if (!preg_match_all(self::REGEX, $semverFileContents, $matches)) { + throw new TaskException($this, 'Bad semver file.'); + } + + list(, $major, $minor, $patch, $special, $metadata) = array_map('current', $matches); + $this->version = compact('major', 'minor', 'patch', 'special', 'metadata'); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/loadTasks.php new file mode 100644 index 00000000..e3dc49a3 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Development/loadTasks.php @@ -0,0 +1,86 @@ +task(Changelog::class, $filename); + } + + /** + * @param string $filename + * + * @return GenerateMarkdownDoc + */ + protected function taskGenDoc($filename) + { + return $this->task(GenerateMarkdownDoc::class, $filename); + } + + /** + * @param string $className + * @param string $wrapperClassName + * + * @return \Robo\Task\Development\GenerateTask + */ + protected function taskGenTask($className, $wrapperClassName = '') + { + return $this->task(GenerateTask::class, $className, $wrapperClassName); + } + + /** + * @param string $pathToSemVer + * + * @return SemVer + */ + protected function taskSemVer($pathToSemVer = '.semver') + { + return $this->task(SemVer::class, $pathToSemVer); + } + + /** + * @param int $port + * + * @return PhpServer + */ + protected function taskServer($port = 8000) + { + return $this->task(PhpServer::class, $port); + } + + /** + * @param string $filename + * + * @return PackPhar + */ + protected function taskPackPhar($filename) + { + return $this->task(PackPhar::class, $filename); + } + + /** + * @param string $tag + * + * @return GitHubRelease + */ + protected function taskGitHubRelease($tag) + { + return $this->task(GitHubRelease::class, $tag); + } + + /** + * @param string|array $url + * + * @return OpenBrowser + */ + protected function taskOpenBrowser($url) + { + return $this->task(OpenBrowser::class, $url); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Base.php new file mode 100644 index 00000000..135f39e7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Base.php @@ -0,0 +1,28 @@ +getCommand(); + return $this->executeCommand($command); + } + + abstract public function getCommand(); +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Build.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Build.php new file mode 100644 index 00000000..11eb92ab --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Build.php @@ -0,0 +1,55 @@ +taskDockerBuild()->run(); + * + * $this->taskDockerBuild('path/to/dir') + * ->tag('database') + * ->run(); + * + * ?> + * + * ``` + * + * Class Build + * @package Robo\Task\Docker + */ +class Build extends Base +{ + /** + * @var string + */ + protected $path; + + /** + * @param string $path + */ + public function __construct($path = '.') + { + $this->command = "docker build"; + $this->path = $path; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->path; + } + + /** + * @param string $tag + * + * @return $this + */ + public function tag($tag) + { + return $this->option('-t', $tag); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Commit.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Commit.php new file mode 100644 index 00000000..302f1920 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Commit.php @@ -0,0 +1,66 @@ +taskDockerCommit($containerId) + * ->name('my/database') + * ->run(); + * + * // alternatively you can take the result from DockerRun task: + * + * $result = $this->taskDockerRun('db') + * ->exec('./prepare_database.sh') + * ->run(); + * + * $task->dockerCommit($result) + * ->name('my/database') + * ->run(); + * ``` + */ +class Commit extends Base +{ + /** + * @var string + */ + protected $command = "docker commit"; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->cid . ' ' . $this->name . ' ' . $this->arguments; + } + + /** + * @param $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Exec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Exec.php new file mode 100644 index 00000000..fa67c8da --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Exec.php @@ -0,0 +1,95 @@ +taskDockerRun('test_env') + * ->detached() + * ->run(); + * + * $this->taskDockerExec($test) + * ->interactive() + * ->exec('./runtests') + * ->run(); + * + * // alternatively use commands from other tasks + * + * $this->taskDockerExec($test) + * ->interactive() + * ->exec($this->taskCodecept()->suite('acceptance')) + * ->run(); + * ?> + * ``` + * + */ +class Exec extends Base +{ + use CommandReceiver; + + /** + * @var string + */ + protected $command = "docker exec"; + + /** + * @var string + */ + protected $cid; + + /** + * @var string + */ + protected $run = ''; + + /** + * @param string|\Robo\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * @return $this + */ + public function detached() + { + $this->option('-d'); + return $this; + } + + /** + * {@inheritdoc)} + */ + public function interactive($interactive = true) + { + if ($interactive) { + $this->option('-i'); + } + return parent::interactive($interactive); + } + + /** + * @param string|\Robo\Contract\CommandInterface $command + * + * @return $this + */ + public function exec($command) + { + $this->run = $this->receiveCommand($command); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid.' '.$this->run; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Pull.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Pull.php new file mode 100644 index 00000000..32ba5b40 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Pull.php @@ -0,0 +1,33 @@ +taskDockerPull('wordpress') + * ->run(); + * + * ?> + * ``` + * + */ +class Pull extends Base +{ + /** + * @param string $image + */ + public function __construct($image) + { + $this->command = "docker pull $image "; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Remove.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Remove.php new file mode 100644 index 00000000..0a8c0ac6 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Remove.php @@ -0,0 +1,32 @@ +taskDockerRemove($container) + * ->run(); + * ?> + * ``` + * + */ +class Remove extends Base +{ + /** + * @param string $container + */ + public function __construct($container) + { + $this->command = "docker rm $container "; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Result.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Result.php new file mode 100644 index 00000000..0533159a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Result.php @@ -0,0 +1,35 @@ +taskDockerRun('mysql')->run(); + * + * $result = $this->taskDockerRun('my_db_image') + * ->env('DB', 'database_name') + * ->volume('/path/to/data', '/data') + * ->detached() + * ->publish(3306) + * ->name('my_mysql') + * ->run(); + * + * // retrieve container's cid: + * $this->say("Running container ".$result->getCid()); + * + * // execute script inside container + * $result = $this->taskDockerRun('db') + * ->exec('prepare_test_data.sh') + * ->run(); + * + * $this->taskDockerCommit($result) + * ->name('test_db') + * ->run(); + * + * // link containers + * $mysql = $this->taskDockerRun('mysql') + * ->name('wp_db') // important to set name for linked container + * ->env('MYSQL_ROOT_PASSWORD', '123456') + * ->run(); + * + * $this->taskDockerRun('wordpress') + * ->link($mysql) + * ->publish(80, 8080) + * ->detached() + * ->run(); + * + * ?> + * ``` + * + */ +class Run extends Base +{ + use CommandReceiver; + + /** + * @var string + */ + protected $image = ''; + + /** + * @var string + */ + protected $run = ''; + + /** + * @var string + */ + protected $cidFile; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $dir; + + /** + * @param string $image + */ + public function __construct($image) + { + $this->image = $image; + } + + /** + * {@inheritdoc} + */ + public function getPrinted() + { + return $this->isPrinted; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + if ($this->isPrinted) { + $this->option('-i'); + } + if ($this->cidFile) { + $this->option('cidfile', $this->cidFile); + } + return trim('docker run ' . $this->arguments . ' ' . $this->image . ' ' . $this->run); + } + + /** + * @return $this + */ + public function detached() + { + $this->option('-d'); + return $this; + } + + /** + * {@inheritdoc)} + */ + public function interactive($interactive = true) + { + if ($interactive) { + $this->option('-i'); + } + return parent::interactive($interactive); + } + + /** + * @param string|\Robo\Contract\CommandInterface $run + * + * @return $this + */ + public function exec($run) + { + $this->run = $this->receiveCommand($run); + return $this; + } + + /** + * @param string $from + * @param null|string $to + * + * @return $this + */ + public function volume($from, $to = null) + { + $volume = $to ? "$from:$to" : $from; + $this->option('-v', $volume); + return $this; + } + + /** + * Set environment variables. + * n.b. $this->env($variable, $value) also available here, + * inherited from ExecTrait. + * + * @param array $env + * @return type + */ + public function envVars(array $env) + { + foreach ($env as $variable => $value) { + $this->setDockerEnv($variable, $value); + } + return $this; + } + + /** + * @param string $variable + * @param null|string $value + * + * @return $this + */ + protected function setDockerEnv($variable, $value = null) + { + $env = $value ? "$variable=$value" : $variable; + return $this->option("-e", $env); + } + + /** + * @param null|int $port + * @param null|int $portTo + * + * @return $this + */ + public function publish($port = null, $portTo = null) + { + if (!$port) { + return $this->option('-P'); + } + if ($portTo) { + $port = "$port:$portTo"; + } + return $this->option('-p', $port); + } + + /** + * @param string $dir + * + * @return $this + */ + public function containerWorkdir($dir) + { + return $this->option('-w', $dir); + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + return $this->option('-u', $user); + } + + /** + * @return $this + */ + public function privileged() + { + return $this->option('--privileged'); + } + + /** + * @param string $name + * + * @return $this + */ + public function name($name) + { + $this->name = $name; + return $this->option('name', $name); + } + + /** + * @param string|\Robo\Task\Docker\Result $name + * @param string $alias + * + * @return $this + */ + public function link($name, $alias) + { + if ($name instanceof Result) { + $name = $name->getContainerName(); + } + $this->option('link', "$name:$alias"); + return $this; + } + + /** + * @param string $dir + * + * @return $this + */ + public function tmpDir($dir) + { + $this->dir = $dir; + return $this; + } + + /** + * @return string + */ + public function getTmpDir() + { + return $this->dir ? $this->dir : sys_get_temp_dir(); + } + + /** + * @return string + */ + public function getUniqId() + { + return uniqid(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->cidFile = $this->getTmpDir() . '/docker_' . $this->getUniqId() . '.cid'; + $result = parent::run(); + $result['cid'] = $this->getCid(); + return $result; + } + + /** + * @return null|string + */ + protected function getCid() + { + if (!$this->cidFile || !file_exists($this->cidFile)) { + return null; + } + $cid = trim(file_get_contents($this->cidFile)); + @unlink($this->cidFile); + return $cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Start.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Start.php new file mode 100644 index 00000000..ef19d74d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Start.php @@ -0,0 +1,41 @@ +taskDockerStart($cidOrResult) + * ->run(); + * ?> + * ``` + */ +class Start extends Base +{ + /** + * @var string + */ + protected $command = "docker start"; + + /** + * @var null|string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Stop.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Stop.php new file mode 100644 index 00000000..4d0d436d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/Stop.php @@ -0,0 +1,41 @@ +taskDockerStop($cidOrResult) + * ->run(); + * ?> + * ``` + */ +class Stop extends Base +{ + /** + * @var string + */ + protected $command = "docker stop"; + + /** + * @var null|string + */ + protected $cid; + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + */ + public function __construct($cidOrResult) + { + $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . ' ' . $this->arguments . ' ' . $this->cid; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/loadTasks.php new file mode 100644 index 00000000..e58f5ef0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Docker/loadTasks.php @@ -0,0 +1,85 @@ +task(Run::class, $image); + } + + /** + * @param string $image + * + * @return \Robo\Task\Docker\Pull + */ + protected function taskDockerPull($image) + { + return $this->task(Pull::class, $image); + } + + /** + * @param string $path + * + * @return \Robo\Task\Docker\Build + */ + protected function taskDockerBuild($path = '.') + { + return $this->task(Build::class, $path); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Stop + */ + protected function taskDockerStop($cidOrResult) + { + return $this->task(Stop::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Commit + */ + protected function taskDockerCommit($cidOrResult) + { + return $this->task(Commit::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Start + */ + protected function taskDockerStart($cidOrResult) + { + return $this->task(Start::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Remove + */ + protected function taskDockerRemove($cidOrResult) + { + return $this->task(Remove::class, $cidOrResult); + } + + /** + * @param string|\Robo\Task\Docker\Result $cidOrResult + * + * @return \Robo\Task\Docker\Exec + */ + protected function taskDockerExec($cidOrResult) + { + return $this->task(Exec::class, $cidOrResult); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Concat.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Concat.php new file mode 100644 index 00000000..12b1eca0 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Concat.php @@ -0,0 +1,101 @@ +taskConcat([ + * 'web/assets/screen.css', + * 'web/assets/print.css', + * 'web/assets/theme.css' + * ]) + * ->to('web/assets/style.css') + * ->run() + * ?> + * ``` + */ +class Concat extends BaseTask +{ + use ResourceExistenceChecker; + + /** + * @var array|Iterator + */ + protected $files; + + /** + * @var string + */ + protected $dst; + + /** + * Constructor. + * + * @param array|Iterator $files + */ + public function __construct($files) + { + $this->files = $files; + } + + /** + * set the destination file + * + * @param string $dst + * + * @return $this + */ + public function to($dst) + { + $this->dst = $dst; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (is_null($this->dst) || "" === $this->dst) { + return Result::error($this, 'You must specify a destination file with to() method.'); + } + + if (!$this->checkResources($this->files, 'file')) { + return Result::error($this, 'Source files are missing!'); + } + + if (file_exists($this->dst) && !is_writable($this->dst)) { + return Result::error($this, 'Destination already exists and cannot be overwritten.'); + } + + $dump = ''; + + foreach ($this->files as $path) { + foreach (glob($path) as $file) { + $dump .= file_get_contents($file) . "\n"; + } + } + + $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]); + + $dst = $this->dst . '.part'; + $write_result = file_put_contents($dst, $dump); + + if (false === $write_result) { + @unlink($dst); + return Result::error($this, 'File write failed.'); + } + // Cannot be cross-volume; should always succeed. + @rename($dst, $this->dst); + + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Replace.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Replace.php new file mode 100644 index 00000000..0107df13 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Replace.php @@ -0,0 +1,141 @@ +taskReplaceInFile('VERSION') + * ->from('0.2.0') + * ->to('0.3.0') + * ->run(); + * + * $this->taskReplaceInFile('README.md') + * ->from(date('Y')-1) + * ->to(date('Y')) + * ->run(); + * + * $this->taskReplaceInFile('config.yml') + * ->regex('~^service:~') + * ->to('services:') + * ->run(); + * + * $this->taskReplaceInFile('box/robo.txt') + * ->from(array('##dbname##', '##dbhost##')) + * ->to(array('robo', 'localhost')) + * ->run(); + * ?> + * ``` + */ +class Replace extends BaseTask +{ + /** + * @var string + */ + protected $filename; + + /** + * @var string|string[] + */ + protected $from; + + /** + * @var string|string[] + */ + protected $to; + + /** + * @var string + */ + protected $regex; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * String(s) to be replaced. + * + * @param string|string[] $from + * + * @return $this + */ + public function from($from) + { + $this->from = $from; + return $this; + } + + /** + * Value(s) to be set as a replacement. + * + * @param string|string[] $to + * + * @return $this + */ + public function to($to) + { + $this->to = $to; + return $this; + } + + /** + * Regex to match string to be replaced. + * + * @param string $regex + * + * @return $this + */ + public function regex($regex) + { + $this->regex = $regex; + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + if (!file_exists($this->filename)) { + $this->printTaskError('File {filename} does not exist', ['filename' => $this->filename]); + return false; + } + + $text = file_get_contents($this->filename); + if ($this->regex) { + $text = preg_replace($this->regex, $this->to, $text, -1, $count); + } else { + $text = str_replace($this->from, $this->to, $text, $count); + } + if ($count > 0) { + $res = file_put_contents($this->filename, $text); + if ($res === false) { + return Result::error($this, "Error writing to file {filename}.", ['filename' => $this->filename]); + } + $this->printTaskSuccess("{filename} updated. {count} items replaced", ['filename' => $this->filename, 'count' => $count]); + } else { + $this->printTaskInfo("{filename} unchanged. {count} items replaced", ['filename' => $this->filename, 'count' => $count]); + } + return Result::success($this, '', ['replaced' => $count]); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/TmpFile.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/TmpFile.php new file mode 100644 index 00000000..4a18691d --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/TmpFile.php @@ -0,0 +1,72 @@ +collectionBuilder(); + * $tmpFilePath = $collection->taskTmpFile() + * ->line('-----') + * ->line(date('Y-m-d').' '.$title) + * ->line('----') + * ->getPath(); + * $collection->run(); + * ?> + * ``` + */ +class TmpFile extends Write implements CompletionInterface +{ + /** + * @param string $filename + * @param string $extension + * @param string $baseDir + * @param bool $includeRandomPart + */ + public function __construct($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true) + { + if (empty($baseDir)) { + $baseDir = sys_get_temp_dir(); + } + if ($includeRandomPart) { + $random = static::randomString(); + $filename = "{$filename}_{$random}"; + } + $filename .= $extension; + parent::__construct("{$baseDir}/{$filename}"); + } + + /** + * Generate a suitably random string to use as the suffix for our + * temporary file. + * + * @param int $length + * + * @return string + */ + private static function randomString($length = 12) + { + return substr(str_shuffle('23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'), 0, $length); + } + + /** + * Delete this file when our collection completes. + * If this temporary file is not part of a collection, + * then it will be deleted when the program terminates, + * presuming that it was created by taskTmpFile() or _tmpFile(). + */ + public function complete() + { + unlink($this->getPath()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Write.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Write.php new file mode 100644 index 00000000..dc2199f9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/Write.php @@ -0,0 +1,335 @@ +taskWriteToFile('blogpost.md') + * ->line('-----') + * ->line(date('Y-m-d').' '.$title) + * ->line('----') + * ->run(); + * ?> + * ``` + */ +class Write extends BaseTask +{ + /** + * @var array + */ + protected $stack = []; + + /** + * @var string + */ + protected $filename; + + /** + * @var bool + */ + protected $append = false; + + /** + * @var null|string + */ + protected $originalContents = null; + + /** + * @param string $filename + */ + public function __construct($filename) + { + $this->filename = $filename; + } + + /** + * @param string $filename + * + * @return $this + */ + public function filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * @param bool $append + * + * @return $this + */ + public function append($append = true) + { + $this->append = $append; + return $this; + } + + /** + * add a line. + * + * @param string $line + * + * @return $this The current instance + */ + public function line($line) + { + $this->text($line . "\n"); + return $this; + } + + /** + * add more lines. + * + * @param array $lines + * + * @return $this The current instance + */ + public function lines(array $lines) + { + $this->text(implode("\n", $lines) . "\n"); + return $this; + } + + /** + * add a text. + * + * @param string $text + * + * @return $this The current instance + */ + public function text($text) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * add a text from a file. + * + * Note that the file is read in the run() method of this task. + * To load text from the current state of a file (e.g. one that may + * be deleted or altered by other tasks prior the execution of this one), + * use: + * $task->text(file_get_contents($filename)); + * + * @param string $filename + * + * @return $this The current instance + */ + public function textFromFile($filename) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * substitute a placeholder with value, placeholder must be enclosed by `{}`. + * + * @param string $name + * @param string $val + * + * @return $this The current instance + */ + public function place($name, $val) + { + $this->replace('{'.$name.'}', $val); + + return $this; + } + + /** + * replace any string with value. + * + * @param string $string + * @param string $replacement + * + * @return $this The current instance + */ + public function replace($string, $replacement) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * replace any string with value using regular expression. + * + * @param string $pattern + * @param string $replacement + * + * @return $this The current instance + */ + public function regexReplace($pattern, $replacement) + { + $this->stack[] = array_merge([__FUNCTION__ . 'Collect'], func_get_args()); + return $this; + } + + /** + * Append the provided text to the end of the buffer if the provided + * regex pattern matches any text already in the buffer. + * + * @param string $pattern + * @param string $text + * + * @return $this + */ + public function appendIfMatches($pattern, $text) + { + $this->stack[] = array_merge(['appendIfMatchesCollect'], [$pattern, $text, true]); + return $this; + } + + /** + * Append the provided text to the end of the buffer unless the provided + * regex pattern matches any text already in the buffer. + * + * @param string $pattern + * @param string $text + * + * @return $this + */ + public function appendUnlessMatches($pattern, $text) + { + $this->stack[] = array_merge(['appendIfMatchesCollect'], [$pattern, $text, false]); + return $this; + } + + /** + * @param $contents string + * @param $filename string + * + * @return string + */ + protected function textFromFileCollect($contents, $filename) + { + if (file_exists($filename)) { + $contents .= file_get_contents($filename); + } + return $contents; + } + + /** + * @param string|string[] $contents + * @param string|string[] $string + * @param string|string[] $replacement + * + * @return string|string[] + */ + protected function replaceCollect($contents, $string, $replacement) + { + return str_replace($string, $replacement, $contents); + } + + /** + * @param string|string[] $contents + * @param string|string[] $pattern + * @param string|string[] $replacement + * + * @return string|string[] + */ + protected function regexReplaceCollect($contents, $pattern, $replacement) + { + return preg_replace($pattern, $replacement, $contents); + } + + /** + * @param string $contents + * @param string $text + * + * @return string + */ + protected function textCollect($contents, $text) + { + return $contents . $text; + } + + /** + * @param string $contents + * @param string $pattern + * @param string $text + * @param bool $shouldMatch + * + * @return string + */ + protected function appendIfMatchesCollect($contents, $pattern, $text, $shouldMatch) + { + if (preg_match($pattern, $contents) == $shouldMatch) { + $contents .= $text; + } + return $contents; + } + + /** + * @return string + */ + public function originalContents() + { + if (!isset($this->originalContents)) { + $this->originalContents = ''; + if (file_exists($this->filename)) { + $this->originalContents = file_get_contents($this->filename); + } + } + return $this->originalContents; + } + + /** + * @return bool + */ + public function wouldChange() + { + return $this->originalContents() != $this->getContentsToWrite(); + } + + /** + * @return string + */ + protected function getContentsToWrite() + { + $contents = ""; + if ($this->append) { + $contents = $this->originalContents(); + } + foreach ($this->stack as $action) { + $command = array_shift($action); + if (method_exists($this, $command)) { + array_unshift($action, $contents); + $contents = call_user_func_array([$this, $command], $action); + } + } + return $contents; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo("Writing to {filename}.", ['filename' => $this->filename]); + $contents = $this->getContentsToWrite(); + if (!file_exists(dirname($this->filename))) { + mkdir(dirname($this->filename), 0777, true); + } + $res = file_put_contents($this->filename, $contents); + if ($res === false) { + return Result::error($this, "File {$this->filename} couldn't be created"); + } + + return Result::success($this); + } + + /** + * @return string + */ + public function getPath() + { + return $this->filename; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/loadTasks.php new file mode 100644 index 00000000..c5f39c95 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/File/loadTasks.php @@ -0,0 +1,48 @@ +task(Concat::class, $files); + } + + /** + * @param string $file + * + * @return \Robo\Task\File\Replace + */ + protected function taskReplaceInFile($file) + { + return $this->task(Replace::class, $file); + } + + /** + * @param string $file + * + * @return \Robo\Task\File\Write + */ + protected function taskWriteToFile($file) + { + return $this->task(Write::class, $file); + } + + /** + * @param string $filename + * @param string $extension + * @param string $baseDir + * @param bool $includeRandomPart + * + * @return \Robo\Task\File\TmpFile + */ + protected function taskTmpFile($filename = 'tmp', $extension = '', $baseDir = '', $includeRandomPart = true) + { + return $this->task(TmpFile::class, $filename, $extension, $baseDir, $includeRandomPart); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/BaseDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/BaseDir.php new file mode 100644 index 00000000..434334d7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/BaseDir.php @@ -0,0 +1,30 @@ +dirs = $dirs + : $this->dirs[] = $dirs; + + $this->fs = new sfFilesystem(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CleanDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CleanDir.php new file mode 100644 index 00000000..762f8550 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CleanDir.php @@ -0,0 +1,63 @@ +taskCleanDir(['tmp','logs'])->run(); + * // as shortcut + * $this->_cleanDir('app/cache'); + * ?> + * ``` + */ +class CleanDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $dir) { + $this->emptyDir($dir); + $this->printTaskInfo("Cleaned {dir}", ['dir' => $dir]); + } + return Result::success($this); + } + + /** + * @param string $path + */ + protected function emptyDir($path) + { + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path), + \RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($iterator as $path) { + if ($path->isDir()) { + $dir = (string)$path; + if (basename($dir) === '.' || basename($dir) === '..') { + continue; + } + $this->fs->remove($dir); + } else { + $file = (string)$path; + if (basename($file) === '.gitignore' || basename($file) === '.gitkeep') { + continue; + } + $this->fs->remove($file); + } + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CopyDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CopyDir.php new file mode 100644 index 00000000..08482222 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/CopyDir.php @@ -0,0 +1,162 @@ +taskCopyDir(['dist/config' => 'config'])->run(); + * // as shortcut + * $this->_copyDir('dist/config', 'config'); + * ?> + * ``` + */ +class CopyDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * Explicitly declare our consturctor, so that + * our copyDir() method does not look like a php4 constructor. + */ + public function __construct($dirs) + { + parent::__construct($dirs); + } + + /** + * @var int + */ + protected $chmod = 0755; + + /** + * Files to exclude on copying. + * + * @var string[] + */ + protected $exclude = []; + + /** + * Overwrite destination files newer than source files. + */ + protected $overwrite = true; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $src => $dst) { + $this->copyDir($src, $dst); + $this->printTaskInfo('Copied from {source} to {destination}', ['source' => $src, 'destination' => $dst]); + } + return Result::success($this); + } + + /** + * Sets the default folder permissions for the destination if it doesn't exist + * + * @link http://en.wikipedia.org/wiki/Chmod + * @link http://php.net/manual/en/function.mkdir.php + * @link http://php.net/manual/en/function.chmod.php + * + * @param int $value + * + * @return $this + */ + public function dirPermissions($value) + { + $this->chmod = (int)$value; + return $this; + } + + /** + * List files to exclude. + * + * @param string[] $exclude + * + * @return $this + */ + public function exclude($exclude = []) + { + $this->exclude = $this->simplifyForCompare($exclude); + return $this; + } + + /** + * Destination files newer than source files are overwritten. + * + * @param bool $overwrite + * + * @return $this + */ + public function overwrite($overwrite) + { + $this->overwrite = $overwrite; + return $this; + } + + /** + * Copies a directory to another location. + * + * @param string $src Source directory + * @param string $dst Destination directory + * @param string $parent Parent directory + * + * @throws \Robo\Exception\TaskException + */ + protected function copyDir($src, $dst, $parent = '') + { + $dir = @opendir($src); + if (false === $dir) { + throw new TaskException($this, "Cannot open source directory '" . $src . "'"); + } + if (!is_dir($dst)) { + mkdir($dst, $this->chmod, true); + } + while (false !== ($file = readdir($dir))) { + // Support basename and full path exclusion. + if ($this->excluded($file, $src, $parent)) { + continue; + } + $srcFile = $src . '/' . $file; + $destFile = $dst . '/' . $file; + if (is_dir($srcFile)) { + $this->copyDir($srcFile, $destFile, $parent . $file . DIRECTORY_SEPARATOR); + } else { + $this->fs->copy($srcFile, $destFile, $this->overwrite); + } + } + closedir($dir); + } + + /** + * Check to see if the current item is excluded. + */ + protected function excluded($file, $src, $parent) + { + return + ($file == '.') || + ($file == '..') || + in_array($file, $this->exclude) || + in_array($this->simplifyForCompare($parent . $file), $this->exclude) || + in_array($this->simplifyForCompare($src . DIRECTORY_SEPARATOR . $file), $this->exclude); + } + + /** + * Avoid problems comparing paths on Windows that may have a + * combination of DIRECTORY_SEPARATOR and /. + */ + protected function simplifyForCompare($item) + { + return str_replace(DIRECTORY_SEPARATOR, '/', $item); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/DeleteDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/DeleteDir.php new file mode 100644 index 00000000..25cf007b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/DeleteDir.php @@ -0,0 +1,36 @@ +taskDeleteDir('tmp')->run(); + * // as shortcut + * $this->_deleteDir(['tmp', 'log']); + * ?> + * ``` + */ +class DeleteDir extends BaseDir +{ + use ResourceExistenceChecker; + + /** + * {@inheritdoc} + */ + public function run() + { + if (!$this->checkResources($this->dirs, 'dir')) { + return Result::error($this, 'Source directories are missing!'); + } + foreach ($this->dirs as $dir) { + $this->fs->remove($dir); + $this->printTaskInfo("Deleted {dir}...", ['dir' => $dir]); + } + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FilesystemStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FilesystemStack.php new file mode 100644 index 00000000..8663e245 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FilesystemStack.php @@ -0,0 +1,154 @@ +taskFilesystemStack() + * ->mkdir('logs') + * ->touch('logs/.gitignore') + * ->chgrp('www', 'www-data') + * ->symlink('/var/log/nginx/error.log', 'logs/error.log') + * ->run(); + * + * // one line + * $this->_touch('.gitignore'); + * $this->_mkdir('logs'); + * + * ?> + * ``` + * + * @method $this mkdir(string|array|\Traversable $dir, int $mode = 0777) + * @method $this touch(string|array|\Traversable $file, int $time = null, int $atime = null) + * @method $this copy(string $from, string $to, bool $force = false) + * @method $this chmod(string|array|\Traversable $file, int $permissions, int $umask = 0000, bool $recursive = false) + * @method $this chgrp(string|array|\Traversable $file, string $group, bool $recursive = false) + * @method $this chown(string|array|\Traversable $file, string $user, bool $recursive = false) + * @method $this remove(string|array|\Traversable $file) + * @method $this rename(string $from, string $to, bool $force = false) + * @method $this symlink(string $from, string $to, bool $copyOnWindows = false) + * @method $this mirror(string $from, string $to, \Traversable $iterator = null, array $options = []) + */ +class FilesystemStack extends StackBasedTask implements BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var \Symfony\Component\Filesystem\Filesystem + */ + protected $fs; + + public function __construct() + { + $this->fs = new sfFilesystem(); + } + + /** + * @return \Symfony\Component\Filesystem\Filesystem + */ + protected function getDelegate() + { + return $this->fs; + } + + /** + * @param string $from + * @param string $to + * @param bool $force + */ + protected function _copy($from, $to, $force = false) + { + $this->fs->copy($from, $to, $force); + } + + /** + * @param string|string[]|\Traversable $file + * @param int $permissions + * @param int $umask + * @param bool $recursive + */ + protected function _chmod($file, $permissions, $umask = 0000, $recursive = false) + { + $this->fs->chmod($file, $permissions, $umask, $recursive); + } + + /** + * @param string|string[]|\Traversable $file + * @param string $group + * @param bool $recursive + */ + protected function _chgrp($file, $group, $recursive = null) + { + $this->fs->chgrp($file, $group, $recursive); + } + + /** + * @param string|string[]|\Traversable $file + * @param string $user + * @param bool $recursive + */ + protected function _chown($file, $user, $recursive = null) + { + $this->fs->chown($file, $user, $recursive); + } + + /** + * @param string $origin + * @param string $target + * @param bool $overwrite + * + * @return null|true|\Robo\Result + */ + protected function _rename($origin, $target, $overwrite = false) + { + // we check that target does not exist + if ((!$overwrite && is_readable($target)) || (file_exists($target) && !is_writable($target))) { + throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target); + } + + // Due to a bug (limitation) in PHP, cross-volume renames do not work. + // See: https://bugs.php.net/bug.php?id=54097 + if (true !== @rename($origin, $target)) { + return $this->crossVolumeRename($origin, $target); + } + return true; + } + + /** + * @param string $origin + * @param string $target + * + * @return null|\Robo\Result + */ + protected function crossVolumeRename($origin, $target) + { + // First step is to try to get rid of the target. If there + // is a single, deletable file, then we will just unlink it. + if (is_file($target)) { + unlink($target); + } + // If the target still exists, we will try to delete it. + // TODO: Note that if this fails partway through, then we cannot + // adequately rollback. Perhaps we need to preflight the operation + // and determine if everything inside of $target is writable. + if (file_exists($target)) { + $this->fs->remove($target); + } + + /** @var \Robo\Result $result */ + $result = $this->collectionBuilder()->taskCopyDir([$origin => $target])->run(); + if (!$result->wasSuccessful()) { + return $result; + } + $this->fs->remove($origin); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FlattenDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FlattenDir.php new file mode 100644 index 00000000..6e885112 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/FlattenDir.php @@ -0,0 +1,294 @@ +taskFlattenDir(['assets/*.min.js' => 'dist'])->run(); + * // or use shortcut + * $this->_flattenDir('assets/*.min.js', 'dist'); + * ?> + * ``` + * + * You can also define the target directory with an additional method, instead of + * key/value pairs. More similar to the gulp-flatten syntax: + * + * ``` php + * taskFlattenDir(['assets/*.min.js']) + * ->to('dist') + * ->run(); + * ?> + * ``` + * + * You can also append parts of the parent directories to the target path. If you give + * the value `1` to the `includeParents()` method, then the top parent will be appended + * to the target directory resulting in a path such as `dist/assets/asset-library1.min.js`. + * + * If you give a negative number, such as `-1` (the same as specifying `array(0, 1)` then + * the bottom parent will be appended, resulting in a path such as + * `dist/asset-library1/asset-library1.min.js`. + * + * The top parent directory will always be starting from the relative path to the current + * directory. You can override that with the `parentDir()` method. If in the above example + * you would specify `assets`, then the top parent directory would be `asset-library1`. + * + * ``` php + * taskFlattenDir(['assets/*.min.js' => 'dist']) + * ->parentDir('assets') + * ->includeParents(1) + * ->run(); + * ?> + * ``` + */ +class FlattenDir extends BaseDir +{ + /** + * @var int + */ + protected $chmod = 0755; + + /** + * @var int[] + */ + protected $parents = array(0, 0); + + /** + * @var string + */ + protected $parentDir = ''; + + /** + * @var string + */ + protected $to; + + /** + * {@inheritdoc} + */ + public function __construct($dirs) + { + parent::__construct($dirs); + $this->parentDir = getcwd(); + } + + /** + * {@inheritdoc} + */ + public function run() + { + // find the files + $files = $this->findFiles($this->dirs); + + // copy the files + $this->copyFiles($files); + + $fileNoun = count($files) == 1 ? ' file' : ' files'; + $this->printTaskSuccess("Copied {count} $fileNoun to {destination}", ['count' => count($files), 'destination' => $this->to]); + + return Result::success($this); + } + + /** + * Sets the default folder permissions for the destination if it does not exist. + * + * @link http://en.wikipedia.org/wiki/Chmod + * @link http://php.net/manual/en/function.mkdir.php + * @link http://php.net/manual/en/function.chmod.php + * + * @param int $permission + * + * @return $this + */ + public function dirPermissions($permission) + { + $this->chmod = (int) $permission; + + return $this; + } + + /** + * Sets the value from which direction and how much parent dirs should be included. + * Accepts a positive or negative integer or an array with two integer values. + * + * @param int|int[] $parents + * + * @return $this + * + * @throws TaskException + */ + public function includeParents($parents) + { + if (is_int($parents)) { + // if an integer is given check whether it is for top or bottom parent + if ($parents >= 0) { + $this->parents[0] = $parents; + return $this; + } + $this->parents[1] = 0 - $parents; + return $this; + } + + if (is_array($parents)) { + // check if the array has two values no more, no less + if (count($parents) == 2) { + $this->parents = $parents; + return $this; + } + } + + throw new TaskException($this, 'includeParents expects an integer or an array with two values'); + } + + /** + * Sets the parent directory from which the relative parent directories will be calculated. + * + * @param string $dir + * + * @return $this + */ + public function parentDir($dir) + { + if (!$this->fs->isAbsolutePath($dir)) { + // attach the relative path to current working directory + $dir = getcwd().'/'.$dir; + } + $this->parentDir = $dir; + + return $this; + } + + /** + * Sets the target directory where the files will be copied to. + * + * @param string $target + * + * @return $this + */ + public function to($target) + { + $this->to = rtrim($target, '/'); + + return $this; + } + + /** + * @param array $dirs + * + * @return array|\Robo\Result + * + * @throws \Robo\Exception\TaskException + */ + protected function findFiles($dirs) + { + $files = array(); + + // find the files + foreach ($dirs as $k => $v) { + // reset finder + $finder = new Finder(); + + $dir = $k; + $to = $v; + // check if target was given with the to() method instead of key/value pairs + if (is_int($k)) { + $dir = $v; + if (isset($this->to)) { + $to = $this->to; + } else { + throw new TaskException($this, 'target directory is not defined'); + } + } + + try { + $finder->files()->in($dir); + } catch (\InvalidArgumentException $e) { + // if finder cannot handle it, try with in()->name() + if (strpos($dir, '/') === false) { + $dir = './'.$dir; + } + $parts = explode('/', $dir); + $new_dir = implode('/', array_slice($parts, 0, -1)); + try { + $finder->files()->in($new_dir)->name(array_pop($parts)); + } catch (\InvalidArgumentException $e) { + return Result::fromException($this, $e); + } + } + + foreach ($finder as $file) { + // store the absolute path as key and target as value in the files array + $files[$file->getRealpath()] = $this->getTarget($file->getRealPath(), $to); + } + $fileNoun = count($files) == 1 ? ' file' : ' files'; + $this->printTaskInfo("Found {count} $fileNoun in {dir}", ['count' => count($files), 'dir' => $dir]); + } + + return $files; + } + + /** + * @param string $file + * @param string $to + * + * @return string + */ + protected function getTarget($file, $to) + { + $target = $to.'/'.basename($file); + if ($this->parents !== array(0, 0)) { + // if the parent is set, create additional directories inside target + // get relative path to parentDir + $rel_path = $this->fs->makePathRelative(dirname($file), $this->parentDir); + // get top parents and bottom parents + $parts = explode('/', rtrim($rel_path, '/')); + $prefix_dir = ''; + $prefix_dir .= ($this->parents[0] > 0 ? implode('/', array_slice($parts, 0, $this->parents[0])).'/' : ''); + $prefix_dir .= ($this->parents[1] > 0 ? implode('/', array_slice($parts, (0 - $this->parents[1]), $this->parents[1])) : ''); + $prefix_dir = rtrim($prefix_dir, '/'); + $target = $to.'/'.$prefix_dir.'/'.basename($file); + } + + return $target; + } + + /** + * @param array $files + */ + protected function copyFiles($files) + { + // copy the files + foreach ($files as $from => $to) { + // check if target dir exists + if (!is_dir(dirname($to))) { + $this->fs->mkdir(dirname($to), $this->chmod); + } + $this->fs->copy($from, $to); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/MirrorDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/MirrorDir.php new file mode 100644 index 00000000..4eda9097 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/MirrorDir.php @@ -0,0 +1,40 @@ +taskMirrorDir(['dist/config/' => 'config/'])->run(); + * // or use shortcut + * $this->_mirrorDir('dist/config/', 'config/'); + * + * ?> + * ``` + */ +class MirrorDir extends BaseDir +{ + /** + * {@inheritdoc} + */ + public function run() + { + foreach ($this->dirs as $src => $dst) { + $this->fs->mirror( + $src, + $dst, + null, + [ + 'override' => true, + 'copy_on_windows' => true, + 'delete' => true + ] + ); + $this->printTaskInfo("Mirrored from {source} to {destination}", ['source' => $src, 'destination' => $dst]); + } + return Result::success($this); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/TmpDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/TmpDir.php new file mode 100644 index 00000000..104318de --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/TmpDir.php @@ -0,0 +1,173 @@ +run(). + * $collection = $this->collectionBuilder(); + * $tmpPath = $collection->tmpDir()->getPath(); + * $collection->taskFilesystemStack() + * ->mkdir("$tmpPath/log") + * ->touch("$tmpPath/log/error.txt"); + * $collection->run(); + * // as shortcut (deleted when program exits) + * $tmpPath = $this->_tmpDir(); + * ?> + * ``` + */ +class TmpDir extends BaseDir implements CompletionInterface +{ + /** + * @var string + */ + protected $base; + + /** + * @var string + */ + protected $prefix; + + /** + * @var bool + */ + protected $cwd; + + /** + * @var string + */ + protected $savedWorkingDirectory; + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + */ + public function __construct($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + if (empty($base)) { + $base = sys_get_temp_dir(); + } + $path = "{$base}/{$prefix}"; + if ($includeRandomPart) { + $path = static::randomLocation($path); + } + parent::__construct(["$path"]); + } + + /** + * Add a random part to a path, ensuring that the directory does + * not (currently) exist. + * + * @param string $path The base/prefix path to add a random component to + * @param int $length Number of digits in the random part + * + * @return string + */ + protected static function randomLocation($path, $length = 12) + { + $random = static::randomString($length); + while (is_dir("{$path}_{$random}")) { + $random = static::randomString($length); + } + return "{$path}_{$random}"; + } + + /** + * Generate a suitably random string to use as the suffix for our + * temporary directory. + * + * @param int $length + * + * @return string + */ + protected static function randomString($length = 12) + { + return substr(str_shuffle('23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'), 0, max($length, 3)); + } + + /** + * Flag that we should cwd to the temporary directory when it is + * created, and restore the old working directory when it is deleted. + * + * @param bool $shouldChangeWorkingDirectory + * + * @return $this + */ + public function cwd($shouldChangeWorkingDirectory = true) + { + $this->cwd = $shouldChangeWorkingDirectory; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + // Save the current working directory + $this->savedWorkingDirectory = getcwd(); + foreach ($this->dirs as $dir) { + $this->fs->mkdir($dir); + $this->printTaskInfo("Created {dir}...", ['dir' => $dir]); + + // Change the current working directory, if requested + if ($this->cwd) { + chdir($dir); + } + } + + return Result::success($this, '', ['path' => $this->getPath()]); + } + + protected function restoreWorkingDirectory() + { + // Restore the current working directory, if we redirected it. + if ($this->cwd) { + chdir($this->savedWorkingDirectory); + } + } + + protected function deleteTmpDir() + { + foreach ($this->dirs as $dir) { + $this->fs->remove($dir); + } + } + + /** + * Delete this directory when our collection completes. + * If this temporary directory is not part of a collection, + * then it will be deleted when the program terminates, + * presuming that it was created by taskTmpDir() or _tmpDir(). + */ + public function complete() + { + $this->restoreWorkingDirectory(); + $this->deleteTmpDir(); + } + + /** + * Get a reference to the path to the temporary directory, so that + * it may be used to create other tasks. Note that the directory + * is not actually created until the task runs. + * + * @return string + */ + public function getPath() + { + return $this->dirs[0]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/WorkDir.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/WorkDir.php new file mode 100644 index 00000000..4b75c6ed --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/WorkDir.php @@ -0,0 +1,126 @@ +collectionBuilder(); + * $workingPath = $collection->workDir("build")->getPath(); + * $collection->taskFilesystemStack() + * ->mkdir("$workingPath/log") + * ->touch("$workingPath/log/error.txt"); + * $collection->run(); + * ?> + * ``` + */ +class WorkDir extends TmpDir implements RollbackInterface, BuilderAwareInterface +{ + use BuilderAwareTrait; + + /** + * @var string + */ + protected $finalDestination; + + /** + * @param string $finalDestination + */ + public function __construct($finalDestination) + { + $this->finalDestination = $finalDestination; + + // Create a temporary directory to work in. We will place our + // temporary directory in the same location as the final destination + // directory, so that the work directory can be moved into place + // without having to be copied, e.g. in a cross-volume rename scenario. + parent::__construct(basename($finalDestination), dirname($finalDestination)); + } + + /** + * Create our working directory. + * + * @return \Robo\Result + */ + public function run() + { + // Destination cannot be empty + if (empty($this->finalDestination)) { + return Result::error($this, "Destination directory not specified."); + } + + // Before we do anything else, ensure that any directory in the + // final destination is writable, so that we can at a minimum + // move it out of the way before placing our results there. + if (is_dir($this->finalDestination)) { + if (!is_writable($this->finalDestination)) { + return Result::error($this, "Destination directory {dir} exists and cannot be overwritten.", ['dir' => $this->finalDestination]); + } + } + + return parent::run(); + } + + /** + * Move our working directory into its final destination once the + * collection it belongs to completes. + */ + public function complete() + { + $this->restoreWorkingDirectory(); + + // Delete the final destination, if it exists. + // Move it out of the way first, in case it cannot + // be completely deleted. + if (file_exists($this->finalDestination)) { + $temporaryLocation = static::randomLocation($this->finalDestination . '_TO_DELETE_'); + // This should always work, because we already created a temporary + // folder in the parent directory of the final destination, and we + // have already checked to confirm that the final destination is + // writable. + rename($this->finalDestination, $temporaryLocation); + // This may silently fail, leaving artifacts behind, if there + // are permissions problems with some items somewhere inside + // the folder being deleted. + $this->fs->remove($temporaryLocation); + } + + // Move our working directory over the final destination. + // This should never be a cross-volume rename, so this should + // always succeed. + $workDir = reset($this->dirs); + if (file_exists($workDir)) { + rename($workDir, $this->finalDestination); + } + } + + /** + * Delete our working directory + */ + public function rollback() + { + $this->restoreWorkingDirectory(); + $this->deleteTmpDir(); + } + + /** + * Get a reference to the path to the temporary directory, so that + * it may be used to create other tasks. Note that the directory + * is not actually created until the task runs. + * + * @return string + */ + public function getPath() + { + return $this->dirs[0]; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadShortcuts.php new file mode 100644 index 00000000..fe72ce5a --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadShortcuts.php @@ -0,0 +1,159 @@ +taskCopyDir([$src => $dst])->run(); + } + + /** + * @param string $src + * @param string $dst + * + * @return \Robo\Result + */ + protected function _mirrorDir($src, $dst) + { + return $this->taskMirrorDir([$src => $dst])->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _deleteDir($dir) + { + return $this->taskDeleteDir($dir)->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _cleanDir($dir) + { + return $this->taskCleanDir($dir)->run(); + } + + /** + * @param string $from + * @param string $to + * @param bool $overwrite + * + * @return \Robo\Result + */ + protected function _rename($from, $to, $overwrite = false) + { + return $this->taskFilesystemStack()->rename($from, $to, $overwrite)->run(); + } + + /** + * @param string|string[] $dir + * + * @return \Robo\Result + */ + protected function _mkdir($dir) + { + return $this->taskFilesystemStack()->mkdir($dir)->run(); + } + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return string + */ + protected function _tmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + $result = $this->taskTmpDir($prefix, $base, $includeRandomPart)->run(); + return isset($result['path']) ? $result['path'] : ''; + } + + /** + * @param string $file + * + * @return \Robo\Result + */ + protected function _touch($file) + { + return $this->taskFilesystemStack()->touch($file)->run(); + } + + /** + * @param string|string[] $file + * + * @return \Robo\Result + */ + protected function _remove($file) + { + return $this->taskFilesystemStack()->remove($file)->run(); + } + + /** + * @param string|string[] $file + * @param string $group + * + * @return \Robo\Result + */ + protected function _chgrp($file, $group) + { + return $this->taskFilesystemStack()->chgrp($file, $group)->run(); + } + + /** + * @param string|string[] $file + * @param int $permissions + * @param int $umask + * @param bool $recursive + * + * @return \Robo\Result + */ + protected function _chmod($file, $permissions, $umask = 0000, $recursive = false) + { + return $this->taskFilesystemStack()->chmod($file, $permissions, $umask, $recursive)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _symlink($from, $to) + { + return $this->taskFilesystemStack()->symlink($from, $to)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _copy($from, $to) + { + return $this->taskFilesystemStack()->copy($from, $to)->run(); + } + + /** + * @param string $from + * @param string $to + * + * @return \Robo\Result + */ + protected function _flattenDir($from, $to) + { + return $this->taskFlattenDir([$from => $to])->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadTasks.php new file mode 100644 index 00000000..8fecaaff --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Filesystem/loadTasks.php @@ -0,0 +1,85 @@ +task(CleanDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\DeleteDir + */ + protected function taskDeleteDir($dirs) + { + return $this->task(DeleteDir::class, $dirs); + } + + /** + * @param string $prefix + * @param string $base + * @param bool $includeRandomPart + * + * @return \Robo\Task\Filesystem\WorkDir + */ + protected function taskTmpDir($prefix = 'tmp', $base = '', $includeRandomPart = true) + { + return $this->task(TmpDir::class, $prefix, $base, $includeRandomPart); + } + + /** + * @param string $finalDestination + * + * @return \Robo\Task\Filesystem\TmpDir + */ + protected function taskWorkDir($finalDestination) + { + return $this->task(WorkDir::class, $finalDestination); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\CopyDir + */ + protected function taskCopyDir($dirs) + { + return $this->task(CopyDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\MirrorDir + */ + protected function taskMirrorDir($dirs) + { + return $this->task(MirrorDir::class, $dirs); + } + + /** + * @param string|string[] $dirs + * + * @return \Robo\Task\Filesystem\FlattenDir + */ + protected function taskFlattenDir($dirs) + { + return $this->task(FlattenDir::class, $dirs); + } + + /** + * @return \Robo\Task\Filesystem\FilesystemStack + */ + protected function taskFilesystemStack() + { + return $this->task(FilesystemStack::class); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Base.php new file mode 100644 index 00000000..42728673 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Base.php @@ -0,0 +1,97 @@ +option('silent'); + return $this; + } + + /** + * adds `--no-color` option to gulp + * + * @return $this + */ + public function noColor() + { + $this->option('no-color'); + return $this; + } + + /** + * adds `--color` option to gulp + * + * @return $this + */ + public function color() + { + $this->option('color'); + return $this; + } + + /** + * adds `--tasks-simple` option to gulp + * + * @return $this + */ + public function simple() + { + $this->option('tasks-simple'); + return $this; + } + + /** + * @param string $task + * @param null|string $pathToGulp + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($task, $pathToGulp = null) + { + $this->task = $task; + $this->command = $pathToGulp; + if (!$this->command) { + $this->command = $this->findExecutable('gulp'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Gulp executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} " . ProcessUtils::escapeArgument($this->task) . "{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Run.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Run.php new file mode 100644 index 00000000..8f2077b5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/Run.php @@ -0,0 +1,35 @@ +taskGulpRun()->run(); + * + * // run task 'clean' with --silent option + * $this->taskGulpRun('clean') + * ->silent() + * ->run(); + * ?> + * ``` + */ +class Run extends Base implements CommandInterface +{ + /** + * {@inheritdoc} + */ + public function run() + { + if (strlen($this->arguments)) { + $this->printTaskInfo('Running Gulp task: {gulp_task} with arguments: {arguments}', ['gulp_task' => $this->task, 'arguments' => $this->arguments]); + } else { + $this->printTaskInfo('Running Gulp task: {gulp_task} without arguments', ['gulp_task' => $this->task]); + } + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/loadTasks.php new file mode 100644 index 00000000..6fdc6ca7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Gulp/loadTasks.php @@ -0,0 +1,16 @@ +task(Run::class, $task, $pathToGulp); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Base.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Base.php new file mode 100644 index 00000000..35ff9c48 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Base.php @@ -0,0 +1,60 @@ +option('production'); + return $this; + } + + /** + * @param null|string $pathToNpm + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToNpm = null) + { + $this->command = $pathToNpm; + if (!$this->command) { + $this->command = $this->findExecutable('npm'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Npm executable not found."); + } + } + + /** + * @return string + */ + public function getCommand() + { + return "{$this->command} {$this->action}{$this->arguments}"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Install.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Install.php new file mode 100644 index 00000000..65cbe618 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Install.php @@ -0,0 +1,36 @@ +taskNpmInstall()->run(); + * + * // prefer dist with custom path + * $this->taskNpmInstall('path/to/my/npm') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Install extends Base implements CommandInterface +{ + /** + * @var string + */ + protected $action = 'install'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Install Npm packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Update.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Update.php new file mode 100644 index 00000000..75421b30 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/Update.php @@ -0,0 +1,34 @@ +taskNpmUpdate()->run(); + * + * // prefer dist with custom path + * $this->taskNpmUpdate('path/to/my/npm') + * ->noDev() + * ->run(); + * ?> + * ``` + */ +class Update extends Base +{ + /** + * @var string + */ + protected $action = 'update'; + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Update Npm packages: {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/loadTasks.php new file mode 100644 index 00000000..4d9a26eb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Npm/loadTasks.php @@ -0,0 +1,25 @@ +task(Install::class, $pathToNpm); + } + + /** + * @param null|string $pathToNpm + * + * @return \Robo\Task\Npm\Update + */ + protected function taskNpmUpdate($pathToNpm = null) + { + return $this->task(Update::class, $pathToNpm); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Rsync.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Rsync.php new file mode 100644 index 00000000..5c334af4 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Rsync.php @@ -0,0 +1,484 @@ +taskRsync() + * ->fromPath('src/') + * ->toHost('localhost') + * ->toUser('dev') + * ->toPath('/var/www/html/app/') + * ->remoteShell('ssh -i public_key') + * ->recursive() + * ->excludeVcs() + * ->checksum() + * ->wholeFile() + * ->verbose() + * ->progress() + * ->humanReadable() + * ->stats() + * ->run(); + * ``` + * + * You could also clone the task and do a dry-run first: + * + * ``` php + * $rsync = $this->taskRsync() + * ->fromPath('src/') + * ->toPath('example.com:/var/www/html/app/') + * ->archive() + * ->excludeVcs() + * ->progress() + * ->stats(); + * + * $dryRun = clone $rsync; + * $dryRun->dryRun()->run(); + * if ('y' === $this->ask('Do you want to run (y/n)')) { + * $rsync->run(); + * } + * ``` + */ +class Rsync extends BaseTask implements CommandInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string + */ + protected $fromUser; + + /** + * @var string + */ + protected $fromHost; + + /** + * @var string + */ + protected $fromPath; + + /** + * @var string + */ + protected $toUser; + + /** + * @var string + */ + protected $toHost; + + /** + * @var string + */ + protected $toPath; + + /** + * @return static + */ + public static function init() + { + return new static(); + } + + public function __construct() + { + $this->command = 'rsync'; + } + + /** + * This can either be a full rsync path spec (user@host:path) or just a path. + * In case of the former do not specify host and user. + * + * @param string|array $path + * + * @return $this + */ + public function fromPath($path) + { + $this->fromPath = $path; + + return $this; + } + + /** + * This can either be a full rsync path spec (user@host:path) or just a path. + * In case of the former do not specify host and user. + * + * @param string $path + * + * @return $this + */ + public function toPath($path) + { + $this->toPath = $path; + + return $this; + } + + /** + * @param string $fromUser + * + * @return $this + */ + public function fromUser($fromUser) + { + $this->fromUser = $fromUser; + return $this; + } + + /** + * @param string $fromHost + * + * @return $this + */ + public function fromHost($fromHost) + { + $this->fromHost = $fromHost; + return $this; + } + + /** + * @param string $toUser + * + * @return $this + */ + public function toUser($toUser) + { + $this->toUser = $toUser; + return $this; + } + + /** + * @param string $toHost + * + * @return $this + */ + public function toHost($toHost) + { + $this->toHost = $toHost; + return $this; + } + + /** + * @return $this + */ + public function progress() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function stats() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function recursive() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function verbose() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function checksum() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function archive() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function compress() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function owner() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function group() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function times() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @return $this + */ + public function delete() + { + $this->option(__FUNCTION__); + + return $this; + } + + /** + * @param int $seconds + * + * @return $this + */ + public function timeout($seconds) + { + $this->option(__FUNCTION__, $seconds); + + return $this; + } + + /** + * @return $this + */ + public function humanReadable() + { + $this->option('human-readable'); + + return $this; + } + + /** + * @return $this + */ + public function wholeFile() + { + $this->option('whole-file'); + + return $this; + } + + /** + * @return $this + */ + public function dryRun() + { + $this->option('dry-run'); + + return $this; + } + + /** + * @return $this + */ + public function itemizeChanges() + { + $this->option('itemize-changes'); + + return $this; + } + + /** + * Excludes .git, .svn and .hg items at any depth. + * + * @return $this + */ + public function excludeVcs() + { + return $this->exclude([ + '.git', + '.svn', + '.hg', + ]); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function exclude($pattern) + { + return $this->optionList(__FUNCTION__, $pattern); + } + + /** + * @param string $file + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function excludeFrom($file) + { + if (!is_readable($file)) { + throw new TaskException($this, "Exclude file $file is not readable"); + } + + return $this->option('exclude-from', $file); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function includeFilter($pattern) + { + return $this->optionList('include', $pattern); + } + + /** + * @param array|string $pattern + * + * @return $this + */ + public function filter($pattern) + { + return $this->optionList(__FUNCTION__, $pattern); + } + + /** + * @param string $file + * + * @return $this + * + * @throws \Robo\Exception\TaskException + */ + public function filesFrom($file) + { + if (!is_readable($file)) { + throw new TaskException($this, "Files-from file $file is not readable"); + } + + return $this->option('files-from', $file); + } + + /** + * @param string $command + * + * @return $this + */ + public function remoteShell($command) + { + $this->option('rsh', "'$command'"); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + + return $this->executeCommand($command); + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + foreach ((array)$this->fromPath as $from) { + $this->option(null, $this->getFromPathSpec($from)); + } + $this->option(null, $this->getToPathSpec()); + + return $this->command . $this->arguments; + } + + /** + * @return string + */ + protected function getFromPathSpec($from) + { + return $this->getPathSpec($this->fromHost, $this->fromUser, $from); + } + + /** + * @return string + */ + protected function getToPathSpec() + { + return $this->getPathSpec($this->toHost, $this->toUser, $this->toPath); + } + + /** + * @param string $host + * @param string $user + * @param string $path + * + * @return string + */ + protected function getPathSpec($host, $user, $path) + { + $spec = isset($path) ? $path : ''; + if (!empty($host)) { + $spec = "{$host}:{$spec}"; + } + if (!empty($user)) { + $spec = "{$user}@{$spec}"; + } + + return $spec; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Ssh.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Ssh.php new file mode 100644 index 00000000..69df9fe2 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/Ssh.php @@ -0,0 +1,273 @@ +taskSshExec('remote.example.com', 'user') + * ->remoteDir('/var/www/html') + * ->exec('ls -la') + * ->exec('chmod g+x logs') + * ->run(); + * + * ``` + * + * You can even exec other tasks (which implement CommandInterface): + * + * ```php + * $gitTask = $this->taskGitStack() + * ->checkout('master') + * ->pull(); + * + * $this->taskSshExec('remote.example.com') + * ->remoteDir('/var/www/html/site') + * ->exec($gitTask) + * ->run(); + * ``` + * + * You can configure the remote directory for all future calls: + * + * ```php + * \Robo\Task\Remote\Ssh::configure('remoteDir', '/some-dir'); + * ``` + */ +class Ssh extends BaseTask implements CommandInterface, SimulatedInterface +{ + use \Robo\Common\CommandReceiver; + use \Robo\Common\ExecOneCommand; + + /** + * @var null|string + */ + protected $hostname; + + /** + * @var null|string + */ + protected $user; + + /** + * @var bool + */ + protected $stopOnFail = true; + + /** + * @var array + */ + protected $exec = []; + + /** + * Changes to the given directory before running commands. + * + * @var string + */ + protected $remoteDir; + + /** + * @param null|string $hostname + * @param null|string $user + */ + public function __construct($hostname = null, $user = null) + { + $this->hostname = $hostname; + $this->user = $user; + } + + /** + * @param string $hostname + * + * @return $this + */ + public function hostname($hostname) + { + $this->hostname = $hostname; + return $this; + } + + /** + * @param string $user + * + * @return $this + */ + public function user($user) + { + $this->user = $user; + return $this; + } + + /** + * Whether or not to chain commands together with && and stop the chain if one command fails. + * + * @param bool $stopOnFail + * + * @return $this + */ + public function stopOnFail($stopOnFail = true) + { + $this->stopOnFail = $stopOnFail; + return $this; + } + + /** + * Changes to the given directory before running commands. + * + * @param string $remoteDir + * + * @return $this + */ + public function remoteDir($remoteDir) + { + $this->remoteDir = $remoteDir; + return $this; + } + + /** + * @param string $filename + * + * @return $this + */ + public function identityFile($filename) + { + $this->option('-i', $filename); + + return $this; + } + + /** + * @param int $port + * + * @return $this + */ + public function port($port) + { + $this->option('-p', $port); + + return $this; + } + + /** + * @return $this + */ + public function forcePseudoTty() + { + $this->option('-t'); + + return $this; + } + + /** + * @return $this + */ + public function quiet() + { + $this->option('-q'); + + return $this; + } + + /** + * @return $this + */ + public function verbose() + { + $this->option('-v'); + + return $this; + } + + /** + * @param string|string[]|CommandInterface $command + * + * @return $this + */ + public function exec($command) + { + if (is_array($command)) { + $command = implode(' ', array_filter($command)); + } + + $this->exec[] = $command; + + return $this; + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + $commands = []; + foreach ($this->exec as $command) { + $commands[] = $this->receiveCommand($command); + } + + $remoteDir = $this->remoteDir ? $this->remoteDir : $this->getConfigValue('remoteDir'); + if (!empty($remoteDir)) { + array_unshift($commands, sprintf('cd "%s"', $remoteDir)); + } + $command = implode($this->stopOnFail ? ' && ' : ' ; ', $commands); + + return $this->sshCommand($command); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->validateParameters(); + $command = $this->getCommand(); + return $this->executeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function simulate($context) + { + $command = $this->getCommand(); + $this->printTaskInfo("Running {command}", ['command' => $command] + $context); + } + + protected function validateParameters() + { + if (empty($this->hostname)) { + throw new TaskException($this, 'Please set a hostname'); + } + if (empty($this->exec)) { + throw new TaskException($this, 'Please add at least one command'); + } + } + + /** + * Returns an ssh command string running $command on the remote. + * + * @param string|CommandInterface $command + * + * @return string + */ + protected function sshCommand($command) + { + $command = $this->receiveCommand($command); + $sshOptions = $this->arguments; + $hostSpec = $this->hostname; + if ($this->user) { + $hostSpec = $this->user . '@' . $hostSpec; + } + + return "ssh{$sshOptions} {$hostSpec} '{$command}'"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/loadTasks.php new file mode 100644 index 00000000..092d2a55 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Remote/loadTasks.php @@ -0,0 +1,24 @@ +task(Rsync::class); + } + + /** + * @param null|string $hostname + * @param null|string $user + * + * @return \Robo\Task\Remote\Ssh + */ + protected function taskSshExec($hostname = null, $user = null) + { + return $this->task(Ssh::class, $hostname, $user); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Simulator.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Simulator.php new file mode 100644 index 00000000..e69d23fa --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Simulator.php @@ -0,0 +1,168 @@ +task = ($task instanceof WrappedTaskInterface) ? $task->original() : $task; + $this->constructorParameters = $constructorParameters; + } + + /** + * @param string $function + * @param array $args + * + * @return \Robo\Result|\Robo\Task\Simulator + */ + public function __call($function, $args) + { + $this->stack[] = array_merge([$function], $args); + $result = call_user_func_array([$this->task, $function], $args); + return $result == $this->task ? $this : $result; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $callchain = ''; + foreach ($this->stack as $action) { + $command = array_shift($action); + $parameters = $this->formatParameters($action); + $callchain .= "\n ->$command($parameters)"; + } + $context = $this->getTaskContext( + [ + '_level' => RoboLogLevel::SIMULATED_ACTION, + 'simulated' => TaskInfo::formatTaskName($this->task), + 'parameters' => $this->formatParameters($this->constructorParameters), + '_style' => ['simulated' => 'fg=blue;options=bold'], + ] + ); + + // RoboLogLevel::SIMULATED_ACTION + $this->printTaskInfo( + "Simulating {simulated}({parameters})$callchain", + $context + ); + + $result = null; + if ($this->task instanceof SimulatedInterface) { + $result = $this->task->simulate($context); + } + if (!isset($result)) { + $result = Result::success($this); + } + + return $result; + } + + /** + * Danger: reach through the simulated wrapper and pull out the command + * to be executed. This is used when using a simulated task with another + * simulated task that runs commands, e.g. the Remote\Ssh task. Using + * a simulated CommandInterface task with a non-simulated task may produce + * unexpected results (e.g. execution!). + * + * @return string + * + * @throws \Robo\Exception\TaskException + */ + public function getCommand() + { + if (!$this->task instanceof CommandInterface) { + throw new TaskException($this->task, 'Simulated task that is not a CommandInterface used as a CommandInterface.'); + } + return $this->task->getCommand(); + } + + /** + * @param string $action + * + * @return string + */ + protected function formatParameters($action) + { + $parameterList = array_map([$this, 'convertParameter'], $action); + return implode(', ', $parameterList); + } + + /** + * @param mixed $item + * + * @return string + */ + protected function convertParameter($item) + { + if (is_callable($item)) { + return 'inline_function(...)'; + } + if (is_array($item)) { + return $this->shortenParameter(var_export($item, true)); + } + if (is_object($item)) { + return '[' . get_class($item). ' object]'; + } + if (is_string($item)) { + return $this->shortenParameter("'$item'"); + } + if (is_null($item)) { + return 'null'; + } + return $item; + } + + /** + * @param string $item + * @param string $shortForm + * + * @return string + */ + protected function shortenParameter($item, $shortForm = '') + { + $maxLength = 80; + $tailLength = 20; + if (strlen($item) < $maxLength) { + return $item; + } + if (!empty($shortForm)) { + return $shortForm; + } + $item = trim($item); + $tail = preg_replace("#.*\n#ms", '', substr($item, -$tailLength)); + $head = preg_replace("#\n.*#ms", '', substr($item, 0, $maxLength - (strlen($tail) + 5))); + return "$head ... $tail"; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/StackBasedTask.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/StackBasedTask.php new file mode 100644 index 00000000..91659f33 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/StackBasedTask.php @@ -0,0 +1,236 @@ +friz() + * ->fraz() + * ->frob(); + * + * We presume that the existing library throws an exception on error. + * + * You want: + * + * $result = $this->taskFrobinator($a, $b, $c) + * ->friz() + * ->fraz() + * ->frob() + * ->run(); + * + * Execution is deferred until run(), and a Robo\Result instance is + * returned. Additionally, using Robo will covert Exceptions + * into RoboResult objects. + * + * To create a new Robo task: + * + * - Make a new class that extends StackBasedTask + * - Give it a constructor that creates a new Frobinator + * - Override getDelegate(), and return the Frobinator instance + * + * Finally, add your new class to loadTasks.php as usual, + * and you are all done. + * + * If you need to add any methods to your task that should run + * immediately (e.g. to set parameters used at run() time), just + * implement them in your derived class. + * + * If you need additional methods that should run deferred, just + * define them as 'protected function _foo()'. Then, users may + * call $this->taskFrobinator()->foo() to get deferred execution + * of _foo(). + */ +abstract class StackBasedTask extends BaseTask +{ + /** + * @var array + */ + protected $stack = []; + + /** + * @var bool + */ + protected $stopOnFail = true; + + /** + * @param bool $stop + * + * @return $this + */ + public function stopOnFail($stop = true) + { + $this->stopOnFail = $stop; + return $this; + } + + /** + * Derived classes should override the getDelegate() method, and + * return an instance of the API class being wrapped. When this + * is done, any method of the delegate is available as a method of + * this class. Calling one of the delegate's methods will defer + * execution until the run() method is called. + * + * @return null + */ + protected function getDelegate() + { + return null; + } + + /** + * Derived classes that have more than one delegate may override + * getCommandList to add as many delegate commands as desired to + * the list of potential functions that __call() tried to find. + * + * @param string $function + * + * @return array + */ + protected function getDelegateCommandList($function) + { + return [[$this, "_$function"], [$this->getDelegate(), $function]]; + } + + /** + * Print progress about the commands being executed + * + * @param string $command + * @param string $action + */ + protected function printTaskProgress($command, $action) + { + $this->printTaskInfo('{command} {action}', ['command' => "{$command[1]}", 'action' => json_encode($action, JSON_UNESCAPED_SLASHES)]); + } + + /** + * Derived classes can override processResult to add more + * logic to result handling from functions. By default, it + * is assumed that if a function returns in int, then + * 0 == success, and any other value is the error code. + * + * @param int|\Robo\Result $function_result + * + * @return \Robo\Result + */ + protected function processResult($function_result) + { + if (is_int($function_result)) { + if ($function_result) { + return Result::error($this, $function_result); + } + } + return Result::success($this); + } + + /** + * Record a function to call later. + * + * @param string $command + * @param array $args + * + * @return $this + */ + protected function addToCommandStack($command, $args) + { + $this->stack[] = array_merge([$command], $args); + return $this; + } + + /** + * Any API function provided by the delegate that executes immediately + * may be handled by __call automatically. These operations will all + * be deferred until this task's run() method is called. + * + * @param string $function + * @param array $args + * + * @return $this + */ + public function __call($function, $args) + { + foreach ($this->getDelegateCommandList($function) as $command) { + if (method_exists($command[0], $command[1])) { + // Otherwise, we'll defer calling this function + // until run(), and return $this. + $this->addToCommandStack($command, $args); + return $this; + } + } + + $message = "Method $function does not exist.\n"; + throw new \BadMethodCallException($message); + } + + /** + * @return int + */ + public function progressIndicatorSteps() + { + // run() will call advanceProgressIndicator() once for each + // file, one after calling stopBuffering, and again after compression. + return count($this->stack); + } + + /** + * Run all of the queued objects on the stack + * + * @return \Robo\Result + */ + public function run() + { + $this->startProgressIndicator(); + $result = Result::success($this); + + foreach ($this->stack as $action) { + $command = array_shift($action); + $this->printTaskProgress($command, $action); + $this->advanceProgressIndicator(); + // TODO: merge data from the result on this call + // with data from the result on the previous call? + // For now, the result always comes from the last function. + $result = $this->callTaskMethod($command, $action); + if ($this->stopOnFail && $result && !$result->wasSuccessful()) { + break; + } + } + + $this->stopProgressIndicator(); + + // todo: add timing information to the result + return $result; + } + + /** + * Execute one task method + * + * @param string $command + * @param string $action + * + * @return \Robo\Result + */ + protected function callTaskMethod($command, $action) + { + try { + $function_result = call_user_func_array($command, $action); + return $this->processResult($function_result); + } catch (\Exception $e) { + $this->printTaskError($e->getMessage()); + return Result::fromException($this, $e); + } + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Atoum.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Atoum.php new file mode 100644 index 00000000..56b47d84 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Atoum.php @@ -0,0 +1,184 @@ +taskAtoum() + * ->files('path/to/test.php') + * ->configFile('config/dev.php') + * ->run() + * + * ?> + * ``` + */ +class Atoum extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * Atoum constructor. + * + * @param null|string $pathToAtoum + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToAtoum = null) + { + $this->command = $pathToAtoum; + if (!$this->command) { + $this->command = $this->findExecutable('atoum'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither local atoum nor global composer installation not found"); + } + } + + /** + * Tag or Tags to filter. + * + * @param string|array $tags + * + * @return $this + */ + public function tags($tags) + { + return $this->addMultipleOption('tags', $tags); + } + + /** + * Display result using the light reporter. + * + * @return $this + */ + public function lightReport() + { + $this->option("--use-light-report"); + + return $this; + } + + /** + * Display result using the tap reporter. + * + * @return $this + */ + public function tap() + { + $this->option("use-tap-report"); + + return $this; + } + + /** + * Path to the bootstrap file. + + * @param string $file + * + * @return $this + */ + public function bootstrap($file) + { + $this->option("bootstrap", $file); + + return $this; + } + + /** + * Path to the config file. + * + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option('-c', $file); + + return $this; + } + + /** + * Use atoum's debug mode. + * + * @return $this + */ + public function debug() + { + $this->option("debug"); + + return $this; + } + + /** + * Test file or test files to run. + * + * @param string|array + * + * @return $this + */ + public function files($files) + { + return $this->addMultipleOption('f', $files); + } + + /** + * Test directory or directories to run. + * + * @param string|array A single directory or a list of directories. + * + * @return $this + */ + public function directories($directories) + { + return $this->addMultipleOption('directories', $directories); + } + + /** + * @param string $option + * @param string|array $values + * + * @return $this + */ + protected function addMultipleOption($option, $values) + { + if (is_string($values)) { + $values = [$values]; + } + + foreach ($values as $value) { + $this->option($option, $value); + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running atoum ' . $this->arguments); + + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Behat.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Behat.php new file mode 100644 index 00000000..7e4f1d41 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Behat.php @@ -0,0 +1,163 @@ +taskBehat() + * ->format('pretty') + * ->noInteraction() + * ->run(); + * ?> + * ``` + * + */ +class Behat extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string[] $formaters available formaters for format option + */ + protected $formaters = ['progress', 'pretty', 'junit']; + + /** + * @var string[] $verbose_levels available verbose levels + */ + protected $verbose_levels = ['v', 'vv']; + + /** + * Behat constructor. + * + * @param null|string $pathToBehat + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToBehat = null) + { + $this->command = $pathToBehat; + if (!$this->command) { + $this->command = $this->findExecutable('behat'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Behat found"); + } + } + + /** + * @return $this + */ + public function stopOnFail() + { + $this->option('stop-on-failure'); + return $this; + } + + /** + * @return $this + */ + public function noInteraction() + { + $this->option('no-interaction'); + return $this; + } + + /** + * @param $config_file + * + * @return $this + */ + public function config($config_file) + { + $this->option('config', $config_file); + return $this; + } + + /** + * @return $this + */ + public function colors() + { + $this->option('colors'); + return $this; + } + + /** + * @return $this + */ + public function noColors() + { + $this->option('no-colors'); + return $this; + } + + /** + * @param string $suite + * + * @return $this + */ + public function suite($suite) + { + $this->option('suite', $suite); + return $this; + } + + /** + * @param string $level + * + * @return $this + */ + public function verbose($level = 'v') + { + if (!in_array($level, $this->verbose_levels)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels)); + } + $this->option('-' . $level); + return $this; + } + + /** + * @param string $formater + * + * @return $this + */ + public function format($formater) + { + if (!in_array($formater, $this->formaters)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters)); + } + $this->option('format', $formater); + return $this; + } + + /** + * Returns command that can be executed. + * This method is used to pass generated command from one task to another. + * + * @return string + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running behat {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Codecept.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Codecept.php new file mode 100644 index 00000000..1f8cce70 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Codecept.php @@ -0,0 +1,271 @@ +taskCodecept() + * ->suite('acceptance') + * ->env('chrome') + * ->group('admin') + * ->xml() + * ->html() + * ->run(); + * + * ?> + * ``` + * + */ +class Codecept extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @param string $pathToCodeception + * + * @throws \Robo\Exception\TaskException + */ + public function __construct($pathToCodeception = '') + { + $this->command = $pathToCodeception; + if (!$this->command) { + $this->command = $this->findExecutable('codecept'); + } + if (!$this->command) { + throw new TaskException(__CLASS__, "Neither composer nor phar installation of Codeception found."); + } + $this->command .= ' run'; + } + + /** + * @param string $suite + * + * @return $this + */ + public function suite($suite) + { + $this->option(null, $suite); + return $this; + } + + /** + * @param string $testName + * + * @return $this + */ + public function test($testName) + { + $this->option(null, $testName); + return $this; + } + + /** + * set group option. Can be called multiple times + * + * @param string $group + * + * @return $this + */ + public function group($group) + { + $this->option("group", $group); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function excludeGroup($group) + { + $this->option("skip-group", $group); + return $this; + } + + /** + * generate json report + * + * @param string $file + * + * @return $this + */ + public function json($file = null) + { + $this->option("json", $file); + return $this; + } + + /** + * generate xml JUnit report + * + * @param string $file + * + * @return $this + */ + public function xml($file = null) + { + $this->option("xml", $file); + return $this; + } + + /** + * Generate html report + * + * @param string $dir + * + * @return $this + */ + public function html($dir = null) + { + $this->option("html", $dir); + return $this; + } + + /** + * generate tap report + * + * @param string $file + * + * @return $this + */ + public function tap($file = null) + { + $this->option("tap", $file); + return $this; + } + + /** + * provides config file other then default `codeception.yml` with `-c` option + * + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option("-c", $file); + return $this; + } + + /** + * collect codecoverage in raw format. You may pass name of cov file to save results + * + * @param null|string $cov + * + * @return $this + */ + public function coverage($cov = null) + { + $this->option("coverage", $cov); + return $this; + } + + /** + * execute in silent mode + * + * @return $this + */ + public function silent() + { + $this->option("silent"); + return $this; + } + + /** + * collect code coverage in xml format. You may pass name of xml file to save results + * + * @param string $xml + * + * @return $this + */ + public function coverageXml($xml = null) + { + $this->option("coverage-xml", $xml); + return $this; + } + + /** + * collect code coverage and generate html report. You may pass + * + * @param string $html + * + * @return $this + */ + public function coverageHtml($html = null) + { + $this->option("coverage-html", $html); + return $this; + } + + /** + * @param string $env + * + * @return $this + */ + public function env($env) + { + $this->option("env", $env); + return $this; + } + + /** + * @return $this + */ + public function debug() + { + $this->option("debug"); + return $this; + } + + /** + * @return $this + */ + public function noRebuild() + { + $this->option("no-rebuild"); + return $this; + } + + /** + * @param string $failGroup + * @return $this + */ + public function failGroup($failGroup) + { + $this->option('override', "extensions: config: Codeception\\Extension\\RunFailed: fail-group: {$failGroup}"); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $command = $this->getCommand(); + $this->printTaskInfo('Executing {command}', ['command' => $command]); + return $this->executeCommand($command); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/PHPUnit.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/PHPUnit.php new file mode 100644 index 00000000..df67e1c7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/PHPUnit.php @@ -0,0 +1,199 @@ +taskPHPUnit() + * ->group('core') + * ->bootstrap('test/bootstrap.php') + * ->run() + * + * ?> + * ``` + */ +class PHPUnit extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * Directory of test files or single test file to run. Appended to + * the command and arguments. + * + * @var string + */ + protected $files = ''; + + public function __construct($pathToPhpUnit = null) + { + $this->command = $pathToPhpUnit; + if (!$this->command) { + $this->command = $this->findExecutablePhar('phpunit'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither local phpunit nor global composer installation not found"); + } + } + + /** + * @param string $filter + * + * @return $this + */ + public function filter($filter) + { + $this->option('filter', $filter); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function group($group) + { + $this->option("group", $group); + return $this; + } + + /** + * @param string $group + * + * @return $this + */ + public function excludeGroup($group) + { + $this->option("exclude-group", $group); + return $this; + } + + /** + * adds `log-json` option to runner + * + * @param string $file + * + * @return $this + */ + public function json($file = null) + { + $this->option("log-json", $file); + return $this; + } + + /** + * adds `log-junit` option + * + * @param string $file + * + * @return $this + */ + public function xml($file = null) + { + $this->option("log-junit", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function tap($file = "") + { + $this->option("log-tap", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function bootstrap($file) + { + $this->option("bootstrap", $file); + return $this; + } + + /** + * @param string $file + * + * @return $this + */ + public function configFile($file) + { + $this->option('-c', $file); + return $this; + } + + /** + * @return $this + */ + public function debug() + { + $this->option("debug"); + return $this; + } + + /** + * Directory of test files or single test file to run. + * + * @param string $files A single test file or a directory containing test files. + * + * @return $this + * + * @throws \Robo\Exception\TaskException + * + * @deprecated Use file() or dir() method instead + */ + public function files($files) + { + if (!empty($this->files) || is_array($files)) { + throw new \Robo\Exception\TaskException(__CLASS__, "Only one file or directory may be provided."); + } + $this->files = ' ' . $files; + + return $this; + } + + /** + * Test the provided file. + * + * @param string $file path to file to test + * + * @return $this + */ + public function file($file) + { + return $this->files($file); + } + + /** + * {@inheritdoc} + */ + public function getCommand() + { + return $this->command . $this->arguments . $this->files; + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running PHPUnit {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Phpspec.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Phpspec.php new file mode 100644 index 00000000..dd6a5ae7 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/Phpspec.php @@ -0,0 +1,116 @@ +taskPhpspec() + * ->format('pretty') + * ->noInteraction() + * ->run(); + * ?> + * ``` + * + */ +class Phpspec extends BaseTask implements CommandInterface, PrintedInterface +{ + use \Robo\Common\ExecOneCommand; + + /** + * @var string + */ + protected $command; + + /** + * @var string[] $formaters available formaters for format option + */ + protected $formaters = ['progress', 'html', 'pretty', 'junit', 'dot', 'tap']; + + /** + * @var array $verbose_levels available verbose levels + */ + protected $verbose_levels = ['v', 'vv', 'vvv']; + + public function __construct($pathToPhpspec = null) + { + $this->command = $pathToPhpspec; + if (!$this->command) { + $this->command = $this->findExecutable('phpspec'); + } + if (!$this->command) { + throw new \Robo\Exception\TaskException(__CLASS__, "Neither composer nor phar installation of Phpspec found"); + } + $this->arg('run'); + } + + public function stopOnFail() + { + $this->option('stop-on-failure'); + return $this; + } + + public function noCodeGeneration() + { + $this->option('no-code-generation'); + return $this; + } + + public function quiet() + { + $this->option('quiet'); + return $this; + } + + public function verbose($level = 'v') + { + if (!in_array($level, $this->verbose_levels)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->verbose_levels)); + } + $this->option('-' . $level); + return $this; + } + + public function noAnsi() + { + $this->option('no-ansi'); + return $this; + } + + public function noInteraction() + { + $this->option('no-interaction'); + return $this; + } + + public function config($config_file) + { + $this->option('config', $config_file); + return $this; + } + + public function format($formater) + { + if (!in_array($formater, $this->formaters)) { + throw new \InvalidArgumentException('expected ' . implode(',', $this->formaters)); + } + $this->option('format', $formater); + return $this; + } + + public function getCommand() + { + return $this->command . $this->arguments; + } + + public function run() + { + $this->printTaskInfo('Running phpspec {arguments}', ['arguments' => $this->arguments]); + return $this->executeCommand($this->getCommand()); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/loadTasks.php new file mode 100644 index 00000000..43145b9b --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Testing/loadTasks.php @@ -0,0 +1,55 @@ +task(Codecept::class, $pathToCodeception); + } + + /** + * @param null|string $pathToPhpUnit + * + * @return \Robo\Task\Testing\PHPUnit + */ + protected function taskPhpUnit($pathToPhpUnit = null) + { + return $this->task(PHPUnit::class, $pathToPhpUnit); + } + + /** + * @param null $pathToPhpspec + * + * @return \Robo\Task\Testing\Phpspec + */ + protected function taskPhpspec($pathToPhpspec = null) + { + return $this->task(Phpspec::class, $pathToPhpspec); + } + + /** + * @param null $pathToAtoum + * + * @return \Robo\Task\Testing\Atoum + */ + protected function taskAtoum($pathToAtoum = null) + { + return $this->task(Atoum::class, $pathToAtoum); + } + + /** + * @param null $pathToBehat + * + * @return \Robo\Task\Testing\Behat + */ + protected function taskBehat($pathToBehat = null) + { + return $this->task(Behat::class, $pathToBehat); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/GitStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/GitStack.php new file mode 100644 index 00000000..6cb1783f --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/GitStack.php @@ -0,0 +1,177 @@ +taskGitStack() + * ->stopOnFail() + * ->add('-A') + * ->commit('adding everything') + * ->push('origin','master') + * ->tag('0.6.0') + * ->push('origin','0.6.0') + * ->run() + * + * $this->taskGitStack() + * ->stopOnFail() + * ->add('doc/*') + * ->commit('doc updated') + * ->push() + * ->run(); + * ?> + * ``` + */ +class GitStack extends CommandStack +{ + /** + * @param string $pathToGit + */ + public function __construct($pathToGit = 'git') + { + $this->executable = $pathToGit; + } + + /** + * Executes `git clone` + * + * @param string $repo + * @param string $to + * + * @return $this + */ + public function cloneRepo($repo, $to = "", $branch = "") + { + $cmd = ['clone', $repo, $to]; + if (!empty($branch)) { + $cmd[] = "--branch $branch"; + } + return $this->exec($cmd); + } + + /** + * Executes `git clone` with depth 1 as default + * + * @param string $repo + * @param string $to + * @param string $branch + * @param int $depth + * + * @return $this + */ + public function cloneShallow($repo, $to = '', $branch = "", $depth = 1) + { + $cmd = ["clone --depth $depth", $repo, $to]; + if (!empty($branch)) { + $cmd[] = "--branch $branch"; + } + + return $this->exec($cmd); + } + + /** + * Executes `git add` command with files to add pattern + * + * @param string $pattern + * + * @return $this + */ + public function add($pattern) + { + return $this->exec([__FUNCTION__, $pattern]); + } + + /** + * Executes `git commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = "") + { + $message = ProcessUtils::escapeArgument($message); + return $this->exec([__FUNCTION__, "-m $message", $options]); + } + + /** + * Executes `git pull` command. + * + * @param string $origin + * @param string $branch + * + * @return $this + */ + public function pull($origin = '', $branch = '') + { + return $this->exec([__FUNCTION__, $origin, $branch]); + } + + /** + * Executes `git push` command + * + * @param string $origin + * @param string $branch + * + * @return $this + */ + public function push($origin = '', $branch = '') + { + return $this->exec([__FUNCTION__, $origin, $branch]); + } + + /** + * Performs git merge + * + * @param string $branch + * + * @return $this + */ + public function merge($branch) + { + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `git checkout` command + * + * @param string $branch + * + * @return $this + */ + public function checkout($branch) + { + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `git tag` command + * + * @param string $tag_name + * @param string $message + * + * @return $this + */ + public function tag($tag_name, $message = "") + { + if ($message != "") { + $message = "-m '$message'"; + } + return $this->exec([__FUNCTION__, $message, $tag_name]); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo("Running git commands..."); + return parent::run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/HgStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/HgStack.php new file mode 100644 index 00000000..71cc0ca9 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/HgStack.php @@ -0,0 +1,153 @@ +hgStack + * ->cloneRepo('https://bitbucket.org/durin42/hgsubversion') + * ->pull() + * ->add() + * ->commit('changed') + * ->push() + * ->tag('0.6.0') + * ->push('0.6.0') + * ->run(); + * ?> + * ``` + */ +class HgStack extends CommandStack +{ + + /** + * @param string $pathToHg + */ + public function __construct($pathToHg = 'hg') + { + $this->executable = $pathToHg; + } + + /** + * Executes `hg clone` + * + * @param string $repo + * @param string $to + * + * @return $this + */ + public function cloneRepo($repo, $to = '') + { + return $this->exec(['clone', $repo, $to]); + } + + /** + * Executes `hg add` command with files to add by pattern + * + * @param string $include + * @param string $exclude + * + * @return $this + */ + public function add($include = '', $exclude = '') + { + if (strlen($include) > 0) { + $include = "-I {$include}"; + } + + if (strlen($exclude) > 0) { + $exclude = "-X {$exclude}"; + } + + return $this->exec([__FUNCTION__, $include, $exclude]); + } + + /** + * Executes `hg commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = '') + { + return $this->exec([__FUNCTION__, "-m '{$message}'", $options]); + } + + /** + * Executes `hg pull` command. + * + * @param string $branch + * + * @return $this + */ + public function pull($branch = '') + { + if (strlen($branch) > 0) { + $branch = "-b '{$branch}''"; + } + + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Executes `hg push` command + * + * @param string $branch + * + * @return $this + */ + public function push($branch = '') + { + if (strlen($branch) > 0) { + $branch = "-b '{$branch}'"; + } + + return $this->exec([__FUNCTION__, $branch]); + } + + /** + * Performs hg merge + * + * @param string $revision + * + * @return $this + */ + public function merge($revision = '') + { + if (strlen($revision) > 0) { + $revision = "-r {$revision}"; + } + + return $this->exec([__FUNCTION__, $revision]); + } + + /** + * Executes `hg tag` command + * + * @param string $tag_name + * @param string $message + * + * @return $this + */ + public function tag($tag_name, $message = '') + { + if ($message !== '') { + $message = "-m '{$message}'"; + } + return $this->exec([__FUNCTION__, $message, $tag_name]); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->printTaskInfo('Running hg commands...'); + return parent::run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/SvnStack.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/SvnStack.php new file mode 100644 index 00000000..ec719b53 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/SvnStack.php @@ -0,0 +1,106 @@ +taskSvnStack() + * ->checkout('http://svn.collab.net/repos/svn/trunk') + * ->run() + * + * // alternatively + * $this->_svnCheckout('http://svn.collab.net/repos/svn/trunk'); + * + * $this->taskSvnStack('username', 'password') + * ->stopOnFail() + * ->update() + * ->add('doc/*') + * ->commit('doc updated') + * ->run(); + * ?> + * ``` + */ +class SvnStack extends CommandStack implements CommandInterface +{ + /** + * @var bool + */ + protected $stopOnFail = false; + + /** + * @var \Robo\Result + */ + protected $result; + + /** + * @param string $username + * @param string $password + * @param string $pathToSvn + */ + public function __construct($username = '', $password = '', $pathToSvn = 'svn') + { + $this->executable = $pathToSvn; + if (!empty($username)) { + $this->executable .= " --username $username"; + } + if (!empty($password)) { + $this->executable .= " --password $password"; + } + $this->result = Result::success($this); + } + + /** + * Updates `svn update` command + * + * @param string $path + * + * @return $this; + */ + public function update($path = '') + { + return $this->exec("update $path"); + } + + /** + * Executes `svn add` command with files to add pattern + * + * @param string $pattern + * + * @return $this + */ + public function add($pattern = '') + { + return $this->exec("add $pattern"); + } + + /** + * Executes `svn commit` command with a message + * + * @param string $message + * @param string $options + * + * @return $this + */ + public function commit($message, $options = "") + { + return $this->exec("commit -m '$message' $options"); + } + + /** + * Executes `svn checkout` command + * + * @param string $branch + * + * @return $this + */ + public function checkout($branch) + { + return $this->exec("checkout $branch"); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadShortcuts.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadShortcuts.php new file mode 100644 index 00000000..7d64ab58 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadShortcuts.php @@ -0,0 +1,35 @@ +taskSvnStack()->checkout($url)->run(); + } + + /** + * @param string $url + * + * @return \Robo\Result + */ + protected function _gitClone($url) + { + return $this->taskGitStack()->cloneRepo($url)->run(); + } + + /** + * @param string $url + * + * @return \Robo\Result + */ + protected function _hgClone($url) + { + return $this->taskHgStack()->cloneRepo($url)->run(); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadTasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadTasks.php new file mode 100644 index 00000000..6dd06228 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Task/Vcs/loadTasks.php @@ -0,0 +1,37 @@ +task(SvnStack::class, $username, $password, $pathToSvn); + } + + /** + * @param string $pathToGit + * + * @return \Robo\Task\Vcs\GitStack + */ + protected function taskGitStack($pathToGit = 'git') + { + return $this->task(GitStack::class, $pathToGit); + } + + /** + * @param string $pathToHg + * + * @return \Robo\Task\Vcs\HgStack + */ + protected function taskHgStack($pathToHg = 'hg') + { + return $this->task(HgStack::class, $pathToHg); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskAccessor.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskAccessor.php new file mode 100644 index 00000000..e65cd3eb --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskAccessor.php @@ -0,0 +1,47 @@ +task(Foo::class, $a, $b); + * + * instead of: + * + * $this->taskFoo($a, $b); + * + * The later form is preferred. + * + * @return \Robo\Collection\CollectionBuilder + */ + protected function task() + { + $args = func_get_args(); + $name = array_shift($args); + + $collectionBuilder = $this->collectionBuilder(); + return $collectionBuilder->build($name, $args); + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskInfo.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskInfo.php new file mode 100644 index 00000000..ce59c2d5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/TaskInfo.php @@ -0,0 +1,35 @@ + TaskInfo::formatTaskName($task), + 'task' => $task, + ]; + } + + /** + * @param object $task + * + * @return string + */ + public static function formatTaskName($task) + { + $name = get_class($task); + $name = preg_replace('~Stack^~', '', $name); + $name = str_replace('Robo\\Task\Base\\', '', $name); + $name = str_replace('Robo\\Task\\', '', $name); + $name = str_replace('Robo\\Collection\\', '', $name); + return $name; + } +} diff --git a/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Tasks.php b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Tasks.php new file mode 100644 index 00000000..2822d7d5 --- /dev/null +++ b/core/lib/composer/vendor/consolidation/robo/scenarios/symfony4/src/Tasks.php @@ -0,0 +1,23 @@ +export(); + } + + /** + * Performs the actual property expansion. + * + * @param Data $data + * A data object, containing the $array. + * @param array $array + * The original, unmodified array. + * @param string $parent_keys + * The parent keys of the current key in dot notation. This is used to + * track the absolute path to the current key in recursive cases. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + */ + protected static function doExpandArrayProperties( + $data, + $array, + $parent_keys = '', + $reference_data = null + ) { + foreach ($array as $key => $value) { + // Boundary condition(s). + if (is_null($value) || is_bool($value)) { + continue; + } + // Recursive case. + if (is_array($value)) { + self::doExpandArrayProperties($data, $value, $parent_keys . "$key.", $reference_data); + } // Base case. + else { + self::expandStringProperties($data, $parent_keys, $reference_data, $value, $key); + } + } + } + + /** + * Expand a single property. + * + * @param Data $data + * A data object, containing the $array. + * @param string $parent_keys + * The parent keys of the current key in dot notation. This is used to + * track the absolute path to the current key in recursive cases. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * @param string $value + * The unexpanded property value. + * @param string $key + * The immediate key of the property. + * + * @return mixed + */ + protected static function expandStringProperties( + $data, + $parent_keys, + $reference_data, + $value, + $key + ) { + // We loop through all placeholders in a given string. + // E.g., '${placeholder1} ${placeholder2}' requires two replacements. + while (strpos($value, '${') !== false) { + $original_value = $value; + $value = preg_replace_callback( + '/\$\{([^\$}]+)\}/', + function ($matches) use ($data, $reference_data) { + return self::expandStringPropertiesCallback( + $matches, + $data, + $reference_data + ); + }, + $value + ); + + // If no replacement occurred at all, break to prevent + // infinite loop. + if ($original_value == $value) { + break; + } + + // Set value on $data object. + if ($parent_keys) { + $full_key = $parent_keys . "$key"; + } else { + $full_key = $key; + } + $data->set($full_key, $value); + } + return $value; + } + + /** + * Expansion callback used by preg_replace_callback() in expandProperty(). + * + * @param array $matches + * An array of matches created by preg_replace_callback(). + * @param Data $data + * A data object containing the complete array being operated upon. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * + * @return mixed + */ + public static function expandStringPropertiesCallback( + $matches, + $data, + $reference_data = null + ) { + $property_name = $matches[1]; + $unexpanded_value = $matches[0]; + + // Use only values within the subject array's data. + if (!$reference_data) { + return self::expandProperty($property_name, $unexpanded_value, $data); + } // Search both the subject array's data and the reference data for a value. + else { + return self::expandPropertyWithReferenceData( + $property_name, + $unexpanded_value, + $data, + $reference_data + ); + } + } + + /** + * Searches both the subject data and the reference data for value. + * + * @param string $property_name + * The name of the value for which to search. + * @param string $unexpanded_value + * The original, unexpanded value, containing the placeholder. + * @param Data $data + * A data object containing the complete array being operated upon. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * + * @return string + * The expanded string. + */ + public static function expandPropertyWithReferenceData( + $property_name, + $unexpanded_value, + $data, + $reference_data + ) { + $expanded_value = self::expandProperty( + $property_name, + $unexpanded_value, + $data + ); + // If the string was not changed using the subject data, try using + // the reference data. + if ($expanded_value == $unexpanded_value) { + $expanded_value = self::expandProperty( + $property_name, + $unexpanded_value, + $reference_data + ); + } + + return $expanded_value; + } + + /** + * Searches a data object for a value. + * + * @param string $property_name + * The name of the value for which to search. + * @param string $unexpanded_value + * The original, unexpanded value, containing the placeholder. + * @param Data $data + * A data object containing possible replacement values. + * + * @return mixed + */ + public static function expandProperty($property_name, $unexpanded_value, $data) + { + if (strpos($property_name, "env.") === 0 && + !$data->has($property_name)) { + $env_key = substr($property_name, 4); + if (getenv($env_key)) { + $data->set($property_name, getenv($env_key)); + } + } + + if (!$data->has($property_name)) { + self::log("Property \${'$property_name'} could not be expanded."); + return $unexpanded_value; + } else { + $expanded_value = $data->get($property_name); + if (is_array($expanded_value)) { + $expanded_value = Yaml::dump($expanded_value, 0); + return $expanded_value; + } + self::log("Expanding property \${'$property_name'} => $expanded_value."); + return $expanded_value; + } + } + + /** + * @param $message + */ + public static function log($message) + { + // print "$message\n"; + } +} diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests deleted file mode 120000 index c2ebfe53..00000000 --- a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests \ No newline at end of file diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/phpunit/ExpanderTest.php b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/phpunit/ExpanderTest.php new file mode 100644 index 00000000..291d00cc --- /dev/null +++ b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/phpunit/ExpanderTest.php @@ -0,0 +1,99 @@ +assertEquals('gomjabbar', $expanded['env-test']); + $this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']); + $this->assertEquals('Paul Atreides', $expanded['book']['protaganist']); + $this->assertEquals('Dune by Frank Herbert', $expanded['summary']); + $this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']); + $this->assertEquals('Dune', $expanded['product-name']); + $this->assertEquals(Yaml::dump($array['inline-array'], 0), $expanded['expand-array']); + + $expanded = Expander::expandArrayProperties($array, $reference_array); + $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); + $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); + } + + /** + * Tests Expander::parse(). + * + * @param string $filename + * @param array $reference_array + * + * @dataProvider providerYaml + */ + public function testParse($filename, $reference_array) + { + $yaml_string = file_get_contents(__DIR__ . "/../resources/$filename"); + $expanded = Expander::parse($yaml_string); + $this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']); + $this->assertEquals('Paul Atreides', $expanded['book']['protaganist']); + $this->assertEquals('Dune by Frank Herbert', $expanded['summary']); + $this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']); + + $expanded = Expander::parse($yaml_string, $reference_array); + $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); + $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); + } + + /** + * @return array + * An array of values to test. + */ + public function providerYaml() + { + return [ + ['valid.yml', [ + 'book' => [ + 'sequel' => 'Dune Messiah' + ] + ]], + ]; + } + + /** + * Tests Expander::expandProperty(). + * + * @dataProvider providerTestExpandProperty + */ + public function testExpandProperty($array, $property_name, $unexpanded_string, $expected) + { + $data = new Data($array); + $expanded_value = Expander::expandProperty($property_name, $unexpanded_string, $data); + + $this->assertEquals($expected, $expanded_value); + } + + /** + * @return array + */ + public function providerTestExpandProperty() + { + return [ + [ ['author' => 'Frank Herbert'], 'author', '${author}', 'Frank Herbert' ], + [ ['book' => ['author' => 'Frank Herbert' ]], 'book.author', '${book.author}', 'Frank Herbert' ], + ]; + } +} diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/resources/valid.yml b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/resources/valid.yml new file mode 100644 index 00000000..78e4bc61 --- /dev/null +++ b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony2/tests/resources/valid.yml @@ -0,0 +1,35 @@ +# This file should contain only valid YAML. +type: book +book: + title: Dune + author: Frank Herbert + copyright: ${book.author} 1965 + protaganist: ${characters.0.name} + media: + - hardcover + # Use a nested key to reference an external value. + nested-reference: ${book.sequel} +characters: + - name: Paul Atreides + occupation: Kwisatz Haderach + aliases: + - Usul + - Muad'Dib + - The Preacher + - name: Duncan Idaho + occupation: Swordmaster +summary: ${book.title} by ${book.author} +# This is a complete fake property. +publisher: ${not.real.property} +# series.books is not defined in this YAML file, but is passed in to the parser by the application. +sequels: ${book.sequel}, and others. +# Reference one real value and one fake value. +available-products: ${book.media.1}, ${book.media.0} +# Nested property, should resolve to ${book.title} and then 'Dune'. +product-name: ${${type}.title} +# Represent a few more data types and formats. +boolean-value: true +null-value: null +inline-array: [ one, two, three ] +expand-array: ${inline-array} +env-test: ${env.test} \ No newline at end of file diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src deleted file mode 120000 index 929cb3dc..00000000 --- a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src +++ /dev/null @@ -1 +0,0 @@ -../../src \ No newline at end of file diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src/Expander.php b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src/Expander.php new file mode 100644 index 00000000..d922db59 --- /dev/null +++ b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/src/Expander.php @@ -0,0 +1,273 @@ +export(); + } + + /** + * Performs the actual property expansion. + * + * @param Data $data + * A data object, containing the $array. + * @param array $array + * The original, unmodified array. + * @param string $parent_keys + * The parent keys of the current key in dot notation. This is used to + * track the absolute path to the current key in recursive cases. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + */ + protected static function doExpandArrayProperties( + $data, + $array, + $parent_keys = '', + $reference_data = null + ) { + foreach ($array as $key => $value) { + // Boundary condition(s). + if (is_null($value) || is_bool($value)) { + continue; + } + // Recursive case. + if (is_array($value)) { + self::doExpandArrayProperties($data, $value, $parent_keys . "$key.", $reference_data); + } // Base case. + else { + self::expandStringProperties($data, $parent_keys, $reference_data, $value, $key); + } + } + } + + /** + * Expand a single property. + * + * @param Data $data + * A data object, containing the $array. + * @param string $parent_keys + * The parent keys of the current key in dot notation. This is used to + * track the absolute path to the current key in recursive cases. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * @param string $value + * The unexpanded property value. + * @param string $key + * The immediate key of the property. + * + * @return mixed + */ + protected static function expandStringProperties( + $data, + $parent_keys, + $reference_data, + $value, + $key + ) { + // We loop through all placeholders in a given string. + // E.g., '${placeholder1} ${placeholder2}' requires two replacements. + while (strpos($value, '${') !== false) { + $original_value = $value; + $value = preg_replace_callback( + '/\$\{([^\$}]+)\}/', + function ($matches) use ($data, $reference_data) { + return self::expandStringPropertiesCallback( + $matches, + $data, + $reference_data + ); + }, + $value + ); + + // If no replacement occurred at all, break to prevent + // infinite loop. + if ($original_value == $value) { + break; + } + + // Set value on $data object. + if ($parent_keys) { + $full_key = $parent_keys . "$key"; + } else { + $full_key = $key; + } + $data->set($full_key, $value); + } + return $value; + } + + /** + * Expansion callback used by preg_replace_callback() in expandProperty(). + * + * @param array $matches + * An array of matches created by preg_replace_callback(). + * @param Data $data + * A data object containing the complete array being operated upon. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * + * @return mixed + */ + public static function expandStringPropertiesCallback( + $matches, + $data, + $reference_data = null + ) { + $property_name = $matches[1]; + $unexpanded_value = $matches[0]; + + // Use only values within the subject array's data. + if (!$reference_data) { + return self::expandProperty($property_name, $unexpanded_value, $data); + } // Search both the subject array's data and the reference data for a value. + else { + return self::expandPropertyWithReferenceData( + $property_name, + $unexpanded_value, + $data, + $reference_data + ); + } + } + + /** + * Searches both the subject data and the reference data for value. + * + * @param string $property_name + * The name of the value for which to search. + * @param string $unexpanded_value + * The original, unexpanded value, containing the placeholder. + * @param Data $data + * A data object containing the complete array being operated upon. + * @param Data|null $reference_data + * A reference data object. This is not operated upon but is used as a + * reference to provide supplemental values for property expansion. + * + * @return string + * The expanded string. + */ + public static function expandPropertyWithReferenceData( + $property_name, + $unexpanded_value, + $data, + $reference_data + ) { + $expanded_value = self::expandProperty( + $property_name, + $unexpanded_value, + $data + ); + // If the string was not changed using the subject data, try using + // the reference data. + if ($expanded_value == $unexpanded_value) { + $expanded_value = self::expandProperty( + $property_name, + $unexpanded_value, + $reference_data + ); + } + + return $expanded_value; + } + + /** + * Searches a data object for a value. + * + * @param string $property_name + * The name of the value for which to search. + * @param string $unexpanded_value + * The original, unexpanded value, containing the placeholder. + * @param Data $data + * A data object containing possible replacement values. + * + * @return mixed + */ + public static function expandProperty($property_name, $unexpanded_value, $data) + { + if (strpos($property_name, "env.") === 0 && + !$data->has($property_name)) { + $env_key = substr($property_name, 4); + if (getenv($env_key)) { + $data->set($property_name, getenv($env_key)); + } + } + + if (!$data->has($property_name)) { + self::log("Property \${'$property_name'} could not be expanded."); + return $unexpanded_value; + } else { + $expanded_value = $data->get($property_name); + if (is_array($expanded_value)) { + $expanded_value = Yaml::dump($expanded_value, 0); + return $expanded_value; + } + self::log("Expanding property \${'$property_name'} => $expanded_value."); + return $expanded_value; + } + } + + /** + * @param $message + */ + public static function log($message) + { + // print "$message\n"; + } +} diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests deleted file mode 120000 index c2ebfe53..00000000 --- a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests +++ /dev/null @@ -1 +0,0 @@ -../../tests \ No newline at end of file diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/phpunit/ExpanderTest.php b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/phpunit/ExpanderTest.php new file mode 100644 index 00000000..291d00cc --- /dev/null +++ b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/phpunit/ExpanderTest.php @@ -0,0 +1,99 @@ +assertEquals('gomjabbar', $expanded['env-test']); + $this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']); + $this->assertEquals('Paul Atreides', $expanded['book']['protaganist']); + $this->assertEquals('Dune by Frank Herbert', $expanded['summary']); + $this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']); + $this->assertEquals('Dune', $expanded['product-name']); + $this->assertEquals(Yaml::dump($array['inline-array'], 0), $expanded['expand-array']); + + $expanded = Expander::expandArrayProperties($array, $reference_array); + $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); + $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); + } + + /** + * Tests Expander::parse(). + * + * @param string $filename + * @param array $reference_array + * + * @dataProvider providerYaml + */ + public function testParse($filename, $reference_array) + { + $yaml_string = file_get_contents(__DIR__ . "/../resources/$filename"); + $expanded = Expander::parse($yaml_string); + $this->assertEquals('Frank Herbert 1965', $expanded['book']['copyright']); + $this->assertEquals('Paul Atreides', $expanded['book']['protaganist']); + $this->assertEquals('Dune by Frank Herbert', $expanded['summary']); + $this->assertEquals('${book.media.1}, hardcover', $expanded['available-products']); + + $expanded = Expander::parse($yaml_string, $reference_array); + $this->assertEquals('Dune Messiah, and others.', $expanded['sequels']); + $this->assertEquals('Dune Messiah', $expanded['book']['nested-reference']); + } + + /** + * @return array + * An array of values to test. + */ + public function providerYaml() + { + return [ + ['valid.yml', [ + 'book' => [ + 'sequel' => 'Dune Messiah' + ] + ]], + ]; + } + + /** + * Tests Expander::expandProperty(). + * + * @dataProvider providerTestExpandProperty + */ + public function testExpandProperty($array, $property_name, $unexpanded_string, $expected) + { + $data = new Data($array); + $expanded_value = Expander::expandProperty($property_name, $unexpanded_string, $data); + + $this->assertEquals($expected, $expanded_value); + } + + /** + * @return array + */ + public function providerTestExpandProperty() + { + return [ + [ ['author' => 'Frank Herbert'], 'author', '${author}', 'Frank Herbert' ], + [ ['book' => ['author' => 'Frank Herbert' ]], 'book.author', '${book.author}', 'Frank Herbert' ], + ]; + } +} diff --git a/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/resources/valid.yml b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/resources/valid.yml new file mode 100644 index 00000000..78e4bc61 --- /dev/null +++ b/core/lib/composer/vendor/grasmash/yaml-expander/scenarios/symfony4/tests/resources/valid.yml @@ -0,0 +1,35 @@ +# This file should contain only valid YAML. +type: book +book: + title: Dune + author: Frank Herbert + copyright: ${book.author} 1965 + protaganist: ${characters.0.name} + media: + - hardcover + # Use a nested key to reference an external value. + nested-reference: ${book.sequel} +characters: + - name: Paul Atreides + occupation: Kwisatz Haderach + aliases: + - Usul + - Muad'Dib + - The Preacher + - name: Duncan Idaho + occupation: Swordmaster +summary: ${book.title} by ${book.author} +# This is a complete fake property. +publisher: ${not.real.property} +# series.books is not defined in this YAML file, but is passed in to the parser by the application. +sequels: ${book.sequel}, and others. +# Reference one real value and one fake value. +available-products: ${book.media.1}, ${book.media.0} +# Nested property, should resolve to ${book.title} and then 'Dune'. +product-name: ${${type}.title} +# Represent a few more data types and formats. +boolean-value: true +null-value: null +inline-array: [ one, two, three ] +expand-array: ${inline-array} +env-test: ${env.test} \ No newline at end of file diff --git a/core/lib/composer/vendor/pear/net_smtp/README.rst b/core/lib/composer/vendor/pear/net_smtp/README.rst deleted file mode 120000 index 753c5b5c..00000000 --- a/core/lib/composer/vendor/pear/net_smtp/README.rst +++ /dev/null @@ -1 +0,0 @@ -docs/guide.txt \ No newline at end of file diff --git a/core/lib/composer/vendor/pear/net_smtp/README.rst b/core/lib/composer/vendor/pear/net_smtp/README.rst new file mode 100644 index 00000000..a0e61dbd --- /dev/null +++ b/core/lib/composer/vendor/pear/net_smtp/README.rst @@ -0,0 +1,267 @@ +====================== + The Net_SMTP Package +====================== + +-------------------- + User Documentation +-------------------- + +:Author: Jon Parise +:Contact: jon@php.net + +.. contents:: Table of Contents +.. section-numbering:: + +Dependencies +============ + +The ``PEAR_Error`` Class +------------------------ + +The Net_SMTP package uses the `PEAR_Error`_ class for all of its `error +handling`_. + +The ``Net_Socket`` Package +-------------------------- + +The Net_Socket_ package is used as the basis for all network communications. +Connection options can be specified via the `$socket_options` construction +parameter:: + + $socket_options = array('ssl' => array('verify_peer_name' => false)); + $smtp = new Net_SMTP($host, null, null, false, 0, $socket_options); + +**Note:** PHP 5.6 introduced `OpenSSL changes`_. Peer certificate verification +is now enabled by default. Although not recommended, `$socket_options` can be +used to disable peer verification (as shown above). + +.. _OpenSSL changes: http://php.net/manual/en/migration56.openssl.php + +The ``Auth_SASL`` Package +------------------------- + +The `Auth_SASL`_ package is an optional dependency. If it is available, the +Net_SMTP package will be able to support the DIGEST-MD5_ and CRAM-MD5_ SMTP +authentication methods. Otherwise, only the LOGIN_ and PLAIN_ methods will +be available. + +Error Handling +============== + +All of the Net_SMTP class's public methods return a PEAR_Error_ object if an +error occurs. The standard way to check for a PEAR_Error object is by using +`PEAR::isError()`_:: + + if (PEAR::isError($error = $smtp->connect())) { + die($error->getMessage()); + } + +.. _PEAR::isError(): http://pear.php.net/manual/en/core.pear.pear.iserror.php + +SMTP Authentication +=================== + +The Net_SMTP package supports the SMTP authentication standard (as defined +by RFC-2554_). The Net_SMTP package supports the following authentication +methods, in order of preference: + +.. _RFC-2554: http://www.ietf.org/rfc/rfc2554.txt + +DIGEST-MD5 +---------- + +The DIGEST-MD5 authentication method uses `RSA Data Security Inc.`_'s MD5 +Message Digest algorithm. It is considered the most secure method of SMTP +authentication. + +**Note:** The DIGEST-MD5 authentication method is only supported if the +AUTH_SASL_ package is available. + +.. _RSA Data Security Inc.: http://www.rsasecurity.com/ + +CRAM-MD5 +-------- + +The CRAM-MD5 authentication method has been superseded by the DIGEST-MD5_ +method in terms of security. It is provided here for compatibility with +older SMTP servers that may not support the newer DIGEST-MD5 algorithm. + +**Note:** The CRAM-MD5 authentication method is only supported if the +AUTH_SASL_ package is available. + +LOGIN +----- + +The LOGIN authentication method encrypts the user's password using the +Base64_ encoding scheme. Because decrypting a Base64-encoded string is +trivial, LOGIN is not considered a secure authentication method and should +be avoided. + +.. _Base64: http://www.php.net/manual/en/function.base64-encode.php + +PLAIN +----- + +The PLAIN authentication method sends the user's password in plain text. +This method of authentication is not secure and should be avoided. + +Secure Connections +================== + +If `secure socket transports`_ have been enabled in PHP, it is possible to +establish a secure connection to the remote SMTP server:: + + $smtp = new Net_SMTP('ssl://mail.example.com', 465); + +This example connects to ``mail.example.com`` on port 465 (a common SMTPS +port) using the ``ssl://`` transport. + +.. _secure socket transports: http://www.php.net/transports + +Sending Data +============ + +Message data is sent using the ``data()`` method. The data can be supplied +as a single string or as an open file resource. + +If a string is provided, it is passed through the `data quoting`_ system and +sent to the socket connection as a single block. These operations are all +memory-based, so sending large messages may result in high memory usage. + +If an open file resource is provided, the ``data()`` method will read the +message data from the file line-by-line. Each chunk will be quoted and sent +to the socket connection individually, reducing the overall memory overhead of +this data sending operation. + +Header data can be specified separately from message body data by passing it +as the optional second parameter to ``data()``. This is especially useful +when an open file resource is being used to supply message data because it +allows header fields (like *Subject:*) to be built dynamically at runtime. + +:: + + $smtp->data($fp, "Subject: My Subject"); + +Data Quoting +============ + +By default, all outbound string data is quoted in accordance with SMTP +standards. This means that all native Unix (``\n``) and Mac (``\r``) line +endings are converted to Internet-standard CRLF (``\r\n``) line endings. +Also, because the SMTP protocol uses a single leading period (``.``) to signal +an end to the message data, single leading periods in the original data +string are "doubled" (e.g. "``..``"). + +These string transformation can be expensive when large blocks of data are +involved. For example, the Net_SMTP package is not aware of MIME parts (it +just sees the MIME message as one big string of characters), so it is not +able to skip non-text attachments when searching for characters that may +need to be quoted. + +Because of this, it is possible to extend the Net_SMTP class in order to +implement your own custom quoting routine. Just create a new class based on +the Net_SMTP class and reimplement the ``quotedata()`` method:: + + require 'Net_SMTP.php'; + + class Net_SMTP_custom extends Net_SMTP + { + function quotedata($data) + { + /* Perform custom data quoting */ + } + } + +Note that the ``$data`` parameter will be passed to the ``quotedata()`` +function `by reference`_. This means that you can operate directly on +``$data``. It also the overhead of copying a large ``$data`` string to and +from the ``quotedata()`` method. + +.. _by reference: http://www.php.net/manual/en/language.references.pass.php + +Server Responses +================ + +The Net_SMTP package retains the server's last response for further +inspection. The ``getResponse()`` method returns a 2-tuple (two element +array) containing the server's response code as an integer and the response's +arguments as a string. + +Upon a successful connection, the server's greeting string is available via +the ``getGreeting()`` method. + +Debugging +========= + +The Net_SMTP package contains built-in debugging output routines (disabled by +default). Debugging output must be explicitly enabled via the ``setDebug()`` +method:: + + $smtp->setDebug(true); + +The debugging messages will be sent to the standard output stream by default. +If you need more control over the output, you can optionally install your own +debug handler. + +:: + + function debugHandler($smtp, $message) + { + echo "[$smtp->host] $message\n"; + } + + $smtp->setDebug(true, "debugHandler"); + + +Examples +======== + +Basic Use +--------- + +The following script demonstrates how a simple email message can be sent +using the Net_SMTP package:: + + require 'Net/SMTP.php'; + + $host = 'mail.example.com'; + $from = 'user@example.com'; + $rcpt = array('recipient1@example.com', 'recipient2@example.com'); + $subj = "Subject: Test Message\n"; + $body = "Body Line 1\nBody Line 2"; + + /* Create a new Net_SMTP object. */ + if (! ($smtp = new Net_SMTP($host))) { + die("Unable to instantiate Net_SMTP object\n"); + } + + /* Connect to the SMTP server. */ + if (PEAR::isError($e = $smtp->connect())) { + die($e->getMessage() . "\n"); + } + + /* Send the 'MAIL FROM:' SMTP command. */ + if (PEAR::isError($smtp->mailFrom($from))) { + die("Unable to set sender to <$from>\n"); + } + + /* Address the message to each of the recipients. */ + foreach ($rcpt as $to) { + if (PEAR::isError($res = $smtp->rcptTo($to))) { + die("Unable to add recipient <$to>: " . $res->getMessage() . "\n"); + } + } + + /* Set the body of the message. */ + if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) { + die("Unable to send data\n"); + } + + /* Disconnect from the SMTP server. */ + $smtp->disconnect(); + +.. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php +.. _Net_Socket: http://pear.php.net/package/Net_Socket +.. _Auth_SASL: http://pear.php.net/package/Auth_SASL + +.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst: diff --git a/core/login.php b/core/login.php index 9cf3dfe5..4fda0645 100644 --- a/core/login.php +++ b/core/login.php @@ -302,14 +302,13 @@ $csrfToken = sha1(rand(4500, 100000) . time(). CLIENT_BASE_URL); var password = $("#password").val(); var passwordValidation = function (str) { - var val = /^[a-zA-Z0-9]\w{6,}$/; - return str != null && val.test(str); + return str.length > 7; }; if(!passwordValidation(password)){ $("#newPasswordFormAlert").show(); - $("#newPasswordFormAlert").html("Password may contain only letters, numbers and should be longer than 6 characters"); + $("#newPasswordFormAlert").html("Password should be longer than 7 characters"); return; } @@ -331,6 +330,10 @@ $csrfToken = sha1(rand(4500, 100000) . time(). CLIENT_BASE_URL); $("#loginForm").submit(); } + function authGoogle() { + window.location.href = window.location.href.split('login.php')[0] + "login.php?google=1"; + } +
    diff --git a/core/migrations/list.php b/core/migrations/list.php index 8b1e9f03..c9f80b05 100644 --- a/core/migrations/list.php +++ b/core/migrations/list.php @@ -1,5 +1,12 @@ executeQuery($sql); + } + + public function down(){ + + } + +} diff --git a/core/migrations/v20180801_240003_asset_management.php b/core/migrations/v20180801_240003_asset_management.php new file mode 100644 index 00000000..18bb0668 --- /dev/null +++ b/core/migrations/v20180801_240003_asset_management.php @@ -0,0 +1,63 @@ +executeQuery($sql); + + + $sql = <<<'SQL' +create table `CompanyAssets` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `code` VARCHAR(30) NOT NULL, + `type` bigint(20) NULL, + `attachment` varchar(100) NULL, + `employee` bigint(20) NULL, + `department` bigint(20) NULL, + `description` TEXT NULL, + `created` DATETIME default '0000-00-00 00:00:00', + `updated` DATETIME default '0000-00-00 00:00:00', + primary key (`id`), + CONSTRAINT `Fk_CompanyAssets_AssetTypes` FOREIGN KEY (`type`) REFERENCES `AssetTypes` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_CompanyAssets_Employees` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_CompanyAssets_CompanyStructures` FOREIGN KEY (`department`) REFERENCES `CompanyStructures` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) engine=innodb default charset=utf8; +SQL; + $this->executeQuery($sql); + + + $report = new Report(); + $report->name = 'Company Asset Report'; + $report->parameters = '[["department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],["type", {"label":"Asset Type","type":"select2","remote-source":["AssetType","id","name"],"allow-null":true}]]'; + $report->query = 'AssetUsageReport'; + $report->type = 'Class'; + $report->paramOrder = '["department","type"]'; + $report->report_group = 'Resources'; + $report->output = 'CSV'; + $report->details = 'List company assets assigned to employees and departments'; + $ok = $report->Save(); + + return true; + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20180808_250004_add_languages.php b/core/migrations/v20180808_250004_add_languages.php new file mode 100644 index 00000000..98e5e488 --- /dev/null +++ b/core/migrations/v20180808_250004_add_languages.php @@ -0,0 +1,39 @@ +executeQuery($sql); + + $sql = <<<'SQL' + INSERT INTO `SupportedLanguages` (`name`, `description`) VALUES ('sv', 'Swedish'); +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + INSERT INTO `SupportedLanguages` (`name`, `description`) VALUES ('no', 'Norwegian'); +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + INSERT INTO `SupportedLanguages` (`name`, `description`) VALUES ('pt', 'Portuguese'); +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + INSERT INTO `SupportedLanguages` (`name`, `description`) VALUES ('nl', 'Dutch'); +SQL; + return $this->executeQuery($sql); + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20180810_250005_performance_review.php b/core/migrations/v20180810_250005_performance_review.php new file mode 100644 index 00000000..b44c6491 --- /dev/null +++ b/core/migrations/v20180810_250005_performance_review.php @@ -0,0 +1,72 @@ +executeQuery($sql); + + + $sql = <<<'SQL' +create table `PerformanceReviews` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(150) NOT NULL, + `employee` bigint(20) NULL, + `coordinator` bigint(20) NULL, + `attendees` VARCHAR(50) NOT NULL, + `form` bigint(20) NULL, + `status` varchar(20) NOT NULL, + `review_date` DATETIME default '0000-00-00 00:00:00', + `review_period_start` DATETIME default '0000-00-00 00:00:00', + `review_period_end` DATETIME default '0000-00-00 00:00:00', + `self_assessment_due` DATETIME default '0000-00-00 00:00:00', + `notes` TEXT NULL, + `created` DATETIME default '0000-00-00 00:00:00', + `updated` DATETIME default '0000-00-00 00:00:00', + primary key (`id`), + CONSTRAINT `Fk_PerformanceReviews_ReviewTemplates` FOREIGN KEY (`form`) REFERENCES ReviewTemplates (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_PerformanceReviews_Employees1` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_PerformanceReviews_Employees2` FOREIGN KEY (`coordinator`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) engine=innodb default charset=utf8; +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' +create table `ReviewFeedbacks` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `employee` bigint(20) NULL, + `review` bigint(20) NULL, + `subject` bigint(20) NULL, + `form` bigint(20) NULL, + `status` varchar(20) NOT NULL, + `dueon` DATETIME default '0000-00-00 00:00:00', + `created` DATETIME default '0000-00-00 00:00:00', + `updated` DATETIME default '0000-00-00 00:00:00', + primary key (`id`), + CONSTRAINT `Fk_ReviewFeedbacks_ReviewTemplates` FOREIGN KEY (`form`) REFERENCES ReviewTemplates (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_ReviewFeedbacks_PerformanceReviews` FOREIGN KEY (`review`) REFERENCES PerformanceReviews (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_ReviewFeedbacks_Employees1` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Fk_ReviewFeedbacks_Employees2` FOREIGN KEY (`subject`) REFERENCES `Employees` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) engine=innodb default charset=utf8; +SQL; + return $this->executeQuery($sql); + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20180912_250006_remove_null_users.php b/core/migrations/v20180912_250006_remove_null_users.php new file mode 100644 index 00000000..27a3f1f2 --- /dev/null +++ b/core/migrations/v20180912_250006_remove_null_users.php @@ -0,0 +1,20 @@ +executeQuery($sql); + + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20181025_260001_dept_based_leave_periods.php b/core/migrations/v20181025_260001_dept_based_leave_periods.php new file mode 100644 index 00000000..1be873e8 --- /dev/null +++ b/core/migrations/v20181025_260001_dept_based_leave_periods.php @@ -0,0 +1,26 @@ +executeQuery($sql); + + $sql = <<<'SQL' +Alter table LeavePeriods ADD COLUMN `country` bigint(20) DEFAULT NULL; +SQL; + return $this->executeQuery($sql); + + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20181106_260002_add_arabic_lang.php b/core/migrations/v20181106_260002_add_arabic_lang.php new file mode 100644 index 00000000..9eb0ca3e --- /dev/null +++ b/core/migrations/v20181106_260002_add_arabic_lang.php @@ -0,0 +1,19 @@ +executeQuery($sql); + } + + public function down(){ + + return true; + } + +} diff --git a/core/migrations/v20190125_260003_attendance_with_map.php b/core/migrations/v20190125_260003_attendance_with_map.php new file mode 100644 index 00000000..60e84545 --- /dev/null +++ b/core/migrations/v20190125_260003_attendance_with_map.php @@ -0,0 +1,40 @@ +executeQuery($sql); + + $sql = <<<'SQL' + Alter table Attendance add column `map_lng` DECIMAL(10, 8) NULL; +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + Alter table Attendance add column `map_snapshot` longtext default null; +SQL; + return $this->executeQuery($sql); + } + + public function down(){ + $sql = <<<'SQL' + Alter table Attendance drop column `map_lat`; +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + Alter table Attendance drop column `map_lng`; +SQL; + $this->executeQuery($sql); + + $sql = <<<'SQL' + Alter table Attendance drop column `map_snapshot`; +SQL; + return $this->executeQuery($sql); + } +} diff --git a/core/modulejslibs.inc.php b/core/modulejslibs.inc.php index 8601c4e3..f932cdaa 100644 --- a/core/modulejslibs.inc.php +++ b/core/modulejslibs.inc.php @@ -3,8 +3,8 @@ if(isset($additionalJs)) { foreach ($additionalJs as $js) { ?> - - \ No newline at end of file + diff --git a/core/modules.php b/core/modules.php index 6dbf1425..684ae757 100644 --- a/core/modules.php +++ b/core/modules.php @@ -126,6 +126,7 @@ foreach ($ams as $am) { $dbModule->label = $arr['label']; $dbModule->menu = $arr['menu']; $dbModule->icon = $arr['icon']; + $dbModule->mod_order = $arr['order']; $dbModule->Save(); } @@ -194,6 +195,7 @@ foreach ($ams as $am) { $arr['label'] = $meta->label; $arr['icon'] = $meta->icon; $arr['menu'] = $meta->menu; + $arr['order'] = $meta->order; $arr['status'] = 'Enabled'; $arr['user_levels'] = $meta->user_levels; $arr['user_roles'] = isset($meta->user_roles) ? $meta->user_roles : ""; @@ -212,6 +214,7 @@ foreach ($ams as $am) { $dbModule->label = $arr['label']; $dbModule->menu = $arr['menu']; $dbModule->icon = $arr['icon']; + $dbModule->mod_order = $arr['order']; $dbModule->Save(); } diff --git a/core/modules/attendance/index.php b/core/modules/attendance/index.php index b23f039f..4bc3aeb3 100644 --- a/core/modules/attendance/index.php +++ b/core/modules/attendance/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'attendance'; diff --git a/core/modules/dashboard/index.php b/core/modules/dashboard/index.php index ce4139f5..c2eacd87 100644 --- a/core/modules/dashboard/index.php +++ b/core/modules/dashboard/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'dashboard'; diff --git a/core/modules/dependents/index.php b/core/modules/dependents/index.php index e3bc16a4..2b917a4d 100644 --- a/core/modules/dependents/index.php +++ b/core/modules/dependents/index.php @@ -1,43 +1,26 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ - + $moduleName = 'emergency_contact'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    - + - +
    - +
    @@ -60,4 +43,4 @@ modJsList['tabEmployeeDependent'].setShowEdit(false); var modJs = modJsList['tabEmployeeDependent']; - + diff --git a/core/modules/emergency_contact/index.php b/core/modules/emergency_contact/index.php index 8ab935e7..7bd500dd 100644 --- a/core/modules/emergency_contact/index.php +++ b/core/modules/emergency_contact/index.php @@ -1,24 +1,7 @@ -. - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'emergency_contact'; @@ -26,18 +9,18 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    - + - +
    - +
    @@ -61,4 +44,4 @@ modJsList['tabEmergencyContact'].setShowEdit(false); var modJs = modJsList['tabEmergencyContact']; - + diff --git a/core/modules/employees/index.php b/core/modules/employees/index.php index 01b269e0..57f258b5 100644 --- a/core/modules/employees/index.php +++ b/core/modules/employees/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'employees'; @@ -28,19 +11,26 @@ include APP_BASE_PATH.'modulejslibs.inc.php'; $fieldNameMap = \Classes\BaseService::getInstance()->getFieldNameMappings("Employee"); $customFields = \Classes\BaseService::getInstance()->getCustomFields("Employee"); -if (\Classes\SettingsManager::getInstance()->getSetting("Api: REST Api Enabled") == "1") { - $user = \Classes\BaseService::getInstance()->getCurrentUser(); - if (empty($user)) { - return; - } - $dbUser = new \Users\Common\Model\User(); - $dbUser->Load("id = ?", array($user->id)); - $resp = \Classes\RestApiManager::getInstance()->getAccessTokenForUser($dbUser); - if ($resp->getStatus() != \Classes\IceResponse::SUCCESS) { - \Utils\LogManager::getInstance()->error( - "Error occurred while creating REST Api access token for ".$user->username - ); - } +$restApiBase = ''; +$user = \Classes\BaseService::getInstance()->getCurrentUser(); +if (empty($user)) { + return; +} +$dbUser = new \Users\Common\Model\User(); +$dbUser->Load("id = ?", array($user->id)); +$resp = \Classes\RestApiManager::getInstance()->getAccessTokenForUser($dbUser); +if ($resp->getStatus() != \Classes\IceResponse::SUCCESS) { + \Utils\LogManager::getInstance()->error( + "Error occurred while creating REST Api access token for ".$user->username + ); +} + +if (defined('SYM_CLIENT')) { + $restApiBase = WEB_APP_BASE_URL.'/api/'.SYM_CLIENT.'/'; +} else if (defined('REST_API_BASE')){ + $restApiBase = REST_API_BASE; +} else { + $restApiBase = CLIENT_BASE_PATH.'api/'; } ?> @@ -93,11 +83,17 @@ path.link {

    Api Access Token

    -
    +
    getData()?>
    -
    -
    +
    +
    +

    Mobile Authentication Code

    +
    + +
    +
    +
    @@ -110,6 +106,9 @@ modJsList['tabEmployee'].setCustomFields(); modJsList['tabCompanyGraph'] = new CompanyGraphAdapter('CompanyStructure'); modJsList['tabApiAccess'] = new ApiAccessAdapter('ApiAccess'); +modJsList['tabApiAccess'].setApiUrl(''); +modJsList['tabApiAccess'].setToken('getData()?>'); + var modJs = modJsList['tabEmployee']; diff --git a/core/modules/loans/index.php b/core/modules/loans/index.php index 95fbe846..82147c22 100644 --- a/core/modules/loans/index.php +++ b/core/modules/loans/index.php @@ -1,43 +1,26 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ - + $moduleName = 'loans'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    - + - +
    - +
    @@ -55,4 +38,4 @@ modJsList['tabEmployeeCompanyLoan'].setShowEdit(true); var modJs = modJsList['tabEmployeeCompanyLoan']; - + diff --git a/core/modules/meta.json b/core/modules/meta.json index b74e130c..e5e4fb40 100644 --- a/core/modules/meta.json +++ b/core/modules/meta.json @@ -6,6 +6,7 @@ "Documents":"fa-files-o", "Company":"fa-building", "Training":"fa-briefcase", +"Performance":"fa-crosshairs", "Travel Management":"fa-plane", "Finance":"fa-money", "User Reports":"fa-file-text" diff --git a/core/modules/overtime/index.php b/core/modules/overtime/index.php index 3c4a32cb..00ef4b78 100644 --- a/core/modules/overtime/index.php +++ b/core/modules/overtime/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'overtime'; @@ -33,7 +16,6 @@ $appModName = $moduleMainName.'Approval'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; $additionalJs = array(); -$additionalJs[] = BASE_URL.'admin/overtime/lib.js?v='.$jsVersion; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    @@ -75,7 +57,7 @@ include APP_BASE_PATH.'modulejslibs.inc.php'; var modJsList = new Array(); modJsList['tab'] = new Adapter('',''); - + modJsList['tab'] = new ApproverAdapter('', ''); modJsList['tab'].setShowAddNew(false); @@ -91,4 +73,4 @@ include APP_BASE_PATH.'modulejslibs.inc.php'; var modJs = modJsList['tab']; - + diff --git a/core/modules/projects/index.php b/core/modules/projects/index.php index 34c7cdb7..cd9f502b 100644 --- a/core/modules/projects/index.php +++ b/core/modules/projects/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'projects'; @@ -26,18 +9,18 @@ define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    - + - +
    - +
    @@ -61,4 +44,4 @@ modJsList['tabEmployeeProject'].setShowEdit(false); var modJs = modJsList['tabEmployeeProject']; - + diff --git a/core/modules/qualifications/index.php b/core/modules/qualifications/index.php index 1c8735c6..37d993cb 100644 --- a/core/modules/qualifications/index.php +++ b/core/modules/qualifications/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'qualifications'; diff --git a/core/modules/reports/index.php b/core/modules/reports/index.php index a7cff766..6e695ed5 100644 --- a/core/modules/reports/index.php +++ b/core/modules/reports/index.php @@ -4,7 +4,6 @@ $moduleName = 'Reports'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; $additionalJs = array(); -$additionalJs[] = BASE_URL.'admin/reports/lib.js?v='.$jsVersion; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    diff --git a/core/modules/salary/index.php b/core/modules/salary/index.php index 82b88b63..26591181 100644 --- a/core/modules/salary/index.php +++ b/core/modules/salary/index.php @@ -1,43 +1,26 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ - + $moduleName = 'salary'; define('MODULE_PATH',dirname(__FILE__)); include APP_BASE_PATH.'header.php'; include APP_BASE_PATH.'modulejslibs.inc.php'; ?>
    - + - +
    - +
    @@ -61,4 +44,4 @@ modJsList['tabEmployeeSalary'].setShowEdit(false); var modJs = modJsList['tabEmployeeSalary']; - + diff --git a/core/modules/staffdirectory/customTemplates/element.html b/core/modules/staffdirectory/customTemplates/element.html new file mode 100644 index 00000000..97ace73e --- /dev/null +++ b/core/modules/staffdirectory/customTemplates/element.html @@ -0,0 +1,21 @@ +
    + +
    +
    +
    + User Avatar +
    + +

    #_first_name_# #_last_name_#

    +
    #_job_title_#
    +
    + +
    + +
    \ No newline at end of file diff --git a/core/modules/staffdirectory/index.php b/core/modules/staffdirectory/index.php new file mode 100644 index 00000000..c02cedad --- /dev/null +++ b/core/modules/staffdirectory/index.php @@ -0,0 +1,61 @@ +
    + + + +
    +
    +
    + + +
    +
    + +
    + +
    +
    +
    + +
    + + diff --git a/core/modules/staffdirectory/meta.json b/core/modules/staffdirectory/meta.json new file mode 100644 index 00000000..2d6cd397 --- /dev/null +++ b/core/modules/staffdirectory/meta.json @@ -0,0 +1,14 @@ +{ + "label":"Staff Directory", + "menu":"Company", + "order":"1", + "icon":"fa-user", + "user_levels":["Admin","Manager","Employee"], + + "permissions": + { + + }, + "model_namespace": "\\StaffDirectory\\Common\\Model", + "manager": "\\StaffDirectory\\User\\Api\\StaffDirectoryModulesManager" +} diff --git a/core/modules/time_sheets/index.php b/core/modules/time_sheets/index.php index a79d4519..053e1151 100644 --- a/core/modules/time_sheets/index.php +++ b/core/modules/time_sheets/index.php @@ -1,24 +1,7 @@ . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ $moduleName = 'employee_TimeSheet'; @@ -79,7 +62,7 @@ $startEndTimeNeeded = \Classes\SettingsManager::getInstance()->getSetting( -
    + ');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r
    ')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c
    '),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r
    ');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l",l.parent=null;break}r[n.id]=1,i=n}}return""===t||(this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:
    "+t),!1)}},{key:"getHelpLink",value:function(){return"https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html"}}]),t}();t.exports={CompanyStructureAdapter:c,CompanyGraphAdapter:d}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i
    ")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c
    ');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r
    ')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c
    '),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r
    ');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i
    ")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c
    ');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r
    ')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c
    '),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r
    ');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    #_name_# #_delete_##_edit_#
    Header Title: #_title_#
    Type: #_type_#
    ',validation:"none","custom-validate-function":function(e){var t={};return t.params=e,t.valid=!0,"Reference"===e.type&&("NULL"===e.dependOn?(t.message="If the type is Reference this field should referring another table",t.valid=!1):null!==dependOnField&&void 0!==dependOnField||(t.message="If the type is Reference then 'Depends On Field' can not be empty",t.valid=!1)),t}}]]}}]),t}(),d=function(e){function t(){return s(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,n.default),i(t,[{key:"getDataMapping",value:function(){return["id","name","data_import_definition","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Data Import Definition"},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["data_import_definition",{label:"Data Import Definitions",type:"select","remote-source":["DataImport","id","name"]}],["file",{label:"File to Import",type:"fileupload",validation:"",filetypes:"csv,txt"}],["details",{label:"Last Export Result",type:"textarea",validation:"none"}]]}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__process__clone__delete_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_",""),a=(a=(a=(a="Not Processed"===t[3]?a.replace("_process_",''):a.replace("_process_","")).replace(/_id_/g,e)).replace(/_status_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"process",value:function(e){var t={id:e},a=JSON.stringify(t),l=[];l.callBackData=[],l.callBackSuccess="processSuccessCallBack",l.callBackFail="processFailCallBack",this.customAction("processDataFile","admin=data",a,l)}},{key:"processSuccessCallBack",value:function(e){this.showMessage("Success","File imported successfully.")}},{key:"processFailCallBack",value:function(e){this.showMessage("Error","File import unsuccessful. Result:"+e)}}]),t}();t.exports={DataImportAdapter:c,DataImportFileAdapter:d}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i
    ")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c
    ');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r
    ')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'+this.gt("Skills")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    '+nl2br(e[3])+"

    ")}}]),t}(),c=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","education_id","institute","date_start","date_end"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Qualification"},{sTitle:"Institute"},{sTitle:"Start Date"},{sTitle:"Completed On"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["education_id",{label:"Qualification",type:"select2","allow-null":!1,"remote-source":["Education","id","name"]}],["institute",{label:"Institute",type:"text",validation:""}],["date_start",{label:"Start Date",type:"date",validation:"none"}],["date_end",{label:"Completed On",type:"date",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Education")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[4]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}var i="";try{i=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}return $('
    '+e[2]+t+l+'

    Start: '+a+'

    Completed: '+i+'

    Institute: '+e[3]+"

    ")}}]),t}(),p=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","certification_id","institute","date_start","date_end"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Certification"},{sTitle:"Institute"},{sTitle:"Granted On"},{sTitle:"Valid Thru"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["certification_id",{label:"Certification",type:"select2","allow-null":!1,"remote-source":["Certification","id","name"]}],["institute",{label:"Institute",type:"text",validation:""}],["date_start",{label:"Granted On",type:"date",validation:"none"}],["date_end",{label:"Valid Thru",type:"date",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Certifications")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[4]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}var i="";try{i=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}return $('
    '+e[2]+t+l+'

    Granted On: '+a+'

    Valid Thru: '+i+'

    Institute: '+e[3]+"

    ")}}]),t}(),m=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","language_id","reading","speaking","writing","understanding"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Language"},{sTitle:"Reading"},{sTitle:"Speaking"},{sTitle:"Writing"},{sTitle:"Understanding"}]}},{key:"getFormFields",value:function(){var e=[["Elementary Proficiency","Elementary Proficiency"],["Limited Working Proficiency","Limited Working Proficiency"],["Professional Working Proficiency","Professional Working Proficiency"],["Full Professional Proficiency","Full Professional Proficiency"],["Native or Bilingual Proficiency","Native or Bilingual Proficiency"]];return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["language_id",{label:"Language",type:"select2","allow-null":!1,"remote-source":["Language","id","name"]}],["reading",{label:"Reading",type:"select",source:e}],["speaking",{label:"Speaking",type:"select",source:e}],["writing",{label:"Writing",type:"select",source:e}],["understanding",{label:"Understanding",type:"select",source:e}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Languages")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Reading: '+e[3]+'

    Speaking: '+e[4]+'

    Writing: '+e[5]+'

    Understanding: '+e[6]+"

    ")}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),h=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","name","relationship","dob","id_number"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Name"},{sTitle:"Relationship"},{sTitle:"Date of Birth"},{sTitle:"Id Number"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["relationship",{label:"Relationship",type:"select",source:[["Child","Child"],["Spouse","Spouse"],["Parent","Parent"],["Other","Other"]]}],["dob",{label:"Date of Birth",type:"date",validation:""}],["id_number",{label:"Id Number",type:"text",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Dependents")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Relationship: '+e[3]+'

    Name: '+e[2]+"

    ")}}]),t}(),f=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","name","relationship","home_phone","work_phone","mobile_phone"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Name"},{sTitle:"Relationship"},{sTitle:"Home Phone"},{sTitle:"Work Phone"},{sTitle:"Mobile Phone"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["relationship",{label:"Relationship",type:"text",validation:"none"}],["home_phone",{label:"Home Phone",type:"text",validation:"none"}],["work_phone",{label:"Work Phone",type:"text",validation:"none"}],["mobile_phone",{label:"Mobile Phone",type:"text",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Emergency Contacts")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Relationship: '+e[3]+'

    Name: '+e[2]+'

    Home Phone: '+e[4]+'

    Mobile Phone: '+e[6]+"

    ")}}]),t}(),y=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","document","details","date_added","valid_until","status","attachment"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Document"},{sTitle:"Details"},{sTitle:"Date Added"},{sTitle:"Status"},{sTitle:"Attachment",bVisible:!1}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["document",{label:"Document",type:"select2","remote-source":["Document","id","name"]}],["date_added",{label:"Date Added",type:"date",validation:""}],["valid_until",{label:"Valid Until",type:"date",validation:"none"}],["status",{label:"Status",type:"select",source:[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],["details",{label:"Details",type:"textarea",validation:"none"}],["attachment",{label:"Attachment",type:"fileupload",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Documents")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log(e.message)}var i='';return $('
    '+e[2]+i+t+l+'

    '+nl2br(e[3])+'

    Expire On: '+a+"

    ")}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),b=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,i.default),a(t,[{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),v=function(e){function t(e,l,a,i){s(this,t);var o=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l,a,i));return o.fieldNameMap={},o.hiddenFields={},o.tableFields={},o.formOnlyFields={},o}return u(t,b),a(t,[{key:"setFieldNameMap",value:function(e){for(var t=void 0,l=0;l'.replace("_img_",t)}return t}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"getTableFields",value:function(){return["id","image","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]}},{key:"getDataMapping",value:function(){for(var e=this.getTableFields(),t=[],l=0;l
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ',validation:"none","sort-function":function(e,t){return Date.parse(e.date).getTime()";return l=(l=l.replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"getHelpLink",value:function(){return"https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html"}},{key:"saveSuccessItemCallback",value:function(e){this.lastSavedEmployee=e,null===this.currentId&&$("#createUserModel").modal("show")}},{key:"closeCreateUser",value:function(){$("#createUserModel").modal("hide")}},{key:"createUser",value:function(){var e={};e.employee=this.lastSavedEmployee.id,e.user_level="Employee",e.email=this.lastSavedEmployee.work_email,e.username=this.lastSavedEmployee.work_email.split("@")[0],top.location.href=this.getCustomUrl("?g=admin&n=users&m=admin_Admin&action=new&object="+Base64.encodeURI(JSON.stringify(e)))}},{key:"deleteEmployee",value:function(e){if(confirm("Are you sure you want to archive this employee? Data for this employee will be saved to an archive table. But you will not be able to covert the archived employee data into a normal employee.")){var t=[];t.callBackData=[],t.callBackSuccess="deleteEmployeeSuccessCallback",t.callBackFail="deleteEmployeeFailCallback",this.customAction("deleteEmployee","admin=employees",JSON.stringify({id:e}),t)}}},{key:"deleteEmployeeSuccessCallback",value:function(e){this.showMessage("Delete Success","Employee deleted. You can find archived information for this employee in Archived Employees tab"),this.get([])}},{key:"deleteEmployeeFailCallback",value:function(e){this.showMessage("Error occurred while deleting Employee",e)}},{key:"terminateEmployee",value:function(e){if(confirm("Are you sure you want to terminate this employee contract? You will still be able to access all details of this employee.")){var t={};t.id=e;var l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="terminateEmployeeSuccessCallback",a.callBackFail="terminateEmployeeFailCallback",this.customAction("terminateEmployee","admin=employees",l,a)}}},{key:"terminateEmployeeSuccessCallback",value:function(e){this.showMessage("Success","Employee contract terminated. You can find terminated employee information under Terminated Employees menu."),this.get([])}},{key:"terminateEmployeeFailCallback",value:function(e){this.showMessage("Error occured while terminating Employee",e)}},{key:"activateEmployee",value:function(e){if(confirm("Are you sure you want to re-activate this employee contract?")){var t={};t.id=e;var l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="activateEmployeeSuccessCallback",a.callBackFail="activateEmployeeFailCallback",this.customAction("activateEmployee","admin=employees",l,a)}}},{key:"activateEmployeeSuccessCallback",value:function(e){this.showMessage("Success","Employee contract re-activated."),this.get([])}},{key:"activateEmployeeFailCallback",value:function(e){this.showMessage("Error occurred while activating Employee",e)}},{key:"view",value:function(e){this.currentId=e;var t={id:e,map:JSON.stringify(this.getSourceMapping())},l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="renderEmployee",a.callBackFail="viewFailCallBack",this.customAction("get","modules=employees",l,a)}},{key:"viewFailCallBack",value:function(e){this.showMessage("Error","Error Occured while retriving candidate")}},{key:"renderEmployee",value:function(e){var t=void 0,l=this.getFormFields();e[1],e[1],e[2];e=e[0],this.currentEmployee=e;for(var a=this.getCustomTemplate("myDetails.html"),i=0;i";if($("#"+this.getTableName()+" #subordinates").html(n),$("#"+this.getTableName()+" #name").html(e.first_name+" "+e.last_name),this.currentUserId=e.id,$("#"+this.getTableName()+" #profile_image_"+e.id).attr("src",e.image),void 0!==e.customFields&&null!==e.customFields&&Object.keys(e.customFields).length>0){var r=void 0;for(var u in e.customFields){e.customFields[u][1]||(e.customFields[u][1]=this.gt("Other Details"));var b=e.customFields[u][1].toLocaleLowerCase();if(b=b.replace(" ","_"),$("#cont_"+b).length<=0){var v='

    #_section.name_#

    ';v=(v=v.replace("#_section_#",b)).replace("#_section.name_#",e.customFields[u][1]),$("#customFieldsCont").append($(v))}r=(r='
    ').replace("#_label_#",u),r="fileupload"===e.customFields[u][2]?r.replace("#_value_#",""):r.replace("#_value_#",e.customFields[u][0]),$("#cont_"+b).append($(r))}}else $("#customFieldsCont").remove();for(var g in this.cancel(),this.isModuleInstalled("admin","documents")||$("#tabDocuments").remove(),window.modJs=this,modJs.subModJsList=[],modJs.subModJsList.tabEmployeeSkillSubTab=new d("EmployeeSkill","EmployeeSkillSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeSkillSubTab.parent=this,modJs.subModJsList.tabEmployeeEducationSubTab=new c("EmployeeEducation","EmployeeEducationSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeEducationSubTab.parent=this,modJs.subModJsList.tabEmployeeCertificationSubTab=new p("EmployeeCertification","EmployeeCertificationSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeCertificationSubTab.parent=this,modJs.subModJsList.tabEmployeeLanguageSubTab=new m("EmployeeLanguage","EmployeeLanguageSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeLanguageSubTab.parent=this,modJs.subModJsList.tabEmployeeDependentSubTab=new h("EmployeeDependent","EmployeeDependentSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeDependentSubTab.parent=this,modJs.subModJsList.tabEmployeeEmergencyContactSubTab=new f("EmergencyContact","EmployeeEmergencyContactSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.parent=this,this.isModuleInstalled("admin","documents")&&(modJs.subModJsList.tabEmployeeDocumentSubTab=new y("EmployeeDocument","EmployeeDocumentSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeDocumentSubTab.parent=this),modJs.subModJsList)modJs.subModJsList.hasOwnProperty(g)&&(modJs.subModJsList[g].setTranslationsSubModules(this.translations),modJs.subModJsList[g].setPermissions(this.permissions),modJs.subModJsList[g].setFieldTemplates(this.fieldTemplates),modJs.subModJsList[g].setTemplates(this.templates),modJs.subModJsList[g].setCustomTemplates(this.customTemplates),modJs.subModJsList[g].setEmailTemplates(this.emailTemplates),modJs.subModJsList[g].setUser(this.user),modJs.subModJsList[g].initFieldMasterData(),modJs.subModJsList[g].setBaseUrl(this.baseUrl),modJs.subModJsList[g].setCurrentProfile(this.currentProfile),modJs.subModJsList[g].setInstanceId(this.instanceId),modJs.subModJsList[g].setGoogleAnalytics(ga),modJs.subModJsList[g].setNoJSONRequests(this.noJSONRequests));modJs.subModJsList.tabEmployeeSkillSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeSkillSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeSkillSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeSkillSubTab.get([]),modJs.subModJsList.tabEmployeeEducationSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeEducationSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeEducationSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeEducationSubTab.get([]),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeCertificationSubTab.get([]),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeLanguageSubTab.get([]),modJs.subModJsList.tabEmployeeDependentSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeDependentSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeDependentSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeDependentSubTab.get([]),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.get([]),this.isModuleInstalled("admin","documents")&&(modJs.subModJsList.tabEmployeeDocumentSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeDocumentSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeDocumentSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeDocumentSubTab.get([])),$("#subModTab a").off().on("click",function(e){e.preventDefault(),$(this).tab("show")})}},{key:"deleteProfileImage",value:function(e){var t={id:e},l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="modEmployeeDeleteProfileImageCallBack",a.callBackFail="modEmployeeDeleteProfileImageCallBack",this.customAction("deleteProfileImage","modules=employees",l,a)}},{key:"modEmployeeDeleteProfileImageCallBack",value:function(e){}}]),t}(),g=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,v),a(t,[{key:"getDataMapping",value:function(){return["id","image","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID"},{sTitle:"",bSortable:!1},{sTitle:"Employee Number"},{sTitle:"First Name"},{sTitle:"Last Name"},{sTitle:"Mobile"},{sTitle:"Department"},{sTitle:"Gender"},{sTitle:"Supervisor"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden",validation:""}],["employee_id",{label:"Employee Number",type:"text",validation:""}],["first_name",{label:"First Name",type:"text",validation:""}],["middle_name",{label:"Middle Name",type:"text",validation:"none"}],["last_name",{label:"Last Name",type:"text",validation:""}],["nationality",{label:"Nationality",type:"select2","remote-source":["Nationality","id","name"]}],["birthday",{label:"Date of Birth",type:"date",validation:""}],["gender",{label:"Gender",type:"select",source:[["Male","Male"],["Female","Female"]]}],["marital_status",{label:"Marital Status",type:"select",source:[["Married","Married"],["Single","Single"],["Divorced","Divorced"],["Widowed","Widowed"],["Other","Other"]]}],["ssn_num",{label:"SSN/NRIC",type:"text",validation:"none"}],["nic_num",{label:"NIC",type:"text",validation:"none"}],["other_id",{label:"Other ID",type:"text",validation:"none"}],["driving_license",{label:"Driving License No",type:"text",validation:"none"}],["employment_status",{label:"Employment Status",type:"select2","remote-source":["EmploymentStatus","id","name"]}],["job_title",{label:"Job Title",type:"select2","remote-source":["JobTitle","id","name"]}],["pay_grade",{label:"Pay Grade",type:"select2","allow-null":!0,"remote-source":["PayGrade","id","name"]}],["work_station_id",{label:"Work Station Id",type:"text",validation:"none"}],["address1",{label:"Address Line 1",type:"text",validation:"none"}],["address2",{label:"Address Line 2",type:"text",validation:"none"}],["city",{label:"City",type:"text",validation:"none"}],["country",{label:"Country",type:"select2","remote-source":["Country","code","name"]}],["province",{label:"Province",type:"select2","allow-null":!0,"remote-source":["Province","id","name"]}],["postal_code",{label:"Postal/Zip Code",type:"text",validation:"none"}],["home_phone",{label:"Home Phone",type:"text",validation:"none"}],["mobile_phone",{label:"Mobile Phone",type:"text",validation:"none"}],["work_phone",{label:"Work Phone",type:"text",validation:"none"}],["work_email",{label:"Work Email",type:"text",validation:"emailOrEmpty"}],["private_email",{label:"Private Email",type:"text",validation:"emailOrEmpty"}],["joined_date",{label:"Joined Date",type:"date",validation:""}],["confirmation_date",{label:"Confirmation Date",type:"date",validation:"none"}],["termination_date",{label:"Termination Date",type:"date",validation:"none"}],["department",{label:"Department",type:"select2","remote-source":["CompanyStructure","id","title"]}],["supervisor",{label:"Supervisor",type:"select2","allow-null":!0,"remote-source":["Employee","id","first_name+last_name"]}],["notes",{label:"Notes",type:"datagroup",form:[["note",{label:"Note",type:"textarea",validation:""}]],html:'
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ',validation:"none","sort-function":function(e,t){return Date.parse(e.date).getTime()';return l=(l=(l=l.replace(/_id_/g,e)).replace(/_attachment_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}();t.exports={EmployeeAdapter:v,TerminatedEmployeeAdapter:g,ArchivedEmployeeAdapter:_,EmployeeSkillAdapter:k,EmployeeEducationAdapter:S,EmployeeCertificationAdapter:E,EmployeeLanguageAdapter:w,EmployeeDependentAdapter:T,EmergencyContactAdapter:D,EmployeeImmigrationAdapter:F,EmployeeSubSkillsAdapter:d,EmployeeSubEducationAdapter:c,EmployeeSubCertificationAdapter:p,EmployeeSubLanguageAdapter:m,EmployeeSubDependentAdapter:h,EmployeeSubEmergencyContactAdapter:f,EmployeeSubDocumentAdapter:y,EmployeeDocumentAdapter:M}},{"../../../api/AdapterBase":4,"../../../api/SubAdapterBase":7}],3:[function(e,t,l){"use strict";Object.defineProperty(l,"__esModule",{value:!0});var a=function(){function e(e,t){for(var l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var l=localStorage.getItem(e);return void 0!==l&&null!=l&&""!==l?void 0===(t=JSON.parse(l))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var l=JSON.stringify(t);return localStorage.setItem(e,l),l}}]),e}();l.default=i},{}],4:[function(e,t,l){"use strict";Object.defineProperty(l,"__esModule",{value:!0});var a=function(){function e(e,t){for(var l=0;l0}},o=function(){function e(t,l,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=l,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,a),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return a(e,[{key:"clearError",value:function(e,t){var l=e.attr("id");$("#"+this.formId+" #field_"+l).removeClass("error"),$("#"+this.formId+" #help_"+l).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var l=e.attr("id"),a=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+l).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+l).html(i):void 0===a||null==a||""===a?$("#"+this.formId+" #help_err_"+l).html("Required"):"float"===a||"number"===a?$("#"+this.formId+" #help_err_"+l).html("Number required"):"email"===a?$("#"+this.formId+" #help_err_"+l).html("Email required"):$("#"+this.formId+" #help_err_"+l).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var l=function(e){var l=null,a=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+a+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),o=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(o,t.inputTypes)>=0){if(e.hasClass("uploadInput"))l=e.attr("val");else if("radio"===o||"checkbox"===o)l=$("input[name='"+a+"']:checked").val();else if(e.hasClass("select2Field"))l=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");l=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var l in t)t[l].sTitle=this.gt(t[l].sTitle);var a=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(l)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=l?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){l.apply(o,a),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,l,a,i){var o=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=l?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){l.apply(o,a),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var l=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();a=this.forceInjectValuesBeforeSave(a);var i=this.doCustomValidation(a);if(null==i){this.csrfRequired&&(a.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var o=$("#"+this.getTableName()+"_submit #id").val();null!=o&&void 0!==o&&""!==o&&(a.id=o),a=this.makeEmptyDateFieldsNull(a),this.add(a,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var l in t)t.hasOwnProperty(l)&&"NULL"===t[l]&&delete t[l];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",l=void 0,a=void 0,i=void 0,o=void 0,n=void 0,s=void 0,r=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,r)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])l=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[l[0]+"_"+l[1]+"_"+l[2]][e[u]];else if(a=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');r.attr("id",s),r.html(t),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),this.showDomElement("Edit",r,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var l=this.templates.formTemplate,a="",i=this.getFormFields(),o=0;o')).attr("id",u):r=$("#"+this.getTableName()+"Form"),r.html(l),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),r.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),a=a.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(a=a.replace("#_renderFunction_#",t[1].render(i))),(o=$(a)).attr("fieldId",t[0]+"_div"),r.append(o)}return r}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var l=this.templates.datagroupTemplate,a="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var o=0;o');s.attr("id",n),s.html(l),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var l=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[a])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;a=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var o=JSON.parse(i);a.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(o),o.push(a),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&o.sort(e[1]["sort-function"]),i=JSON.stringify(o);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var l="";try{for(var a=e.split(" "),i=0,o=0;ot?(l+=a[o]+"
    ",i=0):l+=a[o]+" "}catch(e){}return l}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var l=$(e.target);if(!/html|body/i.test(l.offsetParent()[0].tagName)){var a=e.pageY-l.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:a+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],l=void 0,a=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var o=JSON.parse(i);a.each(function(){for(var e in l=$(this).attr("id"),o)if(o[e].id===l){t.push(o[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,l=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[a]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;a=i.params}if(this.doCustomFilterValidation(a)){var o=$("#"+e[0]).val();""===o&&(o="[]");for(var s=JSON.parse(o),r={},u=-1,d=[],c=0;c=t&&(t=parseInt(l,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),l=$("#"+t).val(),a=JSON.parse(l),i=[],o=0;o")}catch(e){}if(void 0!==l[i][1].formatter&&l[i][1].formatter&&$.isFunction(l[i][1].formatter))try{a=l[i][1].formatter(a)}catch(e){}$(t+" #"+l[i][0]).html(a)}else if("fileupload"===l[i][1].type)null!=e[l[i][0]]&&void 0!==e[l[i][0]]&&""!==e[l[i][0]]&&($(t+" #"+l[i][0]).html(e[l[i][0]]),$(t+" #"+l[i][0]).attr("val",e[l[i][0]]),$(t+" #"+l[i][0]).show(),$(t+" #"+l[i][0]+"_download").show(),$(t+" #"+l[i][0]+"_remove").show()),!0===l[i][1].readonly&&$(t+" #"+l[i][0]+"_upload").remove();else if("select"===l[i][1].type)void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL"),$(t+" #"+l[i][0]).val(e[l[i][0]]);else if("select2"===l[i][1].type)void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL"),$(t+" #"+l[i][0]).select2("val",e[l[i][0]]);else if("select2multi"===l[i][1].type){void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL");var u=[];if(void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]])try{u=JSON.parse(e[l[i][0]])}catch(e){}$(t+" #"+l[i][0]).select2("val",u);var d=$(t+" #"+l[i][0]).find(".select2-choices").height();$(t+" #"+l[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+l[i][0]).css("min-height",d+"px")}else if("datagroup"===l[i][1].type)try{var c=this.dataGroupToHtml(e[l[i][0]],l[i]);$(t+" #"+l[i][0]).val(e[l[i][0]]),$(t+" #"+l[i][0]+"_div").html(""),$(t+" #"+l[i][0]+"_div").append(c),this.makeDataGroupSortable(l[i],$(t+" #"+l[i][0]+"_div_inner"))}catch(e){}else"signature"===l[i][1].type?""===e[l[i][0]]&&void 0===e[l[i][0]]&&null==e[l[i][0]]||$(t+" #"+l[i][0]).data("signaturePad").fromDataURL(e[l[i][0]]):"simplemde"===l[i][1].type?$(t+" #"+l[i][0]).data("simplemde").value(e[l[i][0]]):$(t+" #"+l[i][0]).val(e[l[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var l=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)l=l.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var a=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];l=l.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[a],e))}}else if("colorpick"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,l=(l=l.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),l=(l=void 0!==e[1].filetypes&&null!=e[1].filetypes?l.replace(/_filetypes_/g,e[1].filetypes):l.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return l=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?l.replace(/_validation_/g,'validation="'+e[1].validation+'"'):l.replace(/_validation_/g,""),l=void 0!==e[1].help&&null!==e[1].help?(l=l.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(l=l.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),l=void 0!==e[1].placeholder&&null!==e[1].placeholder?l.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):l.replace(/_placeholder_/g,""),l=void 0!==e[1].mask&&null!==e[1].mask?l.replace(/_mask_/g,'mask="'+e[1].mask+'"'):l.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var l="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?l+='":l+='');var a=[];for(var i in e)a.push(e[i]);!0===t[1].sort&&a.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var o=0;o_val_';l+=r=(r=r.replace("_id_",n)).replace("_val_",this.gt(s))}return l}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var l="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?l+='":l+='');var a=[];for(var i in e)a.push([i,e[i]]);"true"===t[1].sort&&a.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var o=0;o_val_';l+=r=(r=r.replace("_id_",n)).replace("_val_",this.gt(s))}return l}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var l='
    _edit__delete__clone_
    ';return l=this.showAddNew?l.replace("_clone_",''):l.replace("_clone_",""),l=this.showDelete?l.replace("_delete_",''):l.replace("_delete_",""),l=(l=(l=this.showEdit?l.replace("_edit_",''):l.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",a="",i=e;i>0;--i)a+=l[Math.round(Math.random()*(l.length-1))];return a+t.getTime()}},{key:"checkFileType",value:function(e,t){var l=document.getElementById(e),a="";return l.value.lastIndexOf(".")>0&&(a=l.value.substring(l.value.lastIndexOf(".")+1,l.value.length)),a=a.toLowerCase(),!(t.split(",").indexOf(a)<0)||(l.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),l=t.toGMTString();return(t-new Date(l.substring(0,l.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var l in e)t+=''.replace("__val__",l).replace("__text__",e[l]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,l=void 0,a=0;a
  • ',s='',r=$('
    '),u=this.getSubHeader();if(r.append(u),0===o.length)r.append(''+this.getNoDataMessage()+"");else for(var d=0;d

    '+this.getSubHeaderTitle()+"

    ")}}]),t}();l.default=s},{"./AdapterBase":4}]},{},[1]); +//# sourceMappingURL=employees.js.map diff --git a/web/admin/dist/fieldnames.js b/web/admin/dist/fieldnames.js new file mode 100644 index 00000000..5ea8dbab --- /dev/null +++ b/web/admin/dist/fieldnames.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,o){if(!a[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var d=a[n]={exports:{}};t[n][0].call(d.exports,function(e){return i(t[n][1][e]||e)},d,d.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a
    #_delete_##_edit_##_label_#:#_value_#
    ',validation:"none"}],["display_order",{label:"Priority",type:"text",validation:"number"}],["display_section",{label:"Display Section",type:"text",validation:"none"}]]}},{key:"setTableType",value:function(e){this.tableType=e}},{key:"doCustomValidation",value:function(e){var t;return null!=(t=e.name)&&/^[a-z][a-z0-9._]+$/.test(t)?null:"Invalid name for custom field"}},{key:"forceInjectValuesBeforeSave",value:function(e){var t=[e.name],a=[],l=void 0;if(t.push({}),t[1].label=e.field_label,t[1].type=e.field_type,t[1].validation=e.field_validation,["select","select2","select2multi"].indexOf(e.field_type)>=0){for(var i in l=""===e.field_options||void 0===e.field_options?[]:JSON.parse(e.field_options))a.push([l[i].value,l[i].label]);t[1].source=a}return null!=e.field_validation&&void 0!==e.field_validation||(e.field_validation=""),e.data=JSON.stringify(t),e.type=this.tableType,e}}]),t}();a.default=o},{"./AdapterBase":4}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;lparseFloat(e.max_salary))return"Min Salary should be smaller than Max Salary"}catch(e){}return null}}]),t}(),h=function(e){function t(){return s(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,n.default),i(t,[{key:"getDataMapping",value:function(){return["id","name","description"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID"},{sTitle:"Name"},{sTitle:"Description"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Employment Status",type:"text"}],["description",{label:"Description",type:"textarea",validation:""}]]}}]),t}();t.exports={JobTitleAdapter:c,PayGradeAdapter:d,EmploymentStatusAdapter:h}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=s},{"./LogViewAdapter":7}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=s},{"./AdapterBase":4}],8:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l')).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"getActionButtonHeader",value:function(){return{sTitle:'',sClass:"center"}}}]),t}(),p=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","pay_period","department","date_start","date_end","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Pay Frequency"},{sTitle:"Department"},{sTitle:"Date Start"},{sTitle:"Date End"},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text"}],["pay_period",{label:"Pay Frequency",type:"select","remote-source":["PayFrequency","id","name"],sort:"none"}],["deduction_group",{label:"Calculation Group",type:"select","remote-source":["DeductionGroup","id","name"],sort:"none"}],["payslipTemplate",{label:"Payslip Template",type:"select","remote-source":["PayslipTemplate","id","name"]}],["department",{label:"Department",type:"select2","remote-source":["CompanyStructure","id","title"],sort:"none"}],["date_start",{label:"Start Date",type:"date",validation:""}],["date_end",{label:"End Date",type:"date",validation:""}],["columns",{label:"Payroll Columns",type:"select2multi","remote-source":["PayrollColumn","id","name"]}],["status",{label:"Status",type:"select",source:[["Draft","Draft"],["Completed","Completed"]],sort:"none"}]]}},{key:"postRenderForm",value:function(e,t){null!=e&&void 0!==e&&void 0!==e.id&&null!=e.id&&(t.find("#pay_period").attr("disabled","disabled"),t.find("#department").attr("disabled","disabled"))}},{key:"process",value:function(e,t){modJs=modJsList.tabPayrollData,modJs.setCurrentPayroll(e),$("#Payroll").hide(),$("#PayrollData").show(),$("#PayrollDataButtons").show(),"Completed"===t?($(".completeBtnTable").hide(),$(".saveBtnTable").hide()):($(".completeBtnTable").show(),$(".saveBtnTable").show()),modJs.get([])}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__process__clone__delete_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace("_process_",'')).replace(/_id_/g,e)).replace(/_status_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"get",value:function(e){$("#PayrollData").hide(),$("#PayrollForm").hide(),$("#PayrollDataButtons").hide(),$("#Payroll").show(),modJsList.tabPayrollData.setCurrentPayroll(null),i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"get",this).call(this,e)}}]),t}(),h=function(e){function t(e,a,l,i){s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return n.cellDataUpdates={},n.payrollId=null,n}return d(t,o.default),l(t,[{key:"validateCellValue",value:function(e,t,a){return modJs.addCellDataUpdate(e.data("colId"),e.data("rowId"),a),!0}},{key:"setCurrentPayroll",value:function(e){this.payrollId=e}},{key:"addAdditionalRequestData",value:function(e,t){return"updateData"===e?t.payrollId=this.payrollId:"updateAllData"===e?t.payrollId=this.payrollId:"getAllData"===e&&(t.payrollId=this.payrollId),t}},{key:"modifyCSVHeader",value:function(e){return e.unshift(""),e}},{key:"getCSVData",value:function(){for(var e="",t=0;t#_delete_##_edit_#
    #_renderFunction_#
    ',validation:"none",render:function(e){return"Variable:"+e.name}}],["calculation_function",{label:"Function",type:"text",validation:"none"}]]}},{key:"getFilters",value:function(){return[["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"Any","remote-source":["DeductionGroup","id","name"]}]]}}]),t}(),m=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!0},{sTitle:"Name"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["columns",{label:"Payroll Columns",type:"select2multi","remote-source":["PayrollColumn","id","name"]}]]}}]),t}(),v=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","employee","pay_frequency","deduction_group","currency"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Pay Frequency"},{sTitle:"Calculation Group"},{sTitle:"Currency"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"select2","remote-source":["Employee","id","first_name+last_name"]}],["pay_frequency",{label:"Pay Frequency",type:"select2","remote-source":["PayFrequency","id","name"]}],["currency",{label:"Currency",type:"select2","remote-source":["CurrencyType","id","code"]}],["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"None","remote-source":["DeductionGroup","id","name"]}],["deduction_exemptions",{label:"Calculation Exemptions",type:"select2multi","remote-source":["Deduction","id","name"],validation:"none"}],["deduction_allowed",{label:"Calculations Assigned",type:"select2multi","remote-source":["Deduction","id","name"],validation:"none"}]]}},{key:"getFilters",value:function(){return[["employee",{label:"Employee",type:"select2","remote-source":["Employee","id","first_name+last_name"]}]]}}]),t}(),y=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","deduction_group"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Calculation Group"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["componentType",{label:"Salary Component Type",type:"select2multi","allow-null":!0,"remote-source":["SalaryComponentType","id","name"]}],["component",{label:"Salary Component",type:"select2multi","allow-null":!0,"remote-source":["SalaryComponent","id","name"]}],["payrollColumn",{label:"Payroll Report Column",type:"select2","allow-null":!0,"remote-source":["PayrollColumn","id","name"]}],["rangeAmounts",{label:"Calculation Process",type:"datagroup",form:[["lowerCondition",{label:"Lower Limit Condition",type:"select",source:[["No Lower Limit","No Lower Limit"],["gt","Greater than"],["gte","Greater than or Equal"]]}],["lowerLimit",{label:"Lower Limit",type:"text",validation:"float"}],["upperCondition",{label:"Upper Limit Condition",type:"select",source:[["No Upper Limit","No Upper Limit"],["lt","Less than"],["lte","Less than or Equal"]]}],["upperLimit",{label:"Upper Limit",type:"text",validation:"float"}],["amount",{label:"Value",type:"text",validation:""}]],html:'
    #_delete_##_edit_#
    #_renderFunction_#
    ',validation:"none","custom-validate-function":function(e){var t={valid:!0};return"No Lower Limit"===e.lowerCondition&&(e.lowerLimit=0),"No Upper Limit"===e.upperCondition&&(e.upperLimit=0),t.params=e,t},render:function(e){var t="",a=function(e){var t={gt:">",gte:">=",lt:"<",lte:"<="};return t[e]};return"No Lower Limit"!==e.lowerCondition&&(t+=e.lowerLimit+" "+a(e.lowerCondition)+" "),"No Upper Limit"!==e.upperCondition&&(t+=" and ",t+=a(e.upperCondition)+" "+e.upperLimit+" "),""===t?"Deduction is "+e.amount+" for all ranges":"If salary component "+t+" deduction is "+e.amount}}],["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"None","remote-source":["DeductionGroup","id","name"]}]]}}]),t}(),g=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","description"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Details"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["description",{label:"Details",type:"textarea",validation:"none"}]]}}]),t}(),b=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["data",{label:"Payslip Fields",type:"datagroup",form:[["type",{label:"Type",type:"select",sort:"none",source:[["Payroll Column","Payroll Column"],["Text","Text"],["Company Name","Company Name"],["Company Logo","Company Logo"],["Separators","Separators"]]}],["payrollColumn",{label:"Payroll Column",type:"select2",sort:"none","allow-null":!0,"null-label":"None","remote-source":["PayrollColumn","id","name"]}],["label",{label:"Label",type:"text",validation:"none"}],["text",{label:"Text",type:"textarea",validation:"none"}],["status",{label:"Status",type:"select",sort:"none",source:[["Show","Show"],["Hide","Hide"]]}]],html:'
    #_delete_##_edit_#
    #_type_# #_label_#
    #_text_#
    ',validation:"none","custom-validate-function":function(e){var t={valid:!0};return"Payroll Column"===e.type?"NULL"===e.payrollColumn?(t.valid=!1,t.message="Please select payroll column"):e.payrollColumn="NULL":"Text"===e.type&&""===e.text&&(t.valid=!1,t.message="Text can not be empty"),t.params=e,t}}]]}}]),t}();t.exports={PaydayAdapter:c,PayrollAdapter:p,PayrollDataAdapter:h,PayrollColumnAdapter:f,PayrollColumnTemplateAdapter:m,PayrollEmployeeAdapter:v,DeductionAdapter:y,DeductionGroupAdapter:g,PayslipTemplateAdapter:b}},{"../../../api/AdapterBase":4,"../../../api/TableEditAdapter":7}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},n=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),n=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(n,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===n||"checkbox"===n)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var o=$("#"+t.formId+" #"+i).select2("data");a=[];for(var r=0;r'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],n=this,o="";o=i?"#plainMessageModel":"#messageModel",$(o).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(o).modal({show:!0}),$(o).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(o).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var n=this,o="";o=i?"#dataMessageModel":"#messageModel",$(o).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(o).modal({show:!0}),$(o).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(o).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new o.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var n=$("#"+this.getTableName()+"_submit #id").val();null!=n&&void 0!==n&&""!==n&&(l.id=n),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new o.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,n=void 0,o=void 0,r=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(o="",r=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?o=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":r=o=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])o=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');s.attr("id",r),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),n=0;n')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(o=i[d])&&null!=o&&"string"==typeof o&&(o=o.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",o);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(n=$(l)).attr("fieldId",t[0]+"_div"),s.append(n)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var n=0;n');r.attr("id",o),r.html(a),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,r,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new o.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(n),n.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&n.sort(e[1]["sort-function"]),i=JSON.stringify(n);var r=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(r),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,n=0;nt?(a+=l[n]+"
    ",i=0):a+=l[n]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),n)if(n[e].id===a){t.push(n[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new o.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var n=$("#"+e[0]).val();""===n&&(n="[]");for(var r=JSON.parse(n),s={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],n=0;n")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",o)).replace("_val_",this.gt(r))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",o)).replace("_val_",this.gt(r))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    ';var n=$("#"+e+" .dataTables_paginate .active a").html(),o=0;void 0!==n&&null!=n&&(o=15*parseInt(n,10)-15),$("#"+e).html(i);var r={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t,aoColumns:a,bSort:!1,iDisplayLength:15,iDisplayStart:o},s=this.getCustomTableParams();$.extend(r,s),$("#"+e+" #grid").dataTable(r),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$("#"+e+" #grid").editableTableWidget(),$("#"+e+" #grid .editcell").on("validate",function(e,t){return modJs.validateCellValue($(this),e,t)}),this.afterCreateTable(e)}},{key:"afterCreateTable",value:function(e){}},{key:"addCellDataUpdate",value:function(e,t,a){this.cellDataUpdates[e+"="+t]=[e,t,a]}},{key:"addAdditionalRequestData",value:function(e,t){return t}},{key:"sendCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataSuccessCallBack",a.callBackFail="updateDataFailCallBack",this.showLoader(),this.customAction("updateData",this.modulePath,t,a)}},{key:"updateDataSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.get()}},{key:"updateDataFailCallBack",value:function(e,t){this.hideLoader()}},{key:"sendAllCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateAllData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataAllSuccessCallBack",a.callBackFail="updateDataAllFailCallBack",this.showLoader(),this.customAction("updateAllData",this.modulePath,t,a)}},{key:"updateDataAllSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.getAllData(!0)}},{key:"updateDataAllFailCallBack",value:function(e,t){this.hideLoader()}},{key:"showActionButtons",value:function(){return!1}}]),t}();a.default=r},{"./AdapterBase":4}]},{},[1]); +//# sourceMappingURL=payroll.js.map diff --git a/web/admin/dist/permissions.js b/web/admin/dist/permissions.js new file mode 100644 index 00000000..bc769ffa --- /dev/null +++ b/web/admin/dist/permissions.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;dDownload Report ':'Download Report ').replace(/_BASE_/g,this.baseUrl),"PDF"===this.currentReport.output||"JSON"===this.currentReport.output)this.showMessage("Download Report",l);else{if(0===t[1].length)return void this.showMessage("Empty Report","There were no data for selected filters");var i=l+'

    ';$("#tempReportTable").remove(),$("#"+this.table).html(i),$("#"+this.table).show(),$("#"+this.table+"Form").hide();var r=[];for(var n in t[1])r.push({sTitle:t[1][n]});var s={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t[2],aoColumns:r,bSort:!1,iDisplayLength:15,iDisplayStart:0};$("#tempReportTable").dataTable(s),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$(".tableActionButton").tooltip()}}},{key:"fillForm",value:function(e){for(var t=this.getFormFields(),a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=o},{"./LogViewAdapter":8}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a
    #_delete_##_edit_##_label_#:#_value_#
    ',validation:"none"}],["display_order",{label:"Priority",type:"text",validation:"number"}],["display_section",{label:"Display Section",type:"text",validation:"none"}]]}},{key:"setTableType",value:function(e){this.tableType=e}},{key:"doCustomValidation",value:function(e){var t;return null!=(t=e.name)&&/^[a-z][a-z0-9._]+$/.test(t)?null:"Invalid name for custom field"}},{key:"forceInjectValuesBeforeSave",value:function(e){var t=[e.name],a=[],l=void 0;if(t.push({}),t[1].label=e.field_label,t[1].type=e.field_type,t[1].validation=e.field_validation,["select","select2","select2multi"].indexOf(e.field_type)>=0){for(var i in l=""===e.field_options||void 0===e.field_options?[]:JSON.parse(e.field_options))a.push([l[i].value,l[i].label]);t[1].source=a}return null!=e.field_validation&&void 0!==e.field_validation||(e.field_validation=""),e.data=JSON.stringify(t),e.type=this.tableType,e}}]),t}();a.default=o},{"./AdapterBase":4}],7:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=o},{"./AdapterBase":4}],9:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l",t+=" You may create a new employee through 'Admin'->'Employees' menu"),t}},{key:"save",value:function(){var e=new i.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters(),a=this.doCustomValidation(t);if(null==a){var l=$("#"+this.getTableName()+"_submit #id").val();if(t.csrf=$("#"+this.getTableName()+"Form").data("csrf"),null!=l&&void 0!==l&&""!==l)t.id=l,this.add(t,[]);else{var r=JSON.stringify(t),s=[];s.callBackData=[],s.callBackSuccess="saveUserSuccessCallBack",s.callBackFail="saveUserFailCallBack",this.customAction("saveUser","admin=users",r,s)}}else this.showMessage("Error Saving User",a)}}},{key:"changePasswordConfirm",value:function(){$("#adminUsersChangePwd_error").hide();var e=$("#adminUsersChangePwd #newpwd").val();if(!(e.length>7))return $("#adminUsersChangePwd_error").html("Password should be longer than 7 characters"),void $("#adminUsersChangePwd_error").show();var t=$("#adminUsersChangePwd #conpwd").val();if(t!==e)return $("#adminUsersChangePwd_error").html("Passwords don't match"),void $("#adminUsersChangePwd_error").show();var a={id:this.currentId,pwd:t},l=JSON.stringify(a),i=[];i.callBackData=[],i.callBackSuccess="changePasswordSuccessCallBack",i.callBackFail="changePasswordFailCallBack",this.customAction("changePassword","admin=users",l,i)}},{key:"closeChangePassword",value:function(){$("#adminUsersModel").modal("hide")}},{key:"changePasswordSuccessCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Password Change","Password changed successfully")}},{key:"changePasswordFailCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Error",e)}}]),t}(),d=function(e){function t(){return n(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,r.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"}]}},{key:"postRenderForm",value:function(e,t){t.find("#changePasswordBtn").remove()}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}]]}}]),t}();t.exports={UserAdapter:c,UserRoleAdapter:d}},{"../../../api/AdapterBase":4,"../../../api/FormValidation":5}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var s=$("#"+t.formId+" #"+i).select2("data");a=[];for(var n=0;n'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,s="";s=i?"#plainMessageModel":"#messageModel",$(s).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,s="";s=i?"#dataMessageModel":"#messageModel",$(s).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new s.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new s.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,s=void 0,n=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(s="",n=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":n=s=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",n),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(s=i[c])&&null!=s&&"string"==typeof s&&(s=s.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",s);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');n.attr("id",s),n.html(a),n.find(".datefield").datepicker({viewMode:2}),n.find(".timefield").datetimepicker({language:"en",pickDate:!1}),n.find(".datetimefield").datetimepicker({language:"en"}),n.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+n.attr("id")+" .tinymce",height:"400"}),n.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),n.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),n.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,n,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var n=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(n),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var n=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    '; -}); - -EmployeeAdapter.method('getTableFields', function() { - var tableFields = [ - "id", - "image", - "employee_id", - "first_name", - "last_name", - "mobile_phone", - "department", - "gender", - "supervisor" - ]; - return tableFields; -}); - -EmployeeAdapter.method('getDataMapping', function() { - var tableFields = this.getTableFields(); - - var newTableFields = []; - for(var i=0;i
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', - "validation":"none", - "sort-function":function (a,b){ - var t1 = Date.parse(a.date).getTime(); - var t2 = Date.parse(b.date).getTime(); - - return (t1'; - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -EmployeeAdapter.method('getHelpLink', function () { - return 'https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html'; -}); - -EmployeeAdapter.method('saveSuccessItemCallback', function(data) { - this.lastSavedEmployee = data; - if(this.currentId == null){ - $('#createUserModel').modal('show'); - } - -}); - -EmployeeAdapter.method('closeCreateUser', function() { - $('#createUserModel').modal('hide'); -}); - -EmployeeAdapter.method('createUser', function() { - var data = {}; - data['employee'] = this.lastSavedEmployee.id; - data['user_level'] = "Employee"; - data['email'] = this.lastSavedEmployee.work_email; - data['username'] = this.lastSavedEmployee.work_email.split("@")[0]; - var url = this.getCustomUrl('?g=admin&n=users&m=admin_Admin&action=new&object='+Base64.encodeURI(JSON.stringify(data))); - top.location.href = url; -}); - -EmployeeAdapter.method('deleteEmployee', function(id) { - - if (confirm('Are you sure you want to archive this employee? Data for this employee will be saved to an archive table. But you will not be able to covert the archived employee data into a normal employee.')) { - //Archive - } else { - return; - } - - var params = {}; - params['id'] = id; - var reqJson = JSON.stringify(params); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'deleteEmployeeSuccessCallback'; - callBackData['callBackFail'] = 'deleteEmployeeFailCallback'; - - this.customAction('deleteEmployee','admin=employees',reqJson,callBackData); -}); - - -EmployeeAdapter.method('deleteEmployeeSuccessCallback', function(callBackData) { - this.showMessage("Delete Success","Employee deleted. You can find archived information for this employee in Archived Employees tab"); - this.get([]); -}); - - -EmployeeAdapter.method('deleteEmployeeFailCallback', function(callBackData) { - this.showMessage("Error occurred while deleting Employee", callBackData); -}); - - -EmployeeAdapter.method('terminateEmployee', function(id) { - - if (confirm('Are you sure you want to terminate this employee contract? You will still be able to access all details of this employee.')) { - //Terminate - } else { - return; - } - - var params = {}; - params['id'] = id; - var reqJson = JSON.stringify(params); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'terminateEmployeeSuccessCallback'; - callBackData['callBackFail'] = 'terminateEmployeeFailCallback'; - - this.customAction('terminateEmployee','admin=employees',reqJson,callBackData); -}); - - -EmployeeAdapter.method('terminateEmployeeSuccessCallback', function(callBackData) { - this.showMessage("Success","Employee contract terminated. You can find terminated employee information under Terminated Employees menu."); - this.get([]); -}); - - -EmployeeAdapter.method('terminateEmployeeFailCallback', function(callBackData) { - this.showMessage("Error occured while terminating Employee", callBackData); -}); - - -EmployeeAdapter.method('activateEmployee', function(id) { - - if (confirm('Are you sure you want to re-activate this employee contract?')) { - //Terminate - } else { - return; - } - - var params = {}; - params['id'] = id; - var reqJson = JSON.stringify(params); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'activateEmployeeSuccessCallback'; - callBackData['callBackFail'] = 'activateEmployeeFailCallback'; - - this.customAction('activateEmployee','admin=employees',reqJson,callBackData); -}); - - -EmployeeAdapter.method('activateEmployeeSuccessCallback', function(callBackData) { - this.showMessage("Success","Employee contract re-activated."); - this.get([]); -}); - - -EmployeeAdapter.method('activateEmployeeFailCallback', function(callBackData) { - this.showMessage("Error occured while activating Employee", callBackData); -}); - - -EmployeeAdapter.method('view', function(id) { - - var that = this; - this.currentId = id; - var sourceMappingJson = JSON.stringify(this.getSourceMapping()); - var object = {"id":id, "map":sourceMappingJson}; - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'renderEmployee'; - callBackData['callBackFail'] = 'viewFailCallBack'; - - this.customAction('get','modules=employees',reqJson,callBackData); -}); - - -EmployeeAdapter.method('viewFailCallBack', function(callBackData) { - this.showMessage("Error","Error Occured while retriving candidate"); -}); - -EmployeeAdapter.method('renderEmployee', function(data) { - var title; - var fields = this.getFormFields(); - var currentEmpId = data[1]; - var currentId = data[1]; - var userEmpId = data[2]; - data = data[0]; - this.currentEmployee = data; - var html = this.getCustomTemplate('myDetails.html'); - - - for(var i=0;i 0) { - - - var ct = '
    '; - var customFieldHtml; - for (index in data.customFields) { - - if(!data.customFields[index][1]){ - data.customFields[index][1] = this.gt('Other Details'); - } - - sectionId = data.customFields[index][1].toLocaleLowerCase(); - sectionId = sectionId.replace(' ','_'); - - if($("#cont_"+sectionId).length <= 0){ - //Add section - sectionHtml = sectionTemplate; - sectionHtml = sectionHtml.replace('#_section_#', sectionId); - sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); - $("#customFieldsCont").append($(sectionHtml)); - } - - customFieldHtml = ct; - customFieldHtml = customFieldHtml.replace('#_label_#', ''); - if (data.customFields[index][2] === 'fileupload') { - customFieldHtml = customFieldHtml.replace( - '#_value_#', - '' - ); - } else { - customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); - } - $("#cont_"+sectionId).append($(customFieldHtml)); - } - }else{ - $("#customFieldsCont").remove(); - } - - - this.cancel(); - - if(!this.isModuleInstalled("admin","documents")) { - $('#tabDocuments').remove(); - } - - - modJs = this; - modJs.subModJsList = new Array(); - - modJs.subModJsList['tabEmployeeSkillSubTab'] = new EmployeeSubSkillsAdapter('EmployeeSkill','EmployeeSkillSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeSkillSubTab'].parent = this; - - modJs.subModJsList['tabEmployeeEducationSubTab'] = new EmployeeSubEducationAdapter('EmployeeEducation','EmployeeEducationSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeEducationSubTab'].parent = this; - - modJs.subModJsList['tabEmployeeCertificationSubTab'] = new EmployeeSubCertificationAdapter('EmployeeCertification','EmployeeCertificationSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeCertificationSubTab'].parent = this; - - modJs.subModJsList['tabEmployeeLanguageSubTab'] = new EmployeeSubLanguageAdapter('EmployeeLanguage','EmployeeLanguageSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeLanguageSubTab'].parent = this; - - modJs.subModJsList['tabEmployeeDependentSubTab'] = new EmployeeSubDependentAdapter('EmployeeDependent','EmployeeDependentSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeDependentSubTab'].parent = this; - - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'] = new EmployeeSubEmergencyContactAdapter('EmergencyContact','EmployeeEmergencyContactSubTab',{"employee":data.id}); - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'].parent = this; - - if(this.isModuleInstalled("admin","documents")) { - modJs.subModJsList['tabEmployeeDocumentSubTab'] = new EmployeeSubDocumentAdapter('EmployeeDocument', 'EmployeeDocumentSubTab', {"employee": data.id}); - modJs.subModJsList['tabEmployeeDocumentSubTab'].parent = this; - } - for (var prop in modJs.subModJsList) { - if(modJs.subModJsList.hasOwnProperty(prop)){ - modJs.subModJsList[prop].setTranslationsSubModules(this.translations); - modJs.subModJsList[prop].setPermissions(this.permissions); - modJs.subModJsList[prop].setFieldTemplates(this.fieldTemplates); - modJs.subModJsList[prop].setTemplates(this.templates); - modJs.subModJsList[prop].setCustomTemplates(this.customTemplates); - modJs.subModJsList[prop].setEmailTemplates(this.emailTemplates); - modJs.subModJsList[prop].setUser(this.user); - modJs.subModJsList[prop].initFieldMasterData(); - modJs.subModJsList[prop].setBaseUrl(this.baseUrl); - modJs.subModJsList[prop].setCurrentProfile(this.currentProfile); - modJs.subModJsList[prop].setInstanceId(this.instanceId); - modJs.subModJsList[prop].setGoogleAnalytics(ga); - modJs.subModJsList[prop].setNoJSONRequests(this.noJSONRequests); - } - } - - modJs.subModJsList['tabEmployeeSkillSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeSkillSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeSkillSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeSkillSubTab'].get([]); - - modJs.subModJsList['tabEmployeeEducationSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeEducationSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeEducationSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeEducationSubTab'].get([]); - - modJs.subModJsList['tabEmployeeCertificationSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeCertificationSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeCertificationSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeCertificationSubTab'].get([]); - - modJs.subModJsList['tabEmployeeLanguageSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeLanguageSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeLanguageSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeLanguageSubTab'].get([]); - - modJs.subModJsList['tabEmployeeDependentSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeDependentSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeDependentSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeDependentSubTab'].get([]); - - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeEmergencyContactSubTab'].get([]); - - if(this.isModuleInstalled("admin","documents")) { - modJs.subModJsList['tabEmployeeDocumentSubTab'].setShowFormOnPopup(true); - modJs.subModJsList['tabEmployeeDocumentSubTab'].setShowAddNew(false); - modJs.subModJsList['tabEmployeeDocumentSubTab'].setShowCancel(false); - modJs.subModJsList['tabEmployeeDocumentSubTab'].get([]); - } - - $('#subModTab a').off().on('click',function (e) { - e.preventDefault(); - $(this).tab('show'); - }); -}); - - -EmployeeAdapter.method('deleteProfileImage', function(empId) { - var that = this; - - var req = {"id":empId}; - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'modEmployeeDeleteProfileImageCallBack'; - callBackData['callBackFail'] = 'modEmployeeDeleteProfileImageCallBack'; - - this.customAction('deleteProfileImage','modules=employees',reqJson,callBackData); -}); - -EmployeeAdapter.method('modEmployeeDeleteProfileImageCallBack', function(data) { - //top.location.href = top.location.href; -}); - - -/* - * Terminated Employee - */ - -function TerminatedEmployeeAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -TerminatedEmployeeAdapter.inherits(EmployeeAdapter); - - - -TerminatedEmployeeAdapter.method('getDataMapping', function() { - return [ - "id", - "image", - "employee_id", - "first_name", - "last_name", - "mobile_phone", - "department", - "gender", - "supervisor" - ]; -}); - -TerminatedEmployeeAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" }, - { "sTitle": "","bSortable":false }, - { "sTitle": "Employee Number" }, - { "sTitle": "First Name" }, - { "sTitle": "Last Name"}, - { "sTitle": "Mobile"}, - { "sTitle": "Department"}, - { "sTitle": "Gender"}, - { "sTitle": "Supervisor"} - ]; -}); - -TerminatedEmployeeAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden","validation":""}], - [ "employee_id", {"label":"Employee Number","type":"text","validation":""}], - [ "first_name", {"label":"First Name","type":"text","validation":""}], - [ "middle_name", {"label":"Middle Name","type":"text","validation":"none"}], - [ "last_name", {"label":"Last Name","type":"text","validation":""}], - [ "nationality", {"label":"Nationality","type":"select2","remote-source":["Nationality","id","name"]}], - [ "birthday", {"label":"Date of Birth","type":"date","validation":""}], - [ "gender", {"label":"Gender","type":"select","source":[["Male","Male"],["Female","Female"]]}], - [ "marital_status", {"label":"Marital Status","type":"select","source":[["Married","Married"],["Single","Single"],["Divorced","Divorced"],["Widowed","Widowed"],["Other","Other"]]}], - [ "ssn_num", {"label":"SSN/NRIC","type":"text","validation":"none"}], - [ "nic_num", {"label":"NIC","type":"text","validation":"none"}], - [ "other_id", {"label":"Other ID","type":"text","validation":"none"}], - [ "driving_license", {"label":"Driving License No","type":"text","validation":"none"}], - /*[ "driving_license_exp_date", {"label":"License Exp Date","type":"date","validation":"none"}],*/ - [ "employment_status", {"label":"Employment Status","type":"select2","remote-source":["EmploymentStatus","id","name"]}], - [ "job_title", {"label":"Job Title","type":"select2","remote-source":["JobTitle","id","name"]}], - [ "pay_grade", {"label":"Pay Grade","type":"select2","allow-null":true,"remote-source":["PayGrade","id","name"]}], - [ "work_station_id", {"label":"Work Station Id","type":"text","validation":"none"}], - [ "address1", {"label":"Address Line 1","type":"text","validation":"none"}], - [ "address2", {"label":"Address Line 2","type":"text","validation":"none"}], - [ "city", {"label":"City","type":"text","validation":"none"}], - [ "country", {"label":"Country","type":"select2","remote-source":["Country","code","name"]}], - [ "province", {"label":"Province","type":"select2","allow-null":true,"remote-source":["Province","id","name"]}], - [ "postal_code", {"label":"Postal/Zip Code","type":"text","validation":"none"}], - [ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}], - [ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}], - [ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}], - [ "work_email", {"label":"Work Email","type":"text","validation":"emailOrEmpty"}], - [ "private_email", {"label":"Private Email","type":"text","validation":"emailOrEmpty"}], - [ "joined_date", {"label":"Joined Date","type":"date","validation":""}], - [ "confirmation_date", {"label":"Confirmation Date","type":"date","validation":"none"}], - [ "termination_date", {"label":"Termination Date","type":"date","validation":"none"}], - [ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"]}], - [ "supervisor", {"label":"Supervisor","type":"select2","allow-null":true,"remote-source":["Employee","id","first_name+last_name"]}], - [ "notes", {"label":"Notes","type":"datagroup", - "form":[ - [ "note", {"label":"Note","type":"textarea","validation":""}] - ], - "html":'
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', - "validation":"none", - "sort-function":function (a,b){ - var t1 = Date.parse(a.date).getTime(); - var t2 = Date.parse(b.date).getTime(); - - return (t1'; - return addBtn + this.gt("Skills"); -}); - -EmployeeSubSkillsAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    '+nl2br(item[3])+'

    '); - return itemHtml; -}); - - - - -/** - * @class EmployeeSubEducationAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - - -function EmployeeSubEducationAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubEducationAdapter.inherits(SubAdapterBase); - - - -EmployeeSubEducationAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "education_id", - "institute", - "date_start", - "date_end" - ]; -}); - -EmployeeSubEducationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID", "bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Qualification" }, - { "sTitle": "Institute"}, - { "sTitle": "Start Date"}, - { "sTitle": "Completed On"}, - ]; -}); - -EmployeeSubEducationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "education_id", {"label":"Qualification","type":"select2","allow-null":false,"remote-source":["Education","id","name"]}], - [ "institute", {"label":"Institute","type":"text","validation":""}], - [ "date_start", {"label":"Start Date","type":"date","validation":"none"}], - [ "date_end", {"label":"Completed On","type":"date","validation":"none"}] - ]; -}); - - -EmployeeSubEducationAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubEducationAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Education"); -}); - -EmployeeSubEducationAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - var start = ""; - try{ - stat = Date.parse(item[4]).toString('MMM d, yyyy'); - }catch(e){} - - var end = ""; - try{ - end = Date.parse(item[5]).toString('MMM d, yyyy'); - }catch(e){} - //var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    '+nl2br(item[3])+'

    '); - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    Start: '+start+'

    '+' Completed: '+end+'

    '+' Institute: '+item[3]+'

    '); - return itemHtml; -}); - - -/** - * @class EmployeeSubCertificationAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - -function EmployeeSubCertificationAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubCertificationAdapter.inherits(SubAdapterBase); - - - -EmployeeSubCertificationAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "certification_id", - "institute", - "date_start", - "date_end" - ]; -}); - - -EmployeeSubCertificationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Certification" }, - { "sTitle": "Institute"}, - { "sTitle": "Granted On"}, - { "sTitle": "Valid Thru"} - ]; -}); - -EmployeeSubCertificationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "certification_id", {"label":"Certification","type":"select2","allow-null":false,"remote-source":["Certification","id","name"]}], - [ "institute", {"label":"Institute","type":"text","validation":""}], - [ "date_start", {"label":"Granted On","type":"date","validation":"none"}], - [ "date_end", {"label":"Valid Thru","type":"date","validation":"none"}] - ]; -}); - - -EmployeeSubCertificationAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubCertificationAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Certifications"); -}); - -EmployeeSubCertificationAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - var start = ""; - try{ - start = Date.parse(item[4]).toString('MMM d, yyyy'); - }catch(e){} - - var end = ""; - try{ - end = Date.parse(item[5]).toString('MMM d, yyyy'); - }catch(e){} - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    Granted On: '+start+'

    '+' Valid Thru: '+end+'

    '+' Institute: '+item[3]+'

    '); - return itemHtml; -}); - - - - -/** - * @class EmployeeSubLanguageAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - -function EmployeeSubLanguageAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubLanguageAdapter.inherits(SubAdapterBase); - - - -EmployeeSubLanguageAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "language_id", - "reading", - "speaking", - "writing", - "understanding" - ]; -}); - -EmployeeSubLanguageAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID", "bVisible":false }, - { "sTitle": "Employee" }, - { "sTitle": "Language" }, - { "sTitle": "Reading"}, - { "sTitle": "Speaking"}, - { "sTitle": "Writing"}, - { "sTitle": "Understanding"} - ]; -}); - -EmployeeSubLanguageAdapter.method('getFormFields', function() { - var compArray = [["Elementary Proficiency","Elementary Proficiency"], - ["Limited Working Proficiency","Limited Working Proficiency"], - ["Professional Working Proficiency","Professional Working Proficiency"], - ["Full Professional Proficiency","Full Professional Proficiency"], - ["Native or Bilingual Proficiency","Native or Bilingual Proficiency"]]; - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "language_id", {"label":"Language","type":"select2","allow-null":false,"remote-source":["Language","id","name"]}], - [ "reading", {"label":"Reading","type":"select","source":compArray}], - [ "speaking", {"label":"Speaking","type":"select","source":compArray}], - [ "writing", {"label":"Writing","type":"select","source":compArray}], - [ "understanding", {"label":"Understanding","type":"select","source":compArray}] - ]; -}); - - -EmployeeSubLanguageAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubLanguageAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Languages"); -}); - -EmployeeSubLanguageAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    Reading: '+item[3]+'

    '+' Speaking: '+ item[4] +'

    '+' Writing: '+item[5]+'

    '+' Understanding: '+item[6]+'

    '); - return itemHtml; -}); - -EmployeeSubLanguageAdapter.method('isSubProfileTable', function() { - if(this.user.user_level == "Admin"){ - return false; - }else{ - return true; - } -}); - -/** - * @class EmployeeSubDependentAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - -function EmployeeSubDependentAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubDependentAdapter.inherits(SubAdapterBase); - - - -EmployeeSubDependentAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "name", - "relationship", - "dob", - "id_number" - ]; -}); - - -EmployeeSubDependentAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Name" }, - { "sTitle": "Relationship"}, - { "sTitle": "Date of Birth"}, - { "sTitle": "Id Number"} - ]; -}); - -EmployeeSubDependentAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "relationship", {"label":"Relationship","type":"select","source":[["Child","Child"],["Spouse","Spouse"],["Parent","Parent"],["Other","Other"]]}], - [ "dob", {"label":"Date of Birth","type":"date","validation":""}], - [ "id_number", {"label":"Id Number","type":"text","validation":"none"}] - ]; -}); - - -EmployeeSubDependentAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubDependentAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Dependents"); -}); - -EmployeeSubDependentAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - - - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    Relationship: '+item[3]+'

    '+' Name: '+item[2]+'

    '); - return itemHtml; -}); - - - -/** - * @class EmployeeSubEmergencyContactAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - -function EmployeeSubEmergencyContactAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubEmergencyContactAdapter.inherits(SubAdapterBase); - - - -EmployeeSubEmergencyContactAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "name", - "relationship", - "home_phone", - "work_phone", - "mobile_phone" - ]; -}); - - -EmployeeSubEmergencyContactAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Name" }, - { "sTitle": "Relationship"}, - { "sTitle": "Home Phone"}, - { "sTitle": "Work Phone"}, - { "sTitle": "Mobile Phone"} - ]; -}); - -EmployeeSubEmergencyContactAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "relationship", {"label":"Relationship","type":"text","validation":"none"}], - [ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}], - [ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}], - [ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}] - ]; -}); - - -EmployeeSubEmergencyContactAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubEmergencyContactAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Emergency Contacts"); -}); - -EmployeeSubEmergencyContactAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - - - var itemHtml = $('
    '+item[2]+itemDelete+itemEdit+'

    Relationship: '+item[3]+'

    '+' Name: '+item[2]+'

    Home Phone: '+item[4]+'

    Mobile Phone: '+item[6]+'

    '); - return itemHtml; -}); - - - - - - - -/** - * @class EmployeeSubDocumentAdapter - * @param endPoint - * @param tab - * @param filter - * @param orderBy - * @returns - */ - -function EmployeeSubDocumentAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeSubDocumentAdapter.inherits(SubAdapterBase); - - - -EmployeeSubDocumentAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "document", - "details", - "date_added", - "valid_until", - "status", - "attachment" - ]; -}); - -EmployeeSubDocumentAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Document" }, - { "sTitle": "Details" }, - { "sTitle": "Date Added"}, - { "sTitle": "Status"}, - { "sTitle": "Attachment","bVisible":false} - ]; -}); - -EmployeeSubDocumentAdapter.method('getFormFields', function() { - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"hidden"}], - [ "document", {"label":"Document","type":"select2","remote-source":["Document","id","name"]}], - [ "date_added", {"label":"Date Added","type":"date","validation":""}], - [ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "attachment", {"label":"Attachment","type":"fileupload","validation":"none"}] - ]; -}); - - -EmployeeSubDocumentAdapter.method('forceInjectValuesBeforeSave', function(params) { - params['employee'] = this.parent.currentId; - return params; -}); - -EmployeeSubDocumentAdapter.method('getSubHeaderTitle', function() { - var addBtn = ''; - return addBtn + this.gt("Documents"); -}); - -EmployeeSubDocumentAdapter.method('getSubItemHtml', function(item, itemDelete, itemEdit) { - var expire = ""; - try{ - expire = Date.parse(item[5]).toString('MMM d, yyyy'); - }catch(e){} - - var downloadButton = ''; - - var itemHtml = $('
    '+item[2]+downloadButton+itemDelete+itemEdit+'

    '+nl2br(item[3])+'

    '+' Expire On: '+expire+'

    '); - return itemHtml; -}); - - - -EmployeeSubDocumentAdapter.method('isSubProfileTable', function() { - if(this.user.user_level == "Admin"){ - return false; - }else{ - return true; - } -}); - - - -/** - * EmployeeDocumentAdapter - */ - - - -function EmployeeDocumentAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeDocumentAdapter.inherits(AdapterBase); - - - -EmployeeDocumentAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "document", - "details", - "date_added", - "status", - "attachment" - ]; -}); - -EmployeeDocumentAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Document" }, - { "sTitle": "Details" }, - { "sTitle": "Date Added"}, - { "sTitle": "Status"}, - { "sTitle": "Attachment","bVisible":false} - ]; -}); - -EmployeeDocumentAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - ["employee", { - "label": "Employee", - "type": "select2", - "sort": "none", - "allow-null": false, - "remote-source": ["Employee", "id", "first_name+last_name", "getActiveSubordinateEmployees"] - }], - [ "document", {"label":"Document","type":"select2","remote-source":["Document","id","name"]}], - [ "date_added", {"label":"Date Added","type":"date","validation":""}], - [ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "attachment", {"label":"Attachment","type":"fileupload","validation":"none"}] - ]; -}); - - -EmployeeDocumentAdapter.method('getFilters', function() { - return [ - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}] - - ]; -}); - - -EmployeeDocumentAdapter.method('getActionButtonsHtml', function(id,data) { - var html = '
    '; - html = html.replace(/_id_/g,id); - html = html.replace(/_attachment_/g,data[6]); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -EmployeeDocumentAdapter.method('isSubProfileTable', function() { - if(this.user.user_level == "Admin"){ - return false; - }else{ - return true; - } -}); - diff --git a/web/admin/fieldnames/lib.js b/web/admin/fieldnames/lib.js deleted file mode 100644 index e3b0ce2b..00000000 --- a/web/admin/fieldnames/lib.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * FieldNameAdapter - */ - -function FieldNameAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -FieldNameAdapter.inherits(AdapterBase); - - - -FieldNameAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "textOrig", - "textMapped", - "display" - ]; -}); - -FieldNameAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Original Text"}, - { "sTitle": "Mapped Text"}, - { "sTitle": "Display Status"} - ]; -}); - -FieldNameAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "type", {"label":"Type","type":"placeholder","validation":""}], - [ "name", {"label":"Name","type":"placeholder","validation":""}], - [ "textOrig", {"label":"Original Text","type":"placeholder","validation":""}], - [ "textMapped", {"label":"Mapped Text","type":"text","validation":""}], - [ "display", {"label":"Display Status","type":"select","source":[["Form","Show"],["Hidden","Hidden"]]}] - ]; -}); - - diff --git a/web/admin/jobs/lib.js b/web/admin/jobs/lib.js deleted file mode 100644 index 016ad20e..00000000 --- a/web/admin/jobs/lib.js +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * JobTitleAdapter - */ - -function JobTitleAdapter(endPoint) { - this.initAdapter(endPoint); -} - -JobTitleAdapter.inherits(AdapterBase); - - - -JobTitleAdapter.method('getDataMapping', function() { - return [ - "id", - "code", - "name" - ]; -}); - -JobTitleAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Code" }, - { "sTitle": "Name" } - ]; -}); - -JobTitleAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "code", {"label":"Job Title Code","type":"text"}], - [ "name", {"label":"Job Title","type":"text"}], - [ "description", {"label":"Description","type":"textarea"}], - [ "specification", {"label":"Specification","type":"textarea"}] - ]; -}); - -JobTitleAdapter.method('getHelpLink', function () { - return 'http://blog.icehrm.com/docs/jobdetails/'; -}); - - -/** - * PayGradeAdapter - */ - -function PayGradeAdapter(endPoint) { - this.initAdapter(endPoint); -} - -PayGradeAdapter.inherits(AdapterBase); - - - -PayGradeAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "currency", - "min_salary", - "max_salary" - ]; -}); - -PayGradeAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Currency"}, - { "sTitle": "Min Salary" }, - { "sTitle": "Max Salary"} - ]; -}); - -PayGradeAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Pay Grade Name","type":"text"}], - [ "currency", {"label":"Currency","type":"select2","remote-source":["CurrencyType","code","name"]}], - [ "min_salary", {"label":"Min Salary","type":"text","validation":"float"}], - [ "max_salary", {"label":"Max Salary","type":"text","validation":"float"}] - ]; -}); - -PayGradeAdapter.method('doCustomValidation', function(params) { - try{ - if(parseFloat(params.min_salary)>parseFloat(params.max_salary)){ - return "Min Salary should be smaller than Max Salary"; - } - }catch(e){ - - } - return null; -}); - - - -/** - * EmploymentStatusAdapter - */ - -function EmploymentStatusAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmploymentStatusAdapter.inherits(AdapterBase); - - - -EmploymentStatusAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -EmploymentStatusAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" }, - { "sTitle": "Name" }, - { "sTitle": "Description"} - ]; -}); - -EmploymentStatusAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Employment Status","type":"text"}], - [ "description", {"label":"Description","type":"textarea","validation":""}] - ]; -}); - diff --git a/web/admin/loans/lib.js b/web/admin/loans/lib.js deleted file mode 100644 index fcd72542..00000000 --- a/web/admin/loans/lib.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * CompanyLoanAdapter - */ - -function CompanyLoanAdapter(endPoint) { - this.initAdapter(endPoint); -} - -CompanyLoanAdapter.inherits(AdapterBase); - - - -CompanyLoanAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "details" - ]; -}); - -CompanyLoanAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Details"} - ]; -}); - -CompanyLoanAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); - -/* - * EmployeeCompanyLoanAdapter - */ - -function EmployeeCompanyLoanAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeCompanyLoanAdapter.inherits(AdapterBase); - - - -EmployeeCompanyLoanAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "loan", - "start_date", - "period_months", - "currency", - "amount", - "status" - ]; -}); - -EmployeeCompanyLoanAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Loan Type" }, - { "sTitle": "Loan Start Date"}, - { "sTitle": "Loan Period (Months)"}, - { "sTitle": "Currency"}, - { "sTitle": "Amount"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeCompanyLoanAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}], - [ "loan", {"label":"Loan Type","type":"select","remote-source":["CompanyLoan","id","name"]}], - [ "start_date", {"label":"Loan Start Date","type":"date","validation":""}], - [ "last_installment_date", {"label":"Last Installment Date","type":"date","validation":"none"}], - [ "period_months", {"label":"Loan Period (Months)","type":"text","validation":"number"}], - [ "currency", {"label":"Currency","type":"select2","remote-source":["CurrencyType","id","name"]}], - [ "amount", {"label":"Loan Amount","type":"text","validation":"float"}], - [ "monthly_installment", {"label":"Monthly Installment","type":"text","validation":"float"}], - [ "status", {"label":"Status","type":"select","source":[["Approved","Approved"],["Paid","Paid"],["Suspended","Suspended"]]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); - -EmployeeCompanyLoanAdapter.method('getFilters', function() { - return [ - [ "employee", {"label":"Employee","type":"select2","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}], - [ "loan", {"label":"Loan Type","type":"select","allow-null":true,"null-label":"All Loan Types","remote-source":["CompanyLoan","id","name"]}], - - ]; -}); diff --git a/web/admin/metadata/lib.js b/web/admin/metadata/lib.js deleted file mode 100644 index c7d66274..00000000 --- a/web/admin/metadata/lib.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * CountryAdapter - */ - -function CountryAdapter(endPoint) { - this.initAdapter(endPoint); -} - -CountryAdapter.inherits(AdapterBase); - - - -CountryAdapter.method('getDataMapping', function() { - return [ - "id", - "code", - "name" - ]; -}); - -CountryAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Code" }, - { "sTitle": "Name"} - ]; -}); - -CountryAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "code", {"label":"Code","type":"text","validation":""}], - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); - - -/** - * ProvinceAdapter - */ - -function ProvinceAdapter(endPoint) { - this.initAdapter(endPoint); -} - -ProvinceAdapter.inherits(AdapterBase); - - - -ProvinceAdapter.method('getDataMapping', function() { - return [ - "id", - "code", - "name", - "country" - ]; -}); - -ProvinceAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Code" }, - { "sTitle": "Name"}, - { "sTitle": "Country"}, - ]; -}); - -ProvinceAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "code", {"label":"Code","type":"text","validation":""}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "country", {"label":"Country","type":"select2","remote-source":["Country","code","name"]}] - ]; -}); - -ProvinceAdapter.method('getFilters', function() { - return [ - [ "country", {"label":"Country","type":"select2","remote-source":["Country","code","name"]}] - - ]; -}); - - -/** - * CurrencyTypeAdapter - */ - -function CurrencyTypeAdapter(endPoint) { - this.initAdapter(endPoint); -} - -CurrencyTypeAdapter.inherits(AdapterBase); - - - -CurrencyTypeAdapter.method('getDataMapping', function() { - return [ - "id", - "code", - "name" - ]; -}); - -CurrencyTypeAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Code" }, - { "sTitle": "Name"} - ]; -}); - -CurrencyTypeAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "code", {"label":"Code","type":"text","validation":""}], - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); - -/** - * NationalityAdapter - */ - -function NationalityAdapter(endPoint) { - this.initAdapter(endPoint); -} - -NationalityAdapter.inherits(IdNameAdapter); - -/** - * ImmigrationStatusAdapter - */ - -function ImmigrationStatusAdapter(endPoint) { - this.initAdapter(endPoint); -} - -ImmigrationStatusAdapter.inherits(IdNameAdapter); - - -/** - * EthnicityAdapter - */ - -function EthnicityAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EthnicityAdapter.inherits(IdNameAdapter); - - - diff --git a/web/admin/modules/lib.js b/web/admin/modules/lib.js deleted file mode 100644 index 4785e70b..00000000 --- a/web/admin/modules/lib.js +++ /dev/null @@ -1,164 +0,0 @@ -/* - This file is part of iCE Hrm. - - iCE Hrm is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - iCE Hrm is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with iCE Hrm. If not, see . - - ------------------------------------------------------------------ - - Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] - Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - - -/** - * ModuleAdapter - */ - -function ModuleAdapter(endPoint) { - this.initAdapter(endPoint); -} - -ModuleAdapter.inherits(AdapterBase); - - - -ModuleAdapter.method('getDataMapping', function() { - return [ - "id", - "label", - "menu", - "mod_group", - "mod_order", - "status", - "version", - "update_path" - ]; -}); - -ModuleAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Menu" ,"bVisible":false}, - { "sTitle": "Group"}, - { "sTitle": "Order"}, - { "sTitle": "Status"}, - { "sTitle": "Version","bVisible":false}, - { "sTitle": "Path" ,"bVisible":false} - ]; -}); - -ModuleAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "label", {"label":"Label","type":"text","validation":""}], - [ "status", {"label":"Status","type":"select","source":[["Enabled","Enabled"],["Disabled","Disabled"]]}], - [ "user_levels", {"label":"User Levels","type":"select2multi","source":[["Admin","Admin"],["Manager","Manager"],["Employee","Employee"],["Other","Other"]]}], - [ "user_roles", {"label":"User Roles","type":"select2multi","remote-source":["UserRole","id","name"]}] - ]; -}); - - -ModuleAdapter.method('getActionButtonsHtml', function(id,data) { - - - var nonEditableFields = {}; - nonEditableFields["admin_Company Structure"] = 1; - nonEditableFields["admin_Employees"] = 1; - nonEditableFields["admin_Job Details Setup"] = 1; - nonEditableFields["admin_Leaves"] = 1; - nonEditableFields["admin_Manage Modules"] = 1; - nonEditableFields["admin_Projects"] = 1; - nonEditableFields["admin_Qualifications"] = 1; - nonEditableFields["admin_Settings"] = 1; - nonEditableFields["admin_Users"] = 1; - nonEditableFields["admin_Upgrade"] = 1; - nonEditableFields["admin_Dashboard"] = 1; - - nonEditableFields["user_Basic Information"] = 1; - nonEditableFields["user_Dashboard"] = 1; - - if(nonEditableFields[data[3]+"_"+data[1]] == 1){ - return ""; - } - var html = '
    '; - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - - - -function UsageAdapter(endPoint) { - this.initAdapter(endPoint); -} - -UsageAdapter.inherits(AdapterBase); - - - -UsageAdapter.method('getDataMapping', function() { - return []; -}); - -UsageAdapter.method('getHeaders', function() { - return []; -}); - -UsageAdapter.method('getFormFields', function() { - return []; -}); - - -UsageAdapter.method('get', function(callBackData) { -}); - - -UsageAdapter.method('saveUsage', function() { - var that = this; - var object = {}; - var arr = []; - $('.module-check').each(function(){ - if($(this).is(":checked")) { - arr.push($(this).val()); - } - - }); - - if(arr.length == 0){ - alert("Please select one or more module groups"); - return; - } - - object['groups'] = arr.join(","); - - var reqJson = JSON.stringify(object); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getInitDataSuccessCallBack'; - callBackData['callBackFail'] = 'getInitDataFailCallBack'; - - this.customAction('saveUsage','admin=modules',reqJson,callBackData); -}); - - - -UsageAdapter.method('saveUsageSuccessCallBack', function(data) { - - -}); - -UsageAdapter.method('saveUsageFailCallBack', function(callBackData) { - -}); diff --git a/web/admin/overtime/lib.js b/web/admin/overtime/lib.js deleted file mode 100644 index 0ac41d45..00000000 --- a/web/admin/overtime/lib.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * OvertimeCategoryAdapter - */ - -function OvertimeCategoryAdapter(endPoint) { - this.initAdapter(endPoint); -} - -OvertimeCategoryAdapter.inherits(AdapterBase); - - - -OvertimeCategoryAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -OvertimeCategoryAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" } - ]; -}); - -OvertimeCategoryAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); - - - - -/** - * EmployeeOvertimeAdminAdapter - */ - - -function EmployeeOvertimeAdminAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.itemName = 'OvertimeRequest'; - this.itemNameLower = 'overtimerequest'; - this.modulePathName = 'overtime'; -} - -EmployeeOvertimeAdminAdapter.inherits(ApproveAdminAdapter); - - - -EmployeeOvertimeAdminAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "category", - "start_time", - "end_time", - "project", - "status" - ]; -}); - -EmployeeOvertimeAdminAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Category" }, - { "sTitle": "Start Time" }, - { "sTitle": "End Time"}, - { "sTitle": "Project"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeOvertimeAdminAdapter.method('getFormFields', function() { - return [ - ["id", {"label": "ID", "type": "hidden"}], - ["employee", { - "label": "Employee", - "type": "select2", - "sort": "none", - "allow-null": false, - "remote-source": ["Employee", "id", "first_name+last_name", "getActiveSubordinateEmployees"] - }], - ["category", {"label": "Category", "type": "select2", "allow-null":false, "remote-source": ["OvertimeCategory", "id", "name"]}], - ["start_time", {"label": "Start Time", "type": "datetime", "validation": ""}], - ["end_time", {"label": "End Time", "type": "datetime", "validation": ""}], - ["project", {"label": "Project", "type": "select2", "allow-null":true,"null=label":"none","remote-source": ["Project", "id", "name"]}], - ["notes", {"label": "Notes", "type": "textarea", "validation": "none"}] - ]; -}); - diff --git a/web/admin/payroll/lib.js b/web/admin/payroll/lib.js deleted file mode 100644 index 5a5752bd..00000000 --- a/web/admin/payroll/lib.js +++ /dev/null @@ -1,657 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * PaydayAdapter - */ - -function PaydayAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -PaydayAdapter.inherits(AdapterBase); - - - -PaydayAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -PaydayAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Select Pay Frequency"} - ]; -}); - -PaydayAdapter.method('getFormFields', function() { - return [ - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); - -/* - PaydayAdapter.method('showActionButtons' , function() { - return false; - }); - */ - -PaydayAdapter.method('getAddNewLabel', function() { - return "Run Payroll"; -}); - -PaydayAdapter.method('createTable', function(elementId) { - $("#payday_all").off(); - this.uber('createTable',elementId); - $("#payday_all").off().on('click',function(){ - if($(this).is(':checked')){ - $('.paydayCheck').prop('checked', true); - }else{ - $('.paydayCheck').prop('checked', false); - } - }) -}); - -PaydayAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - - var html = '
    _edit_
    '; - html = html.replace('_edit_',editButton); - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -PaydayAdapter.method('getActionButtonHeader', function() { - return { "sTitle": '', "sClass": "center" }; -}); - - - - -/** - * PayrollAdapter - */ - -function PayrollAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -PayrollAdapter.inherits(AdapterBase); - - - -PayrollAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "pay_period", - "department", - "date_start", - "date_end", - "status" - - ]; -}); - -PayrollAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Pay Frequency"}, - { "sTitle": "Department"}, - { "sTitle": "Date Start"}, - { "sTitle": "Date End"}, - { "sTitle": "Status"} - ]; -}); - -PayrollAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "pay_period", {"label":"Pay Frequency","type":"select","remote-source":["PayFrequency","id","name"],"sort":"none"}], - [ "deduction_group", {"label":"Calculation Group","type":"select","remote-source":["DeductionGroup","id","name"],"sort":"none"}], - [ "payslipTemplate", {"label":"Payslip Template","type":"select","remote-source":["PayslipTemplate","id","name"]}], - [ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"sort":"none"}], - [ "date_start", {"label":"Start Date","type":"date","validation":""}], - [ "date_end", {"label":"End Date","type":"date","validation":""}], - //[ "column_template", {"label":"Report Column Template","type":"select","remote-source":["PayrollColumnTemplate","id","name"]}], - [ "columns", {"label":"Payroll Columns","type":"select2multi","remote-source":["PayrollColumn","id","name"]}], - [ "status", {"label":"Status","type":"select","source":[["Draft","Draft"],["Completed","Completed"]],"sort":"none"}] - ]; -}); - -PayrollAdapter.method('postRenderForm', function(object, $tempDomObj) { - if(object != null && object != undefined && object.id != undefined && object.id != null){ - $tempDomObj.find("#pay_period").attr('disabled','disabled'); - $tempDomObj.find("#department").attr('disabled','disabled'); - //$tempDomObj.find("#date_start").attr('disabled','disabled'); - //$tempDomObj.find("#date_end").attr('disabled','disabled'); - //$tempDomObj.find("#column_template").attr('disabled','disabled'); - } - - -}); - -PayrollAdapter.method('process', function(id, status) { - modJs = modJsList['tabPayrollData']; - modJs.setCurrentPayroll(id); - $("#Payroll").hide(); - $("#PayrollData").show(); - $("#PayrollDataButtons").show(); - - if(status == 'Completed'){ - $(".completeBtnTable").hide(); - $(".saveBtnTable").hide(); - }else{ - $(".completeBtnTable").show(); - $(".saveBtnTable").show(); - } - - modJs.get([]); - - -}); - - -PayrollAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var processButton = ''; - var deleteButton = ''; - var cloneButton = ''; - - var html = '
    _edit__process__clone__delete_
    '; - - - if(this.showAddNew){ - html = html.replace('_clone_',cloneButton); - }else{ - html = html.replace('_clone_',''); - } - - if(this.showDelete){ - html = html.replace('_delete_',deleteButton); - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - /* - if(data[6] != "Completed"){ - html = html.replace('_process_',processButton); - }else{ - html = html.replace('_process_',''); - } - */ - html = html.replace('_process_',processButton); - - - html = html.replace(/_id_/g,id); - html = html.replace(/_status_/g,data[6]); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -PayrollAdapter.method('get', function(callBackData) { - $("#PayrollData").hide(); - $("#PayrollForm").hide(); - $("#PayrollDataButtons").hide(); - $("#Payroll").show(); - modJsList['tabPayrollData'].setCurrentPayroll(null); - this.uber('get',callBackData); -}); - - - -/** - * PayrollDataAdapter - */ - -function PayrollDataAdapter(endPoint) { - this.initAdapter(endPoint); - this.cellDataUpdates = {}; - this.payrollId = null; -} - -PayrollDataAdapter.inherits(TableEditAdapter); - -PayrollDataAdapter.method('validateCellValue', function(element, evt, newValue) { - modJs.addCellDataUpdate(element.data('colId'),element.data('rowId'),newValue); - return true; -}); - -PayrollDataAdapter.method('setCurrentPayroll', function(val) { - this.payrollId = val; -}); - - -PayrollDataAdapter.method('addAdditionalRequestData' , function(type, req) { - if(type == 'updateData'){ - req.payrollId = this.payrollId; - }else if(type == 'updateAllData'){ - req.payrollId = this.payrollId; - }else if(type == 'getAllData'){ - req.payrollId = this.payrollId; - } - - return req; -}); - -PayrollDataAdapter.method('modifyCSVHeader', function(header) { - header.unshift(""); - return header; -}); - -PayrollDataAdapter.method('getCSVData' , function() { - var csv = ""; - - for(var i=0;i#_delete_##_edit_#
    #_renderFunction_#
    ', - "validation":"none", - "render":function(item){ - var output = "Variable:"+item.name; - return output; - - } - - }]; - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "calculation_hook", {"label":"Predefined Calculations","type":"select2","allow-null":true,"null-label":"None","remote-source":["CalculationHook","code","name"]}], - [ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"Common","remote-source":["DeductionGroup","id","name"]}], - [ "salary_components", {"label":"Salary Components","type":"select2multi","remote-source":["SalaryComponent","id","name"]}], - [ "deductions", {"label":"Calculation Method","type":"select2multi","remote-source":["Deduction","id","name"]}], - [ "add_columns", {"label":"Columns to Add","type":"select2multi","remote-source":["PayrollColumn","id","name"]}], - [ "sub_columns", {"label":"Columns to Subtract","type":"select2multi","remote-source":["PayrollColumn","id","name"]}], - [ "colorder", {"label":"Column Order","type":"text","validation":"number"}], - [ "editable", {"label":"Editable","type":"select","source":[["Yes","Yes"],["No","No"]]}], - [ "enabled", {"label":"Enabled","type":"select","source":[["Yes","Yes"],["No","No"]]}], - [ "default_value", {"label":"Default Value","type":"text","validation":""}], - fucntionColumnList, - [ "calculation_function", {"label":"Function","type":"text","validation":"none"}] - ]; -}); - -PayrollColumnAdapter.method('getFilters', function() { - return [ - [ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"Any","remote-source":["DeductionGroup","id","name"]}] - ]; -}); - - - - -/** - * PayrollColumnTemplateAdapter - */ - -function PayrollColumnTemplateAdapter(endPoint) { - this.initAdapter(endPoint); -} - -PayrollColumnTemplateAdapter.inherits(AdapterBase); - -PayrollColumnTemplateAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -PayrollColumnTemplateAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":true}, - { "sTitle": "Name"} - ]; -}); - -PayrollColumnTemplateAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "columns", {"label":"Payroll Columns","type":"select2multi","remote-source":["PayrollColumn","id","name"]}] - ]; -}); - - -/* - * PayrollEmployeeAdapter - */ - -function PayrollEmployeeAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -PayrollEmployeeAdapter.inherits(AdapterBase); - - - -PayrollEmployeeAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "pay_frequency", - "deduction_group", - "currency" - ]; -}); - -PayrollEmployeeAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Pay Frequency"}, - { "sTitle": "Calculation Group"}, - { "sTitle": "Currency"}, - ]; -}); - -PayrollEmployeeAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}], - [ "pay_frequency", {"label":"Pay Frequency","type":"select2","remote-source":["PayFrequency","id","name"]}], - [ "currency", {"label":"Currency","type":"select2","remote-source":["CurrencyType","id","code"]}], - [ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"None","remote-source":["DeductionGroup","id","name"]}], - [ "deduction_exemptions", {"label":"Calculation Exemptions","type":"select2multi","remote-source":["Deduction","id","name"],"validation":"none"}], - [ "deduction_allowed", {"label":"Calculations Assigned","type":"select2multi","remote-source":["Deduction","id","name"],"validation":"none"}] - ]; -}); - -PayrollEmployeeAdapter.method('getFilters', function() { - return [ - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}] - ]; -}); - - -/** - * DeductionAdapter - */ - -function DeductionAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -DeductionAdapter.inherits(AdapterBase); - - - -DeductionAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "deduction_group" - ]; -}); - -DeductionAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Calculation Group"} - ]; -}); - -DeductionAdapter.method('getFormFields', function() { - - var rangeAmounts = [ "rangeAmounts", {"label":"Calculation Process","type":"datagroup", - "form":[ - [ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],["gt","Greater than"],["gte","Greater than or Equal"]]}], - [ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"float"}], - [ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["lt","Less than"],["lte","Less than or Equal"]]}], - [ "upperLimit", {"label":"Upper Limit","type":"text","validation":"float"}], - [ "amount", {"label":"Value","type":"text","validation":""}] - ], - "html":'
    #_delete_##_edit_#
    #_renderFunction_#
    ', - "validation":"none", - "custom-validate-function":function (data){ - var res = {}; - res['valid'] = true; - if(data.lowerCondition == 'No Lower Limit'){ - data.lowerLimit = 0; - } - if(data.upperCondition == 'No Upper Limit'){ - data.upperLimit = 0; - } - res['params'] = data; - return res; - }, - "render":function(item){ - var output = ""; - var getSymbol = function(text){ - var map = {}; - map['gt'] = '>'; - map['gte'] = '>='; - map['lt'] = '<'; - map['lte'] = '<='; - - return map[text]; - } - if(item.lowerCondition != "No Lower Limit"){ - output += item.lowerLimit + " " + getSymbol(item.lowerCondition) + " "; - } - - if(item.upperCondition != "No Upper Limit"){ - output += " and "; - output += getSymbol(item.upperCondition) + " " + item.upperLimit + " "; - } - if(output == ""){ - return "Deduction is "+item.amount + " for all ranges"; - }else{ - return "If salary component "+output+ " deduction is "+item.amount; - } - - - return output; - - } - - }]; - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "componentType", {"label":"Salary Component Type","type":"select2multi","allow-null":true,"remote-source":["SalaryComponentType","id","name"]}], - [ "component", {"label":"Salary Component","type":"select2multi","allow-null":true,"remote-source":["SalaryComponent","id","name"]}], - [ "payrollColumn", {"label":"Payroll Report Column","type":"select2","allow-null":true,"remote-source":["PayrollColumn","id","name"]}], - rangeAmounts, - [ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"None","remote-source":["DeductionGroup","id","name"]}] - - ]; -}); - - - - - -/* - * DeductionGroupAdapter - */ - -function DeductionGroupAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -DeductionGroupAdapter.inherits(AdapterBase); - - - -DeductionGroupAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -DeductionGroupAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Details" } - ]; -}); - -DeductionGroupAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "description", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); - - -/* - * PayslipTemplateAdapter - */ - -function PayslipTemplateAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -PayslipTemplateAdapter.inherits(AdapterBase); - - - -PayslipTemplateAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -PayslipTemplateAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" } - ]; -}); - -PayslipTemplateAdapter.method('getFormFields', function() { - - var payslipFields = [ "data", {"label":"Payslip Fields","type":"datagroup", - "form":[ - [ "type", {"label":"Type","type":"select","sort":"none","source":[["Payroll Column","Payroll Column"],["Text","Text"],["Company Name","Company Name"],["Company Logo","Company Logo"], ["Separators","Separators"]]}], - [ "payrollColumn", {"label":"Payroll Column","type":"select2","sort":"none","allow-null":true,"null-label":"None","remote-source":["PayrollColumn","id","name"]}], - - [ "label", {"label":"Label","type":"text","validation":"none"}], - [ "text", {"label":"Text","type":"textarea","validation":"none"}], - [ "status", {"label":"Status","type":"select","sort":"none","source":[["Show","Show"],["Hide","Hide"]]}] - ], - - //"html":'
    #_delete_##_edit_#
    Type#_type_#
    Label#_label_#
    Text#_text_#
    Font Size#_fontSize_#
    Font Style#_fontStyle_#
    Font Color#_fontColor_#
    Status#_status_#
    ', - "html":'
    #_delete_##_edit_#
    #_type_# #_label_#
    #_text_#
    ', - "validation":"none", - "custom-validate-function":function (data){ - var res = {}; - res['valid'] = true; - if(data.type == 'Payroll Column'){ - if(data.payrollColumn == "NULL"){ - res['valid'] = false; - res['message'] = "Please select payroll column"; - }else{ - data.payrollColumn == "NULL"; - } - }else if(data.type == 'Text'){ - if(data.text == ""){ - res['valid'] = false; - res['message'] = "Text can not be empty"; - } - } - - res['params'] = data; - return res; - } - }]; - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - payslipFields - ]; -}); - - - - - - diff --git a/web/admin/permissions/lib.js b/web/admin/permissions/lib.js deleted file mode 100644 index 52b8c048..00000000 --- a/web/admin/permissions/lib.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * PermissionAdapter - */ - -function PermissionAdapter(endPoint) { - this.initAdapter(endPoint); -} - -PermissionAdapter.inherits(AdapterBase); - - - -PermissionAdapter.method('getDataMapping', function() { - return [ - "id", - "user_level", - "module_id", - "permission", - "value" - ]; -}); - -PermissionAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "User Level" }, - { "sTitle": "Module"}, - { "sTitle": "Permission"}, - { "sTitle": "Value"} - ]; -}); - -PermissionAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "user_level", {"label":"User Level","type":"placeholder","validation":"none"}], - [ "module_id", {"label":"Module","type":"placeholder","remote-source":["Module","id","menu+name"]}], - [ "permission", {"label":"Permission","type":"placeholder","validation":"none"}], - [ "value", {"label":"Value","type":"text","validation":"none"}] - ]; -}); - -PermissionAdapter.method('getFilters', function() { - return [ - [ "module_id", {"label":"Module","type":"select2","allow-null":true,"null-label":"All Modules","remote-source":["Module","id","menu+name"]}] - ]; -}); - -PermissionAdapter.method('getActionButtonsHtml', function(id,data) { - var html = '
    '; - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - - -PermissionAdapter.method('getMetaFieldForRendering', function(fieldName) { - if(fieldName == "value"){ - return "meta"; - } - return ""; -}); - - -PermissionAdapter.method('fillForm', function(object) { - this.uber('fillForm',object); - $("#helptext").html(object.description); -}); diff --git a/web/admin/projects/lib.js b/web/admin/projects/lib.js deleted file mode 100644 index 75fd5a0d..00000000 --- a/web/admin/projects/lib.js +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - -/** - * ClientAdapter - */ - -function ClientAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -ClientAdapter.inherits(AdapterBase); - - - -ClientAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "details", - "address", - "contact_number" - ]; -}); - -ClientAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Details"}, - { "sTitle": "Address"}, - { "sTitle": "Contact Number"} - ]; -}); - -ClientAdapter.method('getFormFields', function() { - if(this.showSave){ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "address", {"label":"Address","type":"textarea","validation":"none"}], - [ "contact_number", {"label":"Contact Number","type":"text","validation":"none"}], - [ "contact_email", {"label":"Contact Email","type":"text","validation":"none"}], - [ "company_url", {"label":"Company Url","type":"text","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"]]}], - [ "first_contact_date", {"label":"First Contact Date","type":"date","validation":"none"}] - ]; - }else{ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"placeholder"}], - [ "details", {"label":"Details","type":"placeholder","validation":"none"}], - [ "address", {"label":"Address","type":"placeholder","validation":"none"}], - [ "contact_number", {"label":"Contact Number","type":"placeholder","validation":"none"}], - [ "contact_email", {"label":"Contact Email","type":"placeholder","validation":"none"}], - [ "company_url", {"label":"Company Url","type":"placeholder","validation":"none"}], - [ "status", {"label":"Status","type":"placeholder","source":[["Active","Active"],["Inactive","Inactive"]]}], - [ "first_contact_date", {"label":"First Contact Date","type":"placeholder","validation":"none"}] - ]; - } -}); - -ClientAdapter.method('getHelpLink', function () { - return 'http://blog.icehrm.com/docs/projects/'; -}); - -/** - * ProjectAdapter - */ - -function ProjectAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -ProjectAdapter.inherits(AdapterBase); - - - -ProjectAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "client" - ]; -}); - -ProjectAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Client"}, - ]; -}); - -ProjectAdapter.method('getFormFields', function() { - - if(this.showSave){ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "client", {"label":"Client","type":"select2","allow-null":true,"remote-source":["Client","id","name"]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["On Hold","On Hold"],["Completed","Completed"],["Dropped","Dropped"]]}] - ]; - }else{ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"placeholder"}], - [ "client", {"label":"Client","type":"placeholder","allow-null":true,"remote-source":["Client","id","name"]}], - [ "details", {"label":"Details","type":"placeholder","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["On Hold","On Hold"],["Completed","Completed"],["Dropped","Dropped"]]}] - ]; - } - -}); - -ProjectAdapter.method('getHelpLink', function () { - return 'http://blog.icehrm.com/docs/projects/'; -}); - - -/* - * EmployeeProjectAdapter - */ - - -function EmployeeProjectAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeProjectAdapter.inherits(AdapterBase); - - - -EmployeeProjectAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "project" - ]; -}); - -EmployeeProjectAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee" }, - { "sTitle": "Project" } - ]; -}); - -EmployeeProjectAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}], - [ "project", {"label":"Project","type":"select2","remote-source":["Project","id","name"]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); - -EmployeeProjectAdapter.method('getFilters', function() { - return [ - [ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}] - - ]; -}); - -EmployeeProjectAdapter.method('getHelpLink', function () { - return 'http://blog.icehrm.com/docs/projects/'; -}); - diff --git a/web/admin/qualifications/lib.js b/web/admin/qualifications/lib.js deleted file mode 100644 index 9f79ff1a..00000000 --- a/web/admin/qualifications/lib.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * SkillAdapter - */ - -function SkillAdapter(endPoint) { - this.initAdapter(endPoint); -} - -SkillAdapter.inherits(AdapterBase); - - - -SkillAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -SkillAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Description"} - ]; -}); - -SkillAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "description", {"label":"Description","type":"textarea","validation":""}] - ]; -}); - -SkillAdapter.method('getHelpLink', function () { - return 'http://blog.icehrm.com/docs/qualifications/'; -}); - - - -/** - * EducationAdapter - */ - -function EducationAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EducationAdapter.inherits(AdapterBase); - - - -EducationAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -EducationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Description"} - ]; -}); - -EducationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "description", {"label":"Description","type":"textarea","validation":""}] - ]; -}); - - - - - -/** - * CertificationAdapter - */ - -function CertificationAdapter(endPoint) { - this.initAdapter(endPoint); -} - -CertificationAdapter.inherits(AdapterBase); - - - -CertificationAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -CertificationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Description"} - ]; -}); - -CertificationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "description", {"label":"Description","type":"textarea","validation":""}] - ]; -}); - - - -/** - * LanguageAdapter - */ - -function LanguageAdapter(endPoint) { - this.initAdapter(endPoint); -} - -LanguageAdapter.inherits(AdapterBase); - - - -LanguageAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "description" - ]; -}); - -LanguageAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Description"} - ]; -}); - -LanguageAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text"}], - [ "description", {"label":"Description","type":"textarea","validation":""}] - ]; -}); - diff --git a/web/admin/reports/lib.js b/web/admin/reports/lib.js deleted file mode 100644 index ccfdceac..00000000 --- a/web/admin/reports/lib.js +++ /dev/null @@ -1,396 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * ReportAdapter - */ - - -function ReportAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this._construct(); -} - -ReportAdapter.inherits(AdapterBase); - -ReportAdapter.method('_construct', function() { - this._formFileds = [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"label","validation":""}], - [ "parameters", {"label":"Parameters","type":"fieldset","validation":"none"}] - ]; - this.remoteFieldsExists = false; -}); - -ReportAdapter.method('_initLocalFormFields', function() { - this._formFileds = [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"label","validation":""}], - [ "parameters", {"label":"Parameters","type":"fieldset","validation":"none"}] - ]; -}); - -ReportAdapter.method('setRemoteFieldExists', function(val) { - this.remoteFieldsExists = val; -}); - -ReportAdapter.method('getDataMapping', function() { - return [ - "id", - "icon", - "name", - "details", - "parameters" - ]; -}); - -ReportAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "","bSortable":false,"sWidth":"22px"}, - { "sTitle": "Name","sWidth":"30%"}, - { "sTitle": "Details"}, - { "sTitle": "Parameters","bVisible":false}, - ]; -}); - - -ReportAdapter.method('getFormFields', function() { - return this._formFileds; -}); - -ReportAdapter.method('processFormFieldsWithObject', function(object) { - var that = this; - this._initLocalFormFields(); - var len = this._formFileds.length; - var fieldIDsToDelete = []; - var fieldsToDelete = []; - this.remoteFieldsExists = false; - for(var i=0;i'); - $tempDomObj.attr('id',randomFormId); - - } - - $tempDomObj.html(formHtml); - - - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false - }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' - }); - - $tempDomObj.find('.colorpick').colorpicker(); - - //$tempDomObj.find('.select2Field').select2(); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - - }); - - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - - }); - - - $tempDomObj.find('.signatureField').each(function() { - //$(this).data('signaturePad',new SignaturePad($(this))); - signatureIds.push($(this).attr('id')); - }); - - for(var i=0;i').parent().html(); - //this.showMessage("Edit",tHtml,null,null,true); - this.showMessage("Edit","",null,null,true); - - $("#plainMessageModel .modal-body").html(""); - $("#plainMessageModel .modal-body").append($tempDomObj); - - - for(var i=0;iDownload Report '; - }else{ - link = 'Download Report '; - } - link = link.replace(/_BASE_/g,this.baseUrl); - - if(this.currentReport.output == "PDF" || this.currentReport.output == "JSON"){ - - this.showMessage("Download Report",link); - - }else{ - if(serverData[1].length == 0){ - this.showMessage("Empty Report","There were no data for selected filters"); - return; - } - - - var tableHtml = link+'

    '; - - //Delete existing temp report table - $("#tempReportTable").remove(); - - //this.showMessage("Report",tableHtml); - - $("#"+this.table).html(tableHtml); - $("#"+this.table).show(); - $("#"+this.table+"Form").hide(); - - //Prepare headers - var headers = []; - for(title in serverData[1]){ - headers.push({ "sTitle": serverData[1][title]}); - } - - var data = serverData[2]; - - - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "aaData": data, - "aoColumns": headers, - "bSort": false, - "iDisplayLength": 15, - "iDisplayStart": 0 - }; - - $("#tempReportTable").dataTable( dataTableParams ); - - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - $('.tableActionButton').tooltip(); - } - - - -}); - - -ReportAdapter.method('fillForm', function(object) { - var fields = this.getFormFields(); - for(var i=0;iHH:mm'); + } if (id === 3) { + if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell == null) { + return ''; + } + return Date.parse(cell).toString('MMM d HH:mm'); + } if (id === 4) { + if (cell !== undefined && cell !== null) { + if (cell.length > 10) { + return `${cell.substring(0, 10)}..`; + } + } + return cell; + } + } + + + save() { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const params = validator.getFormParameters(); + + const msg = this.doCustomValidation(params); + if (msg == null) { + const id = $(`#${this.getTableName()}_submit #id`).val(); + if (id != null && id !== undefined && id !== '') { + params.id = id; + } + + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'saveSuccessCallback'; + callBackData.callBackFail = 'saveFailCallback'; + + this.customAction('savePunch', 'admin=attendance', reqJson, callBackData); + } else { + const label = $(`#${this.getTableName()}Form .label`); + label.html(msg); + label.show(); + } + } + } + + + saveSuccessCallback(callBackData) { + this.get(callBackData); + } + + + saveFailCallback(callBackData) { + this.showMessage('Error saving attendance entry', callBackData); + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } + + showPunchImages(id) { + const reqJson = JSON.stringify({ id }); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getImagesSuccessCallback'; + callBackData.callBackFail = 'getImagesFailCallback'; + this.customAction('getImages', 'admin=attendance', reqJson, callBackData); + } + + getImagesSuccessCallback(callBackData) { + $('#attendancePhotoModel').modal('show'); + $('#attendnaceCanvasEmp').html(callBackData.employee_Name); + if (callBackData.in_time) { + $('#attendnaceCanvasPunchInTime').html(Date.parse(callBackData.in_time).toString('yyyy MMM d HH:mm')); + } + + if (callBackData.image_in) { + const myCanvas = document.getElementById('attendnaceCanvasIn'); + const ctx = myCanvas.getContext('2d'); + const img = new Image(); + img.onload = function () { + ctx.drawImage(img, 0, 0); // Or at whatever offset you like + }; + img.src = callBackData.image_in; + } + + if (callBackData.out_time) { + $('#attendnaceCanvasPunchOutTime').html(Date.parse(callBackData.out_time).toString('yyyy MMM d HH:mm')); + } + + if (callBackData.image_out) { + const myCanvas = document.getElementById('attendnaceCanvasOut'); + const ctx = myCanvas.getContext('2d'); + const img = new Image(); + img.onload = function () { + ctx.drawImage(img, 0, 0); // Or at whatever offset you like + }; + img.src = callBackData.image_out; + } + } + + + getImagesFailCallback(callBackData) { + this.showMessage('Error', callBackData); + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + const deleteButton = ''; + const photoButton = ''; + + let html; + if (this.photoAttendance === 1) { + html = '
    _edit__delete__photo_
    '; + } else { + html = '
    _edit__delete_
    '; + } + + html = html.replace('_photo_', photoButton); + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +/* + Attendance Status + */ + +class AttendanceStatusAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Clocked In Status' }, + ]; + } + + getFormFields() { + return [ + + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_BASE_/g, this.baseUrl); + if (data[2] == 'Not Clocked In') { + html = html.replace(/_COLOR_/g, 'gray'); + } else if (data[2] == 'Clocked Out') { + html = html.replace(/_COLOR_/g, 'yellow'); + } else if (data[2] == 'Clocked In') { + html = html.replace(/_COLOR_/g, 'green'); + } + return html; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +module.exports = { AttendanceAdapter, AttendanceStatusAdapter }; diff --git a/web/admin/src/company_structure/index.js b/web/admin/src/company_structure/index.js new file mode 100644 index 00000000..ad9610d7 --- /dev/null +++ b/web/admin/src/company_structure/index.js @@ -0,0 +1,4 @@ +import { CompanyStructureAdapter, CompanyGraphAdapter } from './lib'; + +window.CompanyStructureAdapter = CompanyStructureAdapter; +window.CompanyGraphAdapter = CompanyGraphAdapter; diff --git a/web/admin/src/company_structure/lib.js b/web/admin/src/company_structure/lib.js new file mode 100644 index 00000000..598d57e6 --- /dev/null +++ b/web/admin/src/company_structure/lib.js @@ -0,0 +1,311 @@ +/* eslint-disable prefer-destructuring */ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global d3, nv */ + +import AdapterBase from '../../../api/AdapterBase'; + +class CompanyStructureAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'title', + 'address', + 'type', + 'country', + 'timezone', + 'parent', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Address', bSortable: false }, + { sTitle: 'Type' }, + { sTitle: 'Country', sClass: 'center' }, + { sTitle: 'Time Zone' }, + { sTitle: 'Parent Structure' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['title', { label: 'Name', type: 'text', validation: '' }], + ['description', { label: 'Details', type: 'textarea', validation: '' }], + ['address', { label: 'Address', type: 'textarea', validation: 'none' }], + ['type', { label: 'Type', type: 'select', source: [['Company', 'Company'], ['Head Office', 'Head Office'], ['Regional Office', 'Regional Office'], ['Department', 'Department'], ['Unit', 'Unit'], ['Sub Unit', 'Sub Unit'], ['Other', 'Other']] }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['timezone', { + label: 'Time Zone', type: 'select2', 'allow-null': false, 'remote-source': ['Timezone', 'name', 'details'], + }], + ['parent', { + label: 'Parent Structure', type: 'select', 'allow-null': true, 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['heads', { + label: 'Heads', type: 'select2multi', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object === undefined + || object === null + || object.id === null + || object.id === undefined || object.id === '' + ) { + $tempDomObj.find('#field_heads').hide(); + } + } +} + + +/* + * Company Graph + */ + + +class CompanyGraphAdapter extends CompanyStructureAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.nodeIdCounter = 0; + } + + convertToTree(data) { + const ice = {}; + ice.id = -1; + ice.title = ''; + ice.name = ''; + ice.children = []; + + let parent = null; + + const added = {}; + + + for (let i = 0; i < data.length; i++) { + data[i].name = data[i].title; + + if (data[i].parent != null && data[i].parent !== undefined) { + parent = this.findParent(data, data[i].parent); + if (parent != null) { + if (parent.children === undefined || parent.children == null) { + parent.children = []; + } + parent.children.push(data[i]); + } + } + } + + for (let i = 0; i < data.length; i++) { + if (data[i].parent == null || data[i].parent === undefined) { + ice.children.push(data[i]); + } + } + + return ice; + } + + + findParent(data, parent) { + for (let i = 0; i < data.length; i++) { + if (data[i].title === parent || data[i].title === parent) { + return data[i]; + } + } + return null; + } + + + createTable(elementId) { + $('#tabPageCompanyGraph').html(''); + const that = this; + const sourceData = this.sourceData; + + // this.fixCyclicParent(sourceData); + const treeData = this.convertToTree(sourceData); + const m = [20, 120, 20, 120]; + const w = 5000 - m[1] - m[3]; + const h = 1000 - m[0] - m[2]; + + const tree = d3.layout.tree() + .size([h, w]); + + this.diagonal = d3.svg.diagonal() + .projection(d => [d.y, d.x]); + + this.vis = d3.select('#tabPageCompanyGraph').append('svg:svg') + .attr('width', w + m[1] + m[3]) + .attr('height', h + m[0] + m[2]) + .append('svg:g') + .attr('transform', `translate(${m[3]},${m[0]})`); + + const root = treeData; + root.x0 = h / 2; + root.y0 = 0; + + function toggleAll(d) { + if (d.children) { + console.log(d.name); + d.children.forEach(toggleAll); + that.toggle(d); + } + } + this.update(root, tree, root); + } + + update(source, tree, root) { + const that = this; + const duration = d3.event && d3.event.altKey ? 5000 : 500; + + // Compute the new tree layout. + const nodes = tree.nodes(root).reverse(); + + // Normalize for fixed-depth. + nodes.forEach((d) => { d.y = d.depth * 180; }); + + // Update the nodes� + const node = that.vis.selectAll('g.node') + .data(nodes, d => d.id || (d.id = ++that.nodeIdCounter)); + + // Enter any new nodes at the parent's previous position. + const nodeEnter = node.enter().append('svg:g') + .attr('class', 'node') + .attr('transform', d => `translate(${source.y0},${source.x0})`) + .on('click', (d) => { that.toggle(d); that.update(d, tree, root); }); + + nodeEnter.append('svg:circle') + .attr('r', 1e-6) + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeEnter.append('svg:text') + .attr('x', d => (d.children || d._children ? -10 : 10)) + .attr('dy', '.35em') + .attr('text-anchor', d => (d.children || d._children ? 'end' : 'start')) + .text(d => d.name) + .style('fill-opacity', 1e-6); + + // Transition nodes to their new position. + const nodeUpdate = node.transition() + .duration(duration) + .attr('transform', d => `translate(${d.y},${d.x})`); + + nodeUpdate.select('circle') + .attr('r', 4.5) + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeUpdate.select('text') + .style('fill-opacity', 1); + + // Transition exiting nodes to the parent's new position. + const nodeExit = node.exit().transition() + .duration(duration) + .attr('transform', d => `translate(${source.y},${source.x})`) + .remove(); + + nodeExit.select('circle') + .attr('r', 1e-6); + + nodeExit.select('text') + .style('fill-opacity', 1e-6); + + // Update the links� + const link = that.vis.selectAll('path.link') + .data(tree.links(nodes), d => d.target.id); + + // Enter any new links at the parent's previous position. + link.enter().insert('svg:path', 'g') + .attr('class', 'link') + .attr('d', (d) => { + const o = { x: source.x0, y: source.y0 }; + return that.diagonal({ source: o, target: o }); + }) + .transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition links to their new position. + link.transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition exiting nodes to the parent's new position. + link.exit().transition() + .duration(duration) + .attr('d', (d) => { + const o = { x: source.x, y: source.y }; + return that.diagonal({ source: o, target: o }); + }) + .remove(); + + // Stash the old positions for transition. + nodes.forEach((d) => { + d.x0 = d.x; + d.y0 = d.y; + }); + } + + // Toggle children. + toggle(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + } + + + getSourceDataById(id) { + for (let i = 0; i < this.sourceData.length; i++) { + if (this.sourceData[i].id == id) { + return this.sourceData[i]; + } + } + + return null; + } + + fixCyclicParent(sourceData) { + let errorMsg = ''; + for (let i = 0; i < sourceData.length; i++) { + const obj = sourceData[i]; + + + let curObj = obj; + const parentIdArr = {}; + parentIdArr[curObj.id] = 1; + + while (curObj.parent != null && curObj.parent != undefined) { + const parent = this.getSourceDataById(curObj.parent); + if (parent == null) { + break; + } else if (parentIdArr[parent.id] == 1) { + errorMsg = `${obj.title}'s parent structure set to ${parent.title}
    `; + obj.parent = null; + break; + } + parentIdArr[parent.id] = 1; + curObj = parent; + } + } + + if (errorMsg !== '') { + this.showMessage('Company Structure is having a cyclic dependency', `We found a cyclic dependency due to following reasons:
    ${errorMsg}`); + return false; + } + + return true; + } + + getHelpLink() { + return 'https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html'; + } +} + +module.exports = { CompanyStructureAdapter, CompanyGraphAdapter }; diff --git a/web/admin/src/dashboard/index.js b/web/admin/src/dashboard/index.js new file mode 100644 index 00000000..636c6706 --- /dev/null +++ b/web/admin/src/dashboard/index.js @@ -0,0 +1,3 @@ +import { DashboardAdapter } from './lib'; + +window.DashboardAdapter = DashboardAdapter; diff --git a/web/admin/src/dashboard/lib.js b/web/admin/src/dashboard/lib.js new file mode 100644 index 00000000..ba91bab3 --- /dev/null +++ b/web/admin/src/dashboard/lib.js @@ -0,0 +1,56 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +class DashboardAdapter extends AdapterBase { + getDataMapping() { + return []; + } + + getHeaders() { + return []; + } + + getFormFields() { + return []; + } + + + get(callBackData) { + } + + + getInitData() { + const that = this; + const object = {}; + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; + callBackData.callBackFail = 'getInitDataFailCallBack'; + + this.customAction('getInitData', 'admin=dashboard', reqJson, callBackData); + } + + + getInitDataSuccessCallBack(data) { + $('#numberOfEmployees').html(`${data.numberOfEmployees} Employees`); + $('#numberOfCompanyStuctures').html(`${data.numberOfCompanyStuctures} Departments`); + $('#numberOfUsers').html(`${data.numberOfUsers} Users`); + $('#numberOfProjects').html(`${data.numberOfProjects} Active Projects`); + $('#numberOfAttendanceLastWeek').html(`${data.numberOfAttendanceLastWeek} Entries Last Week`); + $('#numberOfLeaves').html(`${data.numberOfLeaves} Upcoming`); + $('#numberOfTimeEntries').html(data.numberOfTimeEntries); + $('#numberOfCandidates').html(`${data.numberOfCandidates} Candidates`); + $('#numberOfJobs').html(`${data.numberOfJobs} Active`); + $('#numberOfCourses').html(`${data.numberOfCourses} Courses`); + } + + getInitDataFailCallBack(callBackData) { + + } +} + +module.exports = { DashboardAdapter }; diff --git a/web/admin/src/data/index.js b/web/admin/src/data/index.js new file mode 100644 index 00000000..1c23c3c7 --- /dev/null +++ b/web/admin/src/data/index.js @@ -0,0 +1,4 @@ +import { DataImportAdapter, DataImportFileAdapter } from './lib'; + +window.DataImportAdapter = DataImportAdapter; +window.DataImportFileAdapter = DataImportFileAdapter; diff --git a/web/admin/src/data/lib.js b/web/admin/src/data/lib.js new file mode 100644 index 00000000..1db52293 --- /dev/null +++ b/web/admin/src/data/lib.js @@ -0,0 +1,185 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global dependOnField */ +import AdapterBase from '../../../api/AdapterBase'; + +/** + * DataImportAdapter + */ + +class DataImportAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'dataType', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Data Type' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['dataType', { label: 'Data Type', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['columns', { + label: 'Columns', + type: 'datagroup', + form: [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ['title', { label: 'Filed Title', type: 'text', validation: 'none' }], + ['type', { + label: 'Type', type: 'select', sort: 'none', source: [['Normal', 'Normal'], ['Reference', 'Reference'], ['Attached', 'Attached']], + }], + ['dependOn', { + label: 'Depends On', + type: 'select', + 'allow-null': true, + 'null-label': 'N/A', + source: [['EmergencyContact', 'Emergency Contacts'], ['Ethnicity', 'Ethnicity'], ['Nationality', 'Nationality'], ['JobTitle', 'JobTitle'], ['PayFrequency', 'PayFrequency'], ['PayGrade', 'PayGrade'], ['EmploymentStatus', 'EmploymentStatus'], ['CompanyStructure', 'CompanyStructure'], ['Employee', 'Employee']], + }], + ['dependOnField', { label: 'Depends On Field', type: 'text', validation: 'none' }], + ['isKeyField', { + label: 'Is Key Field', type: 'select', validation: '', source: [['No', 'No'], ['Yes', 'Yes']], + }], + ['idField', { + label: 'Is ID Field', type: 'select', validation: '', source: [['No', 'No'], ['Yes', 'Yes']], + }], + ], + html: '
    #_name_# #_delete_##_edit_#
    Header Title: #_title_#
    Type: #_type_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.params = data; + res.valid = true; + if (data.type === 'Reference') { + if (data.dependOn === 'NULL') { + res.message = 'If the type is Reference this field should referring another table'; + res.valid = false; + } else if (dependOnField === null || dependOnField === undefined) { + res.message = "If the type is Reference then 'Depends On Field' can not be empty"; + res.valid = false; + } + } + + return res; + }, + + }], + ]; + } +} + + +/** + * DataImportFileAdapter + */ + +class DataImportFileAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'data_import_definition', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Data Import Definition' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['data_import_definition', { label: 'Data Import Definitions', type: 'select', 'remote-source': ['DataImport', 'id', 'name'] }], + ['file', { + label: 'File to Import', type: 'fileupload', validation: '', filetypes: 'csv,txt', + }], + ['details', { label: 'Last Export Result', type: 'textarea', validation: 'none' }], + ]; + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + const processButton = ''; + const deleteButton = ''; + const cloneButton = ''; + + let html = '
    _edit__process__clone__delete_
    '; + + + if (this.showAddNew) { + html = html.replace('_clone_', cloneButton); + } else { + html = html.replace('_clone_', ''); + } + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + if (data[3] === 'Not Processed') { + html = html.replace('_process_', processButton); + } else { + html = html.replace('_process_', ''); + } + + + html = html.replace(/_id_/g, id); + html = html.replace(/_status_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + process(id) { + const that = this; + const object = { id }; + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'processSuccessCallBack'; + callBackData.callBackFail = 'processFailCallBack'; + + this.customAction('processDataFile', 'admin=data', reqJson, callBackData); + } + + processSuccessCallBack(callBackData) { + this.showMessage('Success', 'File imported successfully.'); + } + + + processFailCallBack(callBackData) { + this.showMessage('Error', `File import unsuccessful. Result:${callBackData}`); + } +} + +module.exports = { DataImportAdapter, DataImportFileAdapter }; diff --git a/web/admin/src/employees/index.js b/web/admin/src/employees/index.js new file mode 100644 index 00000000..bf8bb349 --- /dev/null +++ b/web/admin/src/employees/index.js @@ -0,0 +1,39 @@ +import { + EmployeeAdapter, + TerminatedEmployeeAdapter, + ArchivedEmployeeAdapter, + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, + EmployeeDependentAdapter, + EmergencyContactAdapter, + EmployeeImmigrationAdapter, + EmployeeSubSkillsAdapter, + EmployeeSubEducationAdapter, + EmployeeSubCertificationAdapter, + EmployeeSubLanguageAdapter, + EmployeeSubDependentAdapter, + EmployeeSubEmergencyContactAdapter, + EmployeeSubDocumentAdapter, + EmployeeDocumentAdapter, +} from './lib'; + +window.EmployeeAdapter = EmployeeAdapter; +window.TerminatedEmployeeAdapter = TerminatedEmployeeAdapter; +window.ArchivedEmployeeAdapter = ArchivedEmployeeAdapter; +window.EmployeeSkillAdapter = EmployeeSkillAdapter; +window.EmployeeEducationAdapter = EmployeeEducationAdapter; +window.EmployeeCertificationAdapter = EmployeeCertificationAdapter; +window.EmployeeLanguageAdapter = EmployeeLanguageAdapter; +window.EmployeeDependentAdapter = EmployeeDependentAdapter; +window.EmergencyContactAdapter = EmergencyContactAdapter; +window.EmployeeImmigrationAdapter = EmployeeImmigrationAdapter; +window.EmployeeSubSkillsAdapter = EmployeeSubSkillsAdapter; +window.EmployeeSubEducationAdapter = EmployeeSubEducationAdapter; +window.EmployeeSubCertificationAdapter = EmployeeSubCertificationAdapter; +window.EmployeeSubLanguageAdapter = EmployeeSubLanguageAdapter; +window.EmployeeSubDependentAdapter = EmployeeSubDependentAdapter; +window.EmployeeSubEmergencyContactAdapter = EmployeeSubEmergencyContactAdapter; +window.EmployeeSubDocumentAdapter = EmployeeSubDocumentAdapter; +window.EmployeeDocumentAdapter = EmployeeDocumentAdapter; diff --git a/web/admin/src/employees/lib.js b/web/admin/src/employees/lib.js new file mode 100644 index 00000000..9d0a5486 --- /dev/null +++ b/web/admin/src/employees/lib.js @@ -0,0 +1,1877 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/* eslint-disable prefer-destructuring,no-restricted-globals */ + +/* global Base64, modJs, nl2br, ga */ +/** + * Author: Thilina Hasantha + */ + +import AdapterBase from '../../../api/AdapterBase'; +import SubAdapterBase from '../../../api/SubAdapterBase'; + +/** + * @class EmployeeSubSkillsAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + + +class EmployeeSubSkillsAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'skill_id', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Skill' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Skills'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    ${nl2br(item[3])}

    `); + return itemHtml; + } +} + + +/** + * @class EmployeeSubEducationAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + + +class EmployeeSubEducationAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'education_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Qualification' }, + { sTitle: 'Institute' }, + { sTitle: 'Start Date' }, + { sTitle: 'Completed On' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], + ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Education'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let start = ''; + try { + start = Date.parse(item[4]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + + let end = ''; + try { + end = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Start: ${start}

    Completed: ${end}

    ` + + ` Institute: ${item[3]}

    `); + } +} + + +/** + * @class EmployeeSubCertificationAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubCertificationAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'certification_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Certification' }, + { sTitle: 'Institute' }, + { sTitle: 'Granted On' }, + { sTitle: 'Valid Thru' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], + ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Certifications'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let start = ''; + try { + start = Date.parse(item[4]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + + let end = ''; + try { + end = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Granted On: ${start}

    Valid Thru: ${end}

    Institute: ${item[3]}

    `); + } +} + +/** + * @class EmployeeSubLanguageAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubLanguageAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'language_id', + 'reading', + 'speaking', + 'writing', + 'understanding', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Language' }, + { sTitle: 'Reading' }, + { sTitle: 'Speaking' }, + { sTitle: 'Writing' }, + { sTitle: 'Understanding' }, + ]; + } + + getFormFields() { + const compArray = [['Elementary Proficiency', 'Elementary Proficiency'], + ['Limited Working Proficiency', 'Limited Working Proficiency'], + ['Professional Working Proficiency', 'Professional Working Proficiency'], + ['Full Professional Proficiency', 'Full Professional Proficiency'], + ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'name'], + }], + ['reading', { label: 'Reading', type: 'select', source: compArray }], + ['speaking', { label: 'Speaking', type: 'select', source: compArray }], + ['writing', { label: 'Writing', type: 'select', source: compArray }], + ['understanding', { label: 'Understanding', type: 'select', source: compArray }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Languages'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Reading: ${item[3]}

    Speaking: ${item[4]}

    Writing: ${item[5]}

    Understanding: ${item[6]}

    `); + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * @class EmployeeSubDependentAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubDependentAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'dob', + 'id_number', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Date of Birth' }, + { sTitle: 'Id Number' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], + ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], + ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Dependents'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    Relationship: ${item[3]}

    Name: ${item[2]}

    `); + return itemHtml; + } +} + + +/** + * @class EmployeeSubEmergencyContactAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubEmergencyContactAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'home_phone', + 'work_phone', + 'mobile_phone', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Home Phone' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Mobile Phone' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Emergency Contacts'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    Relationship: ${item[3]}

    Name: ${item[2]}

    Home Phone: ${item[4]}

    Mobile Phone: ${item[6]}

    `); + return itemHtml; + } +} + +/** + * @class EmployeeSubDocumentAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubDocumentAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'details', + 'date_added', + 'valid_until', + 'status', + 'attachment', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Details' }, + { sTitle: 'Date Added' }, + { sTitle: 'Status' }, + { sTitle: 'Attachment', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name'] }], + ['date_added', { label: 'Date Added', type: 'date', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Documents'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let expire = ''; + try { + expire = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(e.message); + } + + const downloadButton = ``; + + const itemHtml = $(`
    ${item[2]}${downloadButton}${itemDelete}${itemEdit}

    ${nl2br(item[3])}

    Expire On: ${expire}

    `); + return itemHtml; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +class SubProfileEnabledAdapterBase extends AdapterBase { + isSubProfileTable() { + if (this.user.user_level === 'Admin') { + return false; + } + return true; + } +} + + +class EmployeeAdapter extends SubProfileEnabledAdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.fieldNameMap = {}; + this.hiddenFields = {}; + this.tableFields = {}; + this.formOnlyFields = {}; + } + + setFieldNameMap(fields) { + let field; + for (let i = 0; i < fields.length; i++) { + field = fields[i]; + this.fieldNameMap[field.name] = field; + if (field.display === 'Hidden') { + this.hiddenFields[field.name] = field; + } else if (field.display === 'Table and Form' || field.display === 'Form') { + this.tableFields[field.name] = field; + } else { + this.formOnlyFields[field.name] = field; + } + } + } + + getCustomTableParams() { + const that = this; + return { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 1); + }, + aTargets: [1], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + } + + preProcessRemoteTableData(data, cell, id) { + if (id === 1) { + const tmp = 'User Image'; + return tmp.replace('_img_', cell); + } + return cell; + } + + getTableHTMLTemplate() { + return '
    '; + } + + getTableFields() { + return [ + 'id', + 'image', + 'employee_id', + 'first_name', + 'last_name', + 'mobile_phone', + 'department', + 'gender', + 'supervisor', + ]; + } + + getDataMapping() { + const tableFields = this.getTableFields(); + + const newTableFields = []; + for (let i = 0; i < tableFields.length; i++) { + if ((this.hiddenFields[tableFields[i]] === undefined || this.hiddenFields[tableFields[i]] === null) + && (this.formOnlyFields[tableFields[i]] === undefined || this.formOnlyFields[tableFields[i]] === null)) { + newTableFields.push(tableFields[i]); + } + } + + return newTableFields; + } + + getHeaders() { + const tableFields = this.getTableFields(); + const headers = [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '', bSortable: false }, + ]; + let title = ''; + + for (let i = 0; i < tableFields.length; i++) { + if ((this.hiddenFields[tableFields[i]] === undefined || this.hiddenFields[tableFields[i]] === null) + && (this.formOnlyFields[tableFields[i]] === undefined || this.formOnlyFields[tableFields[i]] === null)) { + if (this.fieldNameMap[tableFields[i]] !== undefined && this.fieldNameMap[tableFields[i]] !== null) { + title = this.fieldNameMap[tableFields[i]].textMapped; + if (title === undefined || title === null || title === '') { + headers.push({ sTitle: title }); + } else if (tableFields[i] === 'gender') { + headers.push({ sTitle: title, translate: true }); + } else { + headers.push({ sTitle: title }); + } + } + } + } + + return headers; + } + + getFormFields() { + const newFields = []; + let tempField; let + title; + const fields = [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], + ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], + ['ethnicity', { + label: 'Ethnicity', type: 'select2', 'allow-null': true, 'remote-source': ['Ethnicity', 'id', 'name'], + }], + ['immigration_status', { + label: 'Immigration Status', type: 'select2', 'allow-null': true, 'remote-source': ['ImmigrationStatus', 'id', 'name'], + }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['pay_grade', { + label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }], + ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], + ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], + ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], + ['city', { label: 'City', type: 'text', validation: 'none' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['province', { + label: 'State', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'], + }], + ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'text', validation: 'emailOrEmpty' }], + ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ['confirmation_date', { label: 'Confirmation Date', type: 'date', validation: 'none' }], + ['termination_date', { label: 'Termination Date', type: 'date', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Direct Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['indirect_supervisors', { + label: 'Indirect Supervisors', type: 'select2multi', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver1', { + label: 'First Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver2', { + label: 'Second Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver3', { + label: 'Third Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['notes', { + label: 'Notes', + type: 'datagroup', + form: [ + ['note', { label: 'Note', type: 'textarea', validation: '' }], + ], + html: '
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', + validation: 'none', + 'sort-function': function (a, b) { + const t1 = Date.parse(a.date).getTime(); + const t2 = Date.parse(b.date).getTime(); + + return (t1 < t2); + }, + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + data.date = new Date().toString('d-MMM-yyyy hh:mm tt'); + res.params = data; + return res; + }, + + }], + ]; + + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + for (let i = 0; i < fields.length; i++) { + tempField = fields[i]; + if (this.hiddenFields[tempField[0]] === undefined || this.hiddenFields[tempField[0]] === null) { + if (this.fieldNameMap[tempField[0]] !== undefined && this.fieldNameMap[tempField[0]] !== null) { + title = this.fieldNameMap[tempField[0]].textMapped; + tempField[1].label = title; + } + newFields.push(tempField); + } + } + + return newFields; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + let deleteBtn = ''; + if (this.showDelete === false) { + deleteBtn = ''; + } + // eslint-disable-next-line max-len + let html = `
    ${deleteBtn}
    `; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getHelpLink() { + return 'https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html'; + } + + saveSuccessItemCallback(data) { + this.lastSavedEmployee = data; + if (this.currentId === null) { + $('#createUserModel').modal('show'); + } + } + + closeCreateUser() { + $('#createUserModel').modal('hide'); + } + + createUser() { + const data = {}; + data.employee = this.lastSavedEmployee.id; + data.user_level = 'Employee'; + data.email = this.lastSavedEmployee.work_email; + data.username = this.lastSavedEmployee.work_email.split('@')[0]; + top.location.href = this.getCustomUrl( + `?g=admin&n=users&m=admin_Admin&action=new&object=${ + Base64.encodeURI(JSON.stringify(data))}`, + ); + } + + deleteEmployee(id) { + if (confirm('Are you sure you want to archive this employee? Data for this employee will be saved to an archive table. But you will not be able to covert the archived employee data into a normal employee.')) { + // Archive + } else { + return; + } + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'deleteEmployeeSuccessCallback'; + callBackData.callBackFail = 'deleteEmployeeFailCallback'; + + this.customAction( + 'deleteEmployee', + 'admin=employees', + JSON.stringify({ id }), callBackData, + ); + } + + + deleteEmployeeSuccessCallback(callBackData) { + this.showMessage('Delete Success', 'Employee deleted. You can find archived information for this employee in Archived Employees tab'); + this.get([]); + } + + + deleteEmployeeFailCallback(callBackData) { + this.showMessage('Error occurred while deleting Employee', callBackData); + } + + + terminateEmployee(id) { + if (confirm('Are you sure you want to terminate this employee contract? You will still be able to access all details of this employee.')) { + // Terminate + } else { + return; + } + + const params = {}; + params.id = id; + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'terminateEmployeeSuccessCallback'; + callBackData.callBackFail = 'terminateEmployeeFailCallback'; + + this.customAction('terminateEmployee', 'admin=employees', reqJson, callBackData); + } + + + terminateEmployeeSuccessCallback(callBackData) { + this.showMessage('Success', 'Employee contract terminated. You can find terminated employee information under Terminated Employees menu.'); + this.get([]); + } + + + terminateEmployeeFailCallback(callBackData) { + this.showMessage('Error occured while terminating Employee', callBackData); + } + + + activateEmployee(id) { + if (confirm('Are you sure you want to re-activate this employee contract?')) { + // Terminate + } else { + return; + } + + const params = {}; + params.id = id; + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'activateEmployeeSuccessCallback'; + callBackData.callBackFail = 'activateEmployeeFailCallback'; + + this.customAction('activateEmployee', 'admin=employees', reqJson, callBackData); + } + + + activateEmployeeSuccessCallback(callBackData) { + this.showMessage('Success', 'Employee contract re-activated.'); + this.get([]); + } + + + activateEmployeeFailCallback(callBackData) { + this.showMessage('Error occurred while activating Employee', callBackData); + } + + + view(id) { + const that = this; + this.currentId = id; + const sourceMappingJson = JSON.stringify(this.getSourceMapping()); + const object = { id, map: sourceMappingJson }; + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'renderEmployee'; + callBackData.callBackFail = 'viewFailCallBack'; + + this.customAction('get', 'modules=employees', reqJson, callBackData); + } + + + viewFailCallBack(callBackData) { + this.showMessage('Error', 'Error Occured while retriving candidate'); + } + + renderEmployee(data) { + let title; + const fields = this.getFormFields(); + const currentEmpId = data[1]; + const currentId = data[1]; + const userEmpId = data[2]; + data = data[0]; + this.currentEmployee = data; + let html = this.getCustomTemplate('myDetails.html'); + + + for (let i = 0; i < fields.length; i++) { + if (this.fieldNameMap[fields[i][0]] !== undefined && this.fieldNameMap[fields[i][0]] !== null) { + title = this.gt(this.fieldNameMap[fields[i][0]].textMapped); + html = html.replace(`#_label_${fields[i][0]}_#`, title); + } + } + + html = html.replace(/#_.+_#/gi, ''); + html = html.replace(/_id_/g, data.id); + + $(`#${this.getTableName()}`).html(html); + + for (let i = 0; i < fields.length; i++) { + $(`#${this.getTableName()} #${fields[i][0]}`).html(data[fields[i][0]]); + $(`#${this.getTableName()} #${fields[i][0]}_Name`).html(data[`${fields[i][0]}_Name`]); + } + + let subordinates = ''; + for (let i = 0; i < data.subordinates.length; i++) { + if (data.subordinates[i].first_name !== undefined && data.subordinates[i].first_name !== null) { + subordinates += `${data.subordinates[i].first_name} `; + } + + if (data.subordinates[i].middle_name !== undefined && data.subordinates[i].middle_name !== null && data.subordinates[i].middle_name !== '') { + subordinates += `${data.subordinates[i].middle_name} `; + } + + if (data.subordinates[i].last_name !== undefined && data.subordinates[i].last_name !== null && data.subordinates[i].last_name !== '') { + subordinates += data.subordinates[i].last_name; + } + subordinates += '
    '; + } + + $(`#${this.getTableName()} #subordinates`).html(subordinates); + + + $(`#${this.getTableName()} #name`).html(`${data.first_name} ${data.last_name}`); + this.currentUserId = data.id; + + $(`#${this.getTableName()} #profile_image_${data.id}`).attr('src', data.image); + + + // Add custom fields + if (data.customFields !== undefined && data.customFields !== null && Object.keys(data.customFields).length > 0) { + const ct = '
    '; + + const sectionTemplate = '

    #_section.name_#

    '; + let customFieldHtml; + for (const index in data.customFields) { + if (!data.customFields[index][1]) { + data.customFields[index][1] = this.gt('Other Details'); + } + + let sectionId = data.customFields[index][1].toLocaleLowerCase(); + sectionId = sectionId.replace(' ', '_'); + + if ($(`#cont_${sectionId}`).length <= 0) { + // Add section + let sectionHtml = sectionTemplate; + sectionHtml = sectionHtml.replace('#_section_#', sectionId); + sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); + $('#customFieldsCont').append($(sectionHtml)); + } + + customFieldHtml = ct; + customFieldHtml = customFieldHtml.replace('#_label_#', index); + if (data.customFields[index][2] === 'fileupload') { + customFieldHtml = customFieldHtml.replace( + '#_value_#', + ``, + ); + } else { + customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); + } + $(`#cont_${sectionId}`).append($(customFieldHtml)); + } + } else { + $('#customFieldsCont').remove(); + } + + + this.cancel(); + + if (!this.isModuleInstalled('admin', 'documents')) { + $('#tabDocuments').remove(); + } + + + window.modJs = this; + modJs.subModJsList = []; + + modJs.subModJsList.tabEmployeeSkillSubTab = new EmployeeSubSkillsAdapter('EmployeeSkill', 'EmployeeSkillSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeSkillSubTab.parent = this; + + modJs.subModJsList.tabEmployeeEducationSubTab = new EmployeeSubEducationAdapter('EmployeeEducation', 'EmployeeEducationSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeEducationSubTab.parent = this; + + modJs.subModJsList.tabEmployeeCertificationSubTab = new EmployeeSubCertificationAdapter('EmployeeCertification', 'EmployeeCertificationSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeCertificationSubTab.parent = this; + + modJs.subModJsList.tabEmployeeLanguageSubTab = new EmployeeSubLanguageAdapter('EmployeeLanguage', 'EmployeeLanguageSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeLanguageSubTab.parent = this; + + modJs.subModJsList.tabEmployeeDependentSubTab = new EmployeeSubDependentAdapter('EmployeeDependent', 'EmployeeDependentSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeDependentSubTab.parent = this; + + modJs.subModJsList.tabEmployeeEmergencyContactSubTab = new EmployeeSubEmergencyContactAdapter('EmergencyContact', 'EmployeeEmergencyContactSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.parent = this; + + if (this.isModuleInstalled('admin', 'documents')) { + modJs.subModJsList.tabEmployeeDocumentSubTab = new EmployeeSubDocumentAdapter('EmployeeDocument', 'EmployeeDocumentSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeDocumentSubTab.parent = this; + } + for (const prop in modJs.subModJsList) { + if (modJs.subModJsList.hasOwnProperty(prop)) { + modJs.subModJsList[prop].setTranslationsSubModules(this.translations); + modJs.subModJsList[prop].setPermissions(this.permissions); + modJs.subModJsList[prop].setFieldTemplates(this.fieldTemplates); + modJs.subModJsList[prop].setTemplates(this.templates); + modJs.subModJsList[prop].setCustomTemplates(this.customTemplates); + modJs.subModJsList[prop].setEmailTemplates(this.emailTemplates); + modJs.subModJsList[prop].setUser(this.user); + modJs.subModJsList[prop].initFieldMasterData(); + modJs.subModJsList[prop].setBaseUrl(this.baseUrl); + modJs.subModJsList[prop].setCurrentProfile(this.currentProfile); + modJs.subModJsList[prop].setInstanceId(this.instanceId); + modJs.subModJsList[prop].setGoogleAnalytics(ga); + modJs.subModJsList[prop].setNoJSONRequests(this.noJSONRequests); + } + } + + modJs.subModJsList.tabEmployeeSkillSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeSkillSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeSkillSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeSkillSubTab.get([]); + + modJs.subModJsList.tabEmployeeEducationSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeEducationSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeEducationSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeEducationSubTab.get([]); + + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeCertificationSubTab.get([]); + + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeLanguageSubTab.get([]); + + modJs.subModJsList.tabEmployeeDependentSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeDependentSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeDependentSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeDependentSubTab.get([]); + + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.get([]); + + if (this.isModuleInstalled('admin', 'documents')) { + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeDocumentSubTab.get([]); + } + + $('#subModTab a').off().on('click', function (e) { + e.preventDefault(); + $(this).tab('show'); + }); + } + + + deleteProfileImage(empId) { + const req = { id: empId }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'modEmployeeDeleteProfileImageCallBack'; + callBackData.callBackFail = 'modEmployeeDeleteProfileImageCallBack'; + + this.customAction('deleteProfileImage', 'modules=employees', reqJson, callBackData); + } + + modEmployeeDeleteProfileImageCallBack(data) { + // top.location.href = top.location.href; + } +} + +/* + * Terminated Employee + */ + +class TerminatedEmployeeAdapter extends EmployeeAdapter { + getDataMapping() { + return [ + 'id', + 'image', + 'employee_id', + 'first_name', + 'last_name', + 'mobile_phone', + 'department', + 'gender', + 'supervisor', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: '', bSortable: false }, + { sTitle: 'Employee Number' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Mobile' }, + { sTitle: 'Department' }, + { sTitle: 'Gender' }, + { sTitle: 'Supervisor' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], + ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + /* [ "driving_license_exp_date", {"label":"License Exp Date","type":"date","validation":"none"}], */ + ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['pay_grade', { + label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }], + ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], + ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], + ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], + ['city', { label: 'City', type: 'text', validation: 'none' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['province', { + label: 'Province', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'], + }], + ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'text', validation: 'emailOrEmpty' }], + ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ['confirmation_date', { label: 'Confirmation Date', type: 'date', validation: 'none' }], + ['termination_date', { label: 'Termination Date', type: 'date', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['notes', { + label: 'Notes', + type: 'datagroup', + form: [ + ['note', { label: 'Note', type: 'textarea', validation: '' }], + ], + html: '
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', + validation: 'none', + 'sort-function': function (a, b) { + const t1 = Date.parse(a.date).getTime(); + const t2 = Date.parse(b.date).getTime(); + + return (t1 < t2); + }, + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + data.date = new Date().toString('d-MMM-yyyy hh:mm tt'); + res.params = data; + return res; + }, + + }], + ]; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + // eslint-disable-next-line max-len + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + download(id) { + const params = { t: 'ArchivedEmployee', sa: 'downloadArchivedEmployee', mod: 'admin=employees' }; + params.req = JSON.stringify({ id }); + const downloadUrl = modJs.getCustomActionUrl('ca', params); + window.open(downloadUrl, '_blank'); + } +} + + +/* + * Archived Employee + */ + +class ArchivedEmployeeAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee_id', + 'first_name', + 'last_name', + 'work_email', + 'department', + 'gender', + 'supervisor', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'Employee Number' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Work Email' }, + { sTitle: 'Department' }, + { sTitle: 'Gender' }, + { sTitle: 'Supervisor' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + // eslint-disable-next-line max-len + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + download(id) { + const params = { t: 'ArchivedEmployee', sa: 'downloadArchivedEmployee', mod: 'admin=employees' }; + params.req = JSON.stringify({ id }); + const downloadUrl = modJs.getCustomActionUrl('ca', params); + window.open(downloadUrl, '_blank'); + } +} + + +/* + * ========================================================== + */ + + +class EmployeeSkillAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'skill_id', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Skill' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'null-label': 'All Skills', 'remote-source': ['Skill', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeEducationAdapter + */ + +class EmployeeEducationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'education_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Qualification' }, + { sTitle: 'Institute' }, + { sTitle: 'Start Date' }, + { sTitle: 'Completed On' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], + ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': true, 'null-label': 'All Qualifications', 'remote-source': ['Education', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeCertificationAdapter + */ + +class EmployeeCertificationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'certification_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Certification' }, + { sTitle: 'Institute' }, + { sTitle: 'Granted On' }, + { sTitle: 'Valid Thru' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], + ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': true, 'null-label': 'All Certifications', 'remote-source': ['Certification', 'id', 'name'], + }], + + ]; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeLanguageAdapter + */ + +class EmployeeLanguageAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'language_id', + 'reading', + 'speaking', + 'writing', + 'understanding', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Language' }, + { sTitle: 'Reading' }, + { sTitle: 'Speaking' }, + { sTitle: 'Writing' }, + { sTitle: 'Understanding' }, + ]; + } + + getFormFields() { + const compArray = [['Elementary Proficiency', 'Elementary Proficiency'], + ['Limited Working Proficiency', 'Limited Working Proficiency'], + ['Professional Working Proficiency', 'Professional Working Proficiency'], + ['Full Professional Proficiency', 'Full Professional Proficiency'], + ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'name'], + }], + ['reading', { label: 'Reading', type: 'select', source: compArray }], + ['speaking', { label: 'Speaking', type: 'select', source: compArray }], + ['writing', { label: 'Writing', type: 'select', source: compArray }], + ['understanding', { label: 'Understanding', type: 'select', source: compArray }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': true, 'null-label': 'All Languages', 'remote-source': ['Language', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeDependentAdapter + */ + + +class EmployeeDependentAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'dob', + 'id_number', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Date of Birth' }, + { sTitle: 'Id Number' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], + ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], + ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/* + * EmergencyContactAdapter + */ + + +class EmergencyContactAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'home_phone', + 'work_phone', + 'mobile_phone', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Home Phone' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Mobile Phone' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/* + * EmployeeImmigrationAdapter + */ + + +class EmployeeImmigrationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'doc_number', + 'issued', + 'expiry', + 'status', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document', sClass: 'columnMain' }, + { sTitle: 'Number' }, + { sTitle: 'Issued Date' }, + { sTitle: 'Expiry Date' }, + { sTitle: 'Status' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['document', { label: 'Document', type: 'select2', source: [['Passport', 'Passport'], ['Visa', 'Visa']] }], + ['doc_number', { label: 'Number', type: 'text', validation: '' }], + ['issued', { label: 'Issued Date', type: 'date', validation: '' }], + ['expiry', { label: 'Expiry Date', type: 'date', validation: '' }], + ['status', { label: 'Status', type: 'text', validation: 'none' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +/** + * EmployeeDocumentAdapter + */ + +class EmployeeDocumentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'details', + 'date_added', + 'status', + 'attachment', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Details' }, + { sTitle: 'Date Added' }, + { sTitle: 'Status' }, + { sTitle: 'Attachment', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name'] }], + ['date_added', { label: 'Date Added', type: 'date', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } + + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_attachment_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +module.exports = { + EmployeeAdapter, + TerminatedEmployeeAdapter, + ArchivedEmployeeAdapter, + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, + EmployeeDependentAdapter, + EmergencyContactAdapter, + EmployeeImmigrationAdapter, + EmployeeSubSkillsAdapter, + EmployeeSubEducationAdapter, + EmployeeSubCertificationAdapter, + EmployeeSubLanguageAdapter, + EmployeeSubDependentAdapter, + EmployeeSubEmergencyContactAdapter, + EmployeeSubDocumentAdapter, + EmployeeDocumentAdapter, +}; diff --git a/web/admin/src/fieldnames/index.js b/web/admin/src/fieldnames/index.js new file mode 100644 index 00000000..07a711da --- /dev/null +++ b/web/admin/src/fieldnames/index.js @@ -0,0 +1,4 @@ +import { FieldNameAdapter, CustomFieldAdapter } from './lib'; + +window.FieldNameAdapter = FieldNameAdapter; +window.CustomFieldAdapter = CustomFieldAdapter; diff --git a/web/admin/src/fieldnames/lib.js b/web/admin/src/fieldnames/lib.js new file mode 100644 index 00000000..5edc0e67 --- /dev/null +++ b/web/admin/src/fieldnames/lib.js @@ -0,0 +1,47 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import CustomFieldAdapter from '../../../api/CustomFieldAdapter'; + +/** + * FieldNameAdapter + */ + +class FieldNameAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'textOrig', + 'textMapped', + 'display', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Original Text' }, + { sTitle: 'Mapped Text' }, + { sTitle: 'Display Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['type', { label: 'Type', type: 'placeholder', validation: '' }], + ['name', { label: 'Name', type: 'placeholder', validation: '' }], + ['textOrig', { label: 'Original Text', type: 'placeholder', validation: '' }], + ['textMapped', { label: 'Mapped Text', type: 'text', validation: '' }], + ['display', { label: 'Display Status', type: 'select', source: [['Form', 'Show'], ['Hidden', 'Hidden']] }], + ]; + } +} + + +module.exports = { FieldNameAdapter, CustomFieldAdapter }; diff --git a/web/admin/src/jobs/index.js b/web/admin/src/jobs/index.js new file mode 100644 index 00000000..22cfebc7 --- /dev/null +++ b/web/admin/src/jobs/index.js @@ -0,0 +1,5 @@ +import { JobTitleAdapter, PayGradeAdapter, EmploymentStatusAdapter } from './lib'; + +window.JobTitleAdapter = JobTitleAdapter; +window.PayGradeAdapter = PayGradeAdapter; +window.EmploymentStatusAdapter = EmploymentStatusAdapter; diff --git a/web/admin/src/jobs/lib.js b/web/admin/src/jobs/lib.js new file mode 100644 index 00000000..23a2cc58 --- /dev/null +++ b/web/admin/src/jobs/lib.js @@ -0,0 +1,124 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * JobTitleAdapter + */ + +class JobTitleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Job Title Code', type: 'text' }], + ['name', { label: 'Job Title', type: 'text' }], + ['description', { label: 'Description', type: 'textarea' }], + ['specification', { label: 'Specification', type: 'textarea' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/jobdetails/'; + } +} + + +/** + * PayGradeAdapter + */ + +class PayGradeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'currency', + 'min_salary', + 'max_salary', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Currency' }, + { sTitle: 'Min Salary' }, + { sTitle: 'Max Salary' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Pay Grade Name', type: 'text' }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'code', 'name'] }], + ['min_salary', { label: 'Min Salary', type: 'text', validation: 'float' }], + ['max_salary', { label: 'Max Salary', type: 'text', validation: 'float' }], + ]; + } + + doCustomValidation(params) { + try { + if (parseFloat(params.min_salary) > parseFloat(params.max_salary)) { + return 'Min Salary should be smaller than Max Salary'; + } + } catch (e) { + // D/N + } + return null; + } +} + + +/** + * EmploymentStatusAdapter + */ + +class EmploymentStatusAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Employment Status', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +module.exports = { JobTitleAdapter, PayGradeAdapter, EmploymentStatusAdapter }; diff --git a/web/admin/src/loans/index.js b/web/admin/src/loans/index.js new file mode 100644 index 00000000..82afb258 --- /dev/null +++ b/web/admin/src/loans/index.js @@ -0,0 +1,7 @@ +import { + CompanyLoanAdapter, + EmployeeCompanyLoanAdapter, +} from './lib'; + +window.CompanyLoanAdapter = CompanyLoanAdapter; +window.EmployeeCompanyLoanAdapter = EmployeeCompanyLoanAdapter; diff --git a/web/admin/src/loans/lib.js b/web/admin/src/loans/lib.js new file mode 100644 index 00000000..cf71f83b --- /dev/null +++ b/web/admin/src/loans/lib.js @@ -0,0 +1,101 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +/** + * CompanyLoanAdapter + */ + +class CompanyLoanAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * EmployeeCompanyLoanAdapter + */ + +class EmployeeCompanyLoanAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'loan', + 'start_date', + 'period_months', + 'currency', + 'amount', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Loan Type' }, + { sTitle: 'Loan Start Date' }, + { sTitle: 'Loan Period (Months)' }, + { sTitle: 'Currency' }, + { sTitle: 'Amount' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['loan', { label: 'Loan Type', type: 'select', 'remote-source': ['CompanyLoan', 'id', 'name'] }], + ['start_date', { label: 'Loan Start Date', type: 'date', validation: '' }], + ['last_installment_date', { label: 'Last Installment Date', type: 'date', validation: 'none' }], + ['period_months', { label: 'Loan Period (Months)', type: 'text', validation: 'number' }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'id', 'name'] }], + ['amount', { label: 'Loan Amount', type: 'text', validation: 'float' }], + ['monthly_installment', { label: 'Monthly Installment', type: 'text', validation: 'float' }], + ['status', { label: 'Status', type: 'select', source: [['Approved', 'Approved'], ['Paid', 'Paid'], ['Suspended', 'Suspended']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': true, 'null-label': 'All Employees', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['loan', { + label: 'Loan Type', type: 'select', 'allow-null': true, 'null-label': 'All Loan Types', 'remote-source': ['CompanyLoan', 'id', 'name'], + }], + + ]; + } +} + +module.exports = { + CompanyLoanAdapter, + EmployeeCompanyLoanAdapter, +}; diff --git a/web/admin/src/metadata/index.js b/web/admin/src/metadata/index.js new file mode 100644 index 00000000..82af59b6 --- /dev/null +++ b/web/admin/src/metadata/index.js @@ -0,0 +1,15 @@ +import { + CountryAdapter, + ProvinceAdapter, + CurrencyTypeAdapter, + NationalityAdapter, + ImmigrationStatusAdapter, + EthnicityAdapter, +} from './lib'; + +window.CountryAdapter = CountryAdapter; +window.ProvinceAdapter = ProvinceAdapter; +window.CurrencyTypeAdapter = CurrencyTypeAdapter; +window.NationalityAdapter = NationalityAdapter; +window.ImmigrationStatusAdapter = ImmigrationStatusAdapter; +window.EthnicityAdapter = EthnicityAdapter; diff --git a/web/admin/src/metadata/lib.js b/web/admin/src/metadata/lib.js new file mode 100644 index 00000000..789310a1 --- /dev/null +++ b/web/admin/src/metadata/lib.js @@ -0,0 +1,142 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import IdNameAdapter from '../../../api/IdNameAdapter'; +/** + * CountryAdapter + */ + +class CountryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * ProvinceAdapter + */ + +class ProvinceAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + 'country', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + { sTitle: 'Country' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ]; + } + + getFilters() { + return [ + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + + ]; + } +} + +/** + * CurrencyTypeAdapter + */ + +class CurrencyTypeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * NationalityAdapter + */ + +class NationalityAdapter extends IdNameAdapter { + +} + +/** + * ImmigrationStatusAdapter + */ + +class ImmigrationStatusAdapter extends IdNameAdapter { + +} + + +/** + * EthnicityAdapter + */ + +class EthnicityAdapter extends IdNameAdapter { + +} + +module.exports = { + CountryAdapter, + ProvinceAdapter, + CurrencyTypeAdapter, + NationalityAdapter, + ImmigrationStatusAdapter, + EthnicityAdapter, +}; diff --git a/web/admin/src/modules/index.js b/web/admin/src/modules/index.js new file mode 100644 index 00000000..e9b5c349 --- /dev/null +++ b/web/admin/src/modules/index.js @@ -0,0 +1,4 @@ +import { ModuleAdapter, UsageAdapter } from './lib'; + +window.ModuleAdapter = ModuleAdapter; +window.UsageAdapter = UsageAdapter; diff --git a/web/admin/src/modules/lib.js b/web/admin/src/modules/lib.js new file mode 100644 index 00000000..c99f3b3d --- /dev/null +++ b/web/admin/src/modules/lib.js @@ -0,0 +1,133 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; +/** + * ModuleAdapter + */ + +class ModuleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'label', + 'menu', + 'mod_group', + 'mod_order', + 'status', + 'version', + 'update_path', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Menu', bVisible: false }, + { sTitle: 'Group' }, + { sTitle: 'Order' }, + { sTitle: 'Status' }, + { sTitle: 'Version', bVisible: false }, + { sTitle: 'Path', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['label', { label: 'Label', type: 'text', validation: '' }], + ['status', { label: 'Status', type: 'select', source: [['Enabled', 'Enabled'], ['Disabled', 'Disabled']] }], + ['user_levels', { label: 'User Levels', type: 'select2multi', source: [['Admin', 'Admin'], ['Manager', 'Manager'], ['Employee', 'Employee'], ['Other', 'Other']] }], + ['user_roles', { label: 'User Roles', type: 'select2multi', 'remote-source': ['UserRole', 'id', 'name'] }], + ]; + } + + + getActionButtonsHtml(id, data) { + const nonEditableFields = {}; + nonEditableFields['admin_Company Structure'] = 1; + nonEditableFields.admin_Employees = 1; + nonEditableFields['admin_Job Details Setup'] = 1; + nonEditableFields.admin_Leaves = 1; + nonEditableFields['admin_Manage Modules'] = 1; + nonEditableFields.admin_Projects = 1; + nonEditableFields.admin_Qualifications = 1; + nonEditableFields.admin_Settings = 1; + nonEditableFields.admin_Users = 1; + nonEditableFields.admin_Upgrade = 1; + nonEditableFields.admin_Dashboard = 1; + + nonEditableFields['user_Basic Information'] = 1; + nonEditableFields.user_Dashboard = 1; + + if (nonEditableFields[`${data[3]}_${data[1]}`] === 1) { + return ''; + } + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +/** + * UsageAdapter + */ + +class UsageAdapter extends AdapterBase { + getDataMapping() { + return []; + } + + getHeaders() { + return []; + } + + getFormFields() { + return []; + } + + + get(callBackData) { + + } + + saveUsage() { + const object = {}; + const arr = []; + $('.module-check').each(function () { + if ($(this).is(':checked')) { + arr.push($(this).val()); + } + }); + + if (arr.length === 0) { + alert('Please select one or more module groups'); + return; + } + + object.groups = arr.join(','); + + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; + callBackData.callBackFail = 'getInitDataFailCallBack'; + + this.customAction('saveUsage', 'admin=modules', reqJson, callBackData); + } + + + saveUsageSuccessCallBack(data) { + + } + + saveUsageFailCallBack(callBackData) { + + } +} + +module.exports = { ModuleAdapter, UsageAdapter }; diff --git a/web/admin/src/overtime/index.js b/web/admin/src/overtime/index.js new file mode 100644 index 00000000..25a00705 --- /dev/null +++ b/web/admin/src/overtime/index.js @@ -0,0 +1,7 @@ +import { + OvertimeCategoryAdapter, + EmployeeOvertimeAdminAdapter, +} from './lib'; + +window.OvertimeCategoryAdapter = OvertimeCategoryAdapter; +window.EmployeeOvertimeAdminAdapter = EmployeeOvertimeAdminAdapter; diff --git a/web/admin/src/overtime/lib.js b/web/admin/src/overtime/lib.js new file mode 100644 index 00000000..944a9074 --- /dev/null +++ b/web/admin/src/overtime/lib.js @@ -0,0 +1,100 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import ApproveAdminAdapter from '../../../api/ApproveAdminAdapter'; + +/** + * OvertimeCategoryAdapter + */ + +class OvertimeCategoryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * EmployeeOvertimeAdminAdapter + */ + + +class EmployeeOvertimeAdminAdapter extends ApproveAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'OvertimeRequest'; + this.itemNameLower = 'overtimerequest'; + this.modulePathName = 'overtime'; + } + + getDataMapping() { + return [ + 'id', + 'employee', + 'category', + 'start_time', + 'end_time', + 'project', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Category' }, + { sTitle: 'Start Time' }, + { sTitle: 'End Time' }, + { sTitle: 'Project' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['category', { + label: 'Category', type: 'select2', 'allow-null': false, 'remote-source': ['OvertimeCategory', 'id', 'name'], + }], + ['start_time', { label: 'Start Time', type: 'datetime', validation: '' }], + ['end_time', { label: 'End Time', type: 'datetime', validation: '' }], + ['project', { + label: 'Project', type: 'select2', 'allow-null': true, 'null=label': 'none', 'remote-source': ['Project', 'id', 'name'], + }], + ['notes', { label: 'Notes', type: 'textarea', validation: 'none' }], + ]; + } +} + +module.exports = { + OvertimeCategoryAdapter, + EmployeeOvertimeAdminAdapter, +}; diff --git a/web/admin/src/payroll/index.js b/web/admin/src/payroll/index.js new file mode 100644 index 00000000..943a7dcf --- /dev/null +++ b/web/admin/src/payroll/index.js @@ -0,0 +1,21 @@ +import { + PaydayAdapter, + PayrollAdapter, + PayrollDataAdapter, + PayrollColumnAdapter, + PayrollColumnTemplateAdapter, + PayrollEmployeeAdapter, + DeductionAdapter, + DeductionGroupAdapter, + PayslipTemplateAdapter, +} from './lib'; + +window.PaydayAdapter = PaydayAdapter; +window.PayrollAdapter = PayrollAdapter; +window.PayrollDataAdapter = PayrollDataAdapter; +window.PayrollColumnAdapter = PayrollColumnAdapter; +window.PayrollColumnTemplateAdapter = PayrollColumnTemplateAdapter; +window.PayrollEmployeeAdapter = PayrollEmployeeAdapter; +window.DeductionAdapter = DeductionAdapter; +window.DeductionGroupAdapter = DeductionGroupAdapter; +window.PayslipTemplateAdapter = PayslipTemplateAdapter; diff --git a/web/admin/src/payroll/lib.js b/web/admin/src/payroll/lib.js new file mode 100644 index 00000000..ea8ee13e --- /dev/null +++ b/web/admin/src/payroll/lib.js @@ -0,0 +1,631 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global modJs, modJsList */ +import AdapterBase from '../../../api/AdapterBase'; +import TableEditAdapter from '../../../api/TableEditAdapter'; + +/** + * PaydayAdapter + */ + +class PaydayAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Select Pay Frequency' }, + ]; + } + + getFormFields() { + return [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } + + getAddNewLabel() { + return 'Run Payroll'; + } + + createTable(elementId) { + $('#payday_all').off(); + super.createTable(elementId); + $('#payday_all').off().on('click', function () { + if ($(this).is(':checked')) { + $('.paydayCheck').prop('checked', true); + } else { + $('.paydayCheck').prop('checked', false); + } + }); + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + + let html = '
    _edit_
    '; + html = html.replace('_edit_', editButton); + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getActionButtonHeader() { + return { sTitle: '', sClass: 'center' }; + } +} + + +/** + * PayrollAdapter + */ + +class PayrollAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'pay_period', + 'department', + 'date_start', + 'date_end', + 'status', + + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Pay Frequency' }, + { sTitle: 'Department' }, + { sTitle: 'Date Start' }, + { sTitle: 'Date End' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['pay_period', { + label: 'Pay Frequency', type: 'select', 'remote-source': ['PayFrequency', 'id', 'name'], sort: 'none', + }], + ['deduction_group', { + label: 'Calculation Group', type: 'select', 'remote-source': ['DeductionGroup', 'id', 'name'], sort: 'none', + }], + ['payslipTemplate', { label: 'Payslip Template', type: 'select', 'remote-source': ['PayslipTemplate', 'id', 'name'] }], + ['department', { + label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'], sort: 'none', + }], + ['date_start', { label: 'Start Date', type: 'date', validation: '' }], + ['date_end', { label: 'End Date', type: 'date', validation: '' }], + // [ "column_template", {"label":"Report Column Template","type":"select","remote-source":["PayrollColumnTemplate","id","name"]}], + ['columns', { label: 'Payroll Columns', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['status', { + label: 'Status', type: 'select', source: [['Draft', 'Draft'], ['Completed', 'Completed']], sort: 'none', + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object != null && object !== undefined && object.id !== undefined && object.id != null) { + $tempDomObj.find('#pay_period').attr('disabled', 'disabled'); + $tempDomObj.find('#department').attr('disabled', 'disabled'); + // $tempDomObj.find("#date_start").attr('disabled','disabled'); + // $tempDomObj.find("#date_end").attr('disabled','disabled'); + // $tempDomObj.find("#column_template").attr('disabled','disabled'); + } + } + + process(id, status) { + // eslint-disable-next-line no-global-assign + modJs = modJsList.tabPayrollData; + modJs.setCurrentPayroll(id); + $('#Payroll').hide(); + $('#PayrollData').show(); + $('#PayrollDataButtons').show(); + + if (status === 'Completed') { + $('.completeBtnTable').hide(); + $('.saveBtnTable').hide(); + } else { + $('.completeBtnTable').show(); + $('.saveBtnTable').show(); + } + + modJs.get([]); + } + + + getActionButtonsHtml(id, data) { + const editButton = ''; + const processButton = ''; + const deleteButton = ''; + const cloneButton = ''; + + let html = '
    _edit__process__clone__delete_
    '; + + + if (this.showAddNew) { + html = html.replace('_clone_', cloneButton); + } else { + html = html.replace('_clone_', ''); + } + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace('_process_', processButton); + + + html = html.replace(/_id_/g, id); + html = html.replace(/_status_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + get(callBackData) { + $('#PayrollData').hide(); + $('#PayrollForm').hide(); + $('#PayrollDataButtons').hide(); + $('#Payroll').show(); + modJsList.tabPayrollData.setCurrentPayroll(null); + super.get(callBackData); + } +} + + +/** + * PayrollDataAdapter + */ + +class PayrollDataAdapter extends TableEditAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.cellDataUpdates = {}; + this.payrollId = null; + } + + validateCellValue(element, evt, newValue) { + modJs.addCellDataUpdate(element.data('colId'), element.data('rowId'), newValue); + return true; + } + + setCurrentPayroll(val) { + this.payrollId = val; + } + + + addAdditionalRequestData(type, req) { + if (type === 'updateData') { + req.payrollId = this.payrollId; + } else if (type === 'updateAllData') { + req.payrollId = this.payrollId; + } else if (type === 'getAllData') { + req.payrollId = this.payrollId; + } + + return req; + } + + modifyCSVHeader(header) { + header.unshift(''); + return header; + } + + getCSVData() { + let csv = ''; + + for (let i = 0; i < this.csvData.length; i++) { + csv += this.csvData[i].join(','); + if (i < this.csvData.length - 1) { + csv += '\r\n'; + } + } + + return csv; + } + + downloadPayroll() { + const element = document.createElement('a'); + element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(this.getCSVData())}`); + element.setAttribute('download', `payroll_${this.payrollId}.csv`); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } +} + + +/** + * PayrollColumnAdapter + */ + +class PayrollColumnAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'colorder', + 'calculation_hook', + 'deduction_group', + 'editable', + 'enabled', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Column Order' }, + { sTitle: 'Calculation Method' }, + { sTitle: 'Calculation Group' }, + { sTitle: 'Editable' }, + { sTitle: 'Enabled' }, + ]; + } + + getFormFields() { + const fucntionColumnList = ['calculation_columns', { + label: 'Calculation Columns', + type: 'datagroup', + form: [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ['column', { label: 'Column', type: 'select2', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ], + html: '
    #_delete_##_edit_#
    #_renderFunction_#
    ', + validation: 'none', + render(item) { + const output = `Variable:${item.name}`; + return output; + }, + + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['calculation_hook', { + label: 'Predefined Calculations', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['CalculationHook', 'code', 'name'], + }], + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'Common', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ['salary_components', { label: 'Salary Components', type: 'select2multi', 'remote-source': ['SalaryComponent', 'id', 'name'] }], + ['deductions', { label: 'Calculation Method', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'] }], + ['add_columns', { label: 'Columns to Add', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['sub_columns', { label: 'Columns to Subtract', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['colorder', { label: 'Column Order', type: 'text', validation: 'number' }], + ['editable', { label: 'Editable', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], + ['enabled', { label: 'Enabled', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], + ['default_value', { label: 'Default Value', type: 'text', validation: '' }], + fucntionColumnList, + ['calculation_function', { label: 'Function', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'Any', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ]; + } +} + + +/** + * PayrollColumnTemplateAdapter + */ + +class PayrollColumnTemplateAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: true }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['columns', { label: 'Payroll Columns', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ]; + } +} + + +/* + * PayrollEmployeeAdapter + */ + +class PayrollEmployeeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'pay_frequency', + 'deduction_group', + 'currency', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Pay Frequency' }, + { sTitle: 'Calculation Group' }, + { sTitle: 'Currency' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['pay_frequency', { label: 'Pay Frequency', type: 'select2', 'remote-source': ['PayFrequency', 'id', 'name'] }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'id', 'code'] }], + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ['deduction_exemptions', { + label: 'Calculation Exemptions', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'], validation: 'none', + }], + ['deduction_allowed', { + label: 'Calculations Assigned', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'], validation: 'none', + }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ]; + } +} + + +/** + * DeductionAdapter + */ + +class DeductionAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'deduction_group', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Calculation Group' }, + ]; + } + + getFormFields() { + const rangeAmounts = ['rangeAmounts', { + label: 'Calculation Process', + type: 'datagroup', + form: [ + ['lowerCondition', { label: 'Lower Limit Condition', type: 'select', source: [['No Lower Limit', 'No Lower Limit'], ['gt', 'Greater than'], ['gte', 'Greater than or Equal']] }], + ['lowerLimit', { label: 'Lower Limit', type: 'text', validation: 'float' }], + ['upperCondition', { label: 'Upper Limit Condition', type: 'select', source: [['No Upper Limit', 'No Upper Limit'], ['lt', 'Less than'], ['lte', 'Less than or Equal']] }], + ['upperLimit', { label: 'Upper Limit', type: 'text', validation: 'float' }], + ['amount', { label: 'Value', type: 'text', validation: '' }], + ], + html: '
    #_delete_##_edit_#
    #_renderFunction_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + if (data.lowerCondition === 'No Lower Limit') { + data.lowerLimit = 0; + } + if (data.upperCondition === 'No Upper Limit') { + data.upperLimit = 0; + } + res.params = data; + return res; + }, + render(item) { + let output = ''; + const getSymbol = function (text) { + const map = {}; + map.gt = '>'; + map.gte = '>='; + map.lt = '<'; + map.lte = '<='; + + return map[text]; + }; + + if (item.lowerCondition !== 'No Lower Limit') { + output += `${item.lowerLimit} ${getSymbol(item.lowerCondition)} `; + } + + if (item.upperCondition !== 'No Upper Limit') { + output += ' and '; + output += `${getSymbol(item.upperCondition)} ${item.upperLimit} `; + } + if (output === '') { + return `Deduction is ${item.amount} for all ranges`; + } + return `If salary component ${output} deduction is ${item.amount}`; + }, + + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['componentType', { + label: 'Salary Component Type', type: 'select2multi', 'allow-null': true, 'remote-source': ['SalaryComponentType', 'id', 'name'], + }], + ['component', { + label: 'Salary Component', type: 'select2multi', 'allow-null': true, 'remote-source': ['SalaryComponent', 'id', 'name'], + }], + ['payrollColumn', { + label: 'Payroll Report Column', type: 'select2', 'allow-null': true, 'remote-source': ['PayrollColumn', 'id', 'name'], + }], + rangeAmounts, + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + + ]; + } +} + + +/* + * DeductionGroupAdapter + */ + +class DeductionGroupAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['description', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * PayslipTemplateAdapter + */ + +class PayslipTemplateAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + const payslipFields = ['data', { + label: 'Payslip Fields', + type: 'datagroup', + form: [ + ['type', { + label: 'Type', type: 'select', sort: 'none', source: [['Payroll Column', 'Payroll Column'], ['Text', 'Text'], ['Company Name', 'Company Name'], ['Company Logo', 'Company Logo'], ['Separators', 'Separators']], + }], + ['payrollColumn', { + label: 'Payroll Column', type: 'select2', sort: 'none', 'allow-null': true, 'null-label': 'None', 'remote-source': ['PayrollColumn', 'id', 'name'], + }], + + ['label', { label: 'Label', type: 'text', validation: 'none' }], + ['text', { label: 'Text', type: 'textarea', validation: 'none' }], + ['status', { + label: 'Status', type: 'select', sort: 'none', source: [['Show', 'Show'], ['Hide', 'Hide']], + }], + ], + + // "html":'
    #_delete_##_edit_#
    Type#_type_#
    Label#_label_#
    Text#_text_#
    Font Size#_fontSize_#
    Font Style#_fontStyle_#
    Font Color#_fontColor_#
    Status#_status_#
    ', + html: '
    #_delete_##_edit_#
    #_type_# #_label_#
    #_text_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + if (data.type === 'Payroll Column') { + if (data.payrollColumn === 'NULL') { + res.valid = false; + res.message = 'Please select payroll column'; + } else { + data.payrollColumn = 'NULL'; + } + } else if (data.type === 'Text') { + if (data.text === '') { + res.valid = false; + res.message = 'Text can not be empty'; + } + } + + res.params = data; + return res; + }, + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + payslipFields, + ]; + } +} + + +module.exports = { + PaydayAdapter, + PayrollAdapter, + PayrollDataAdapter, + PayrollColumnAdapter, + PayrollColumnTemplateAdapter, + PayrollEmployeeAdapter, + DeductionAdapter, + DeductionGroupAdapter, + PayslipTemplateAdapter, +}; diff --git a/web/admin/src/permissions/index.js b/web/admin/src/permissions/index.js new file mode 100644 index 00000000..7ff67c96 --- /dev/null +++ b/web/admin/src/permissions/index.js @@ -0,0 +1,3 @@ +import { PermissionAdapter } from './lib'; + +window.PermissionAdapter = PermissionAdapter; diff --git a/web/admin/src/permissions/lib.js b/web/admin/src/permissions/lib.js new file mode 100644 index 00000000..766cc618 --- /dev/null +++ b/web/admin/src/permissions/lib.js @@ -0,0 +1,73 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * PermissionAdapter + */ + +class PermissionAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'user_level', + 'module_id', + 'permission', + 'value', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'User Level' }, + { sTitle: 'Module' }, + { sTitle: 'Permission' }, + { sTitle: 'Value' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['user_level', { label: 'User Level', type: 'placeholder', validation: 'none' }], + ['module_id', { label: 'Module', type: 'placeholder', 'remote-source': ['Module', 'id', 'menu+name'] }], + ['permission', { label: 'Permission', type: 'placeholder', validation: 'none' }], + ['value', { label: 'Value', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['module_id', { + label: 'Module', type: 'select2', 'allow-null': true, 'null-label': 'All Modules', 'remote-source': ['Module', 'id', 'menu+name'], + }], + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + getMetaFieldForRendering(fieldName) { + if (fieldName === 'value') { + return 'meta'; + } + return ''; + } + + + fillForm(object) { + super.fillForm(object); + $('#helptext').html(object.description); + } +} + +module.exports = { PermissionAdapter }; diff --git a/web/admin/src/projects/index.js b/web/admin/src/projects/index.js new file mode 100644 index 00000000..45f71baf --- /dev/null +++ b/web/admin/src/projects/index.js @@ -0,0 +1,9 @@ +import { + ClientAdapter, + ProjectAdapter, + EmployeeProjectAdapter, +} from './lib'; + +window.ClientAdapter = ClientAdapter; +window.ProjectAdapter = ProjectAdapter; +window.EmployeeProjectAdapter = EmployeeProjectAdapter; diff --git a/web/admin/src/projects/lib.js b/web/admin/src/projects/lib.js new file mode 100644 index 00000000..95139c63 --- /dev/null +++ b/web/admin/src/projects/lib.js @@ -0,0 +1,163 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * ClientAdapter + */ + +class ClientAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + 'address', + 'contact_number', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + { sTitle: 'Address' }, + { sTitle: 'Contact Number' }, + ]; + } + + getFormFields() { + if (this.showSave) { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['address', { label: 'Address', type: 'textarea', validation: 'none' }], + ['contact_number', { label: 'Contact Number', type: 'text', validation: 'none' }], + ['contact_email', { label: 'Contact Email', type: 'text', validation: 'none' }], + ['company_url', { label: 'Company Url', type: 'text', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive']] }], + ['first_contact_date', { label: 'First Contact Date', type: 'date', validation: 'none' }], + ]; + } + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'placeholder' }], + ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], + ['address', { label: 'Address', type: 'placeholder', validation: 'none' }], + ['contact_number', { label: 'Contact Number', type: 'placeholder', validation: 'none' }], + ['contact_email', { label: 'Contact Email', type: 'placeholder', validation: 'none' }], + ['company_url', { label: 'Company Url', type: 'placeholder', validation: 'none' }], + ['status', { label: 'Status', type: 'placeholder', source: [['Active', 'Active'], ['Inactive', 'Inactive']] }], + ['first_contact_date', { label: 'First Contact Date', type: 'placeholder', validation: 'none' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + + +/** + * ProjectAdapter + */ + +class ProjectAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'client', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Client' }, + ]; + } + + getFormFields() { + if (this.showSave) { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['client', { + label: 'Client', type: 'select2', 'allow-null': true, 'remote-source': ['Client', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['On Hold', 'On Hold'], ['Completed', 'Completed'], ['Dropped', 'Dropped']] }], + ]; + } + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'placeholder' }], + ['client', { + label: 'Client', type: 'placeholder', 'allow-null': true, 'remote-source': ['Client', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['On Hold', 'On Hold'], ['Completed', 'Completed'], ['Dropped', 'Dropped']] }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + + +/* + * EmployeeProjectAdapter + */ + + +class EmployeeProjectAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'project', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Project' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['project', { label: 'Project', type: 'select2', 'remote-source': ['Project', 'id', 'name'] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + +module.exports = { + ClientAdapter, + ProjectAdapter, + EmployeeProjectAdapter, +}; diff --git a/web/admin/src/qualifications/index.js b/web/admin/src/qualifications/index.js new file mode 100644 index 00000000..847ec6de --- /dev/null +++ b/web/admin/src/qualifications/index.js @@ -0,0 +1,11 @@ +import { + SkillAdapter, + EducationAdapter, + CertificationAdapter, + LanguageAdapter, +} from './lib'; + +window.SkillAdapter = SkillAdapter; +window.EducationAdapter = EducationAdapter; +window.CertificationAdapter = CertificationAdapter; +window.LanguageAdapter = LanguageAdapter; diff --git a/web/admin/src/qualifications/lib.js b/web/admin/src/qualifications/lib.js new file mode 100644 index 00000000..1984de49 --- /dev/null +++ b/web/admin/src/qualifications/lib.js @@ -0,0 +1,140 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SkillAdapter + */ + +class SkillAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/qualifications/'; + } +} + + +/** + * EducationAdapter + */ + +class EducationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +/** + * CertificationAdapter + */ + +class CertificationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +/** + * LanguageAdapter + */ + +class LanguageAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + +module.exports = { + SkillAdapter, + EducationAdapter, + CertificationAdapter, + LanguageAdapter, +}; diff --git a/web/admin/src/reports/index.js b/web/admin/src/reports/index.js new file mode 100644 index 00000000..4ef2b125 --- /dev/null +++ b/web/admin/src/reports/index.js @@ -0,0 +1,4 @@ +import { ReportAdapter, ReportGenAdapter } from './lib'; + +window.ReportAdapter = ReportAdapter; +window.ReportGenAdapter = ReportGenAdapter; diff --git a/web/admin/src/reports/lib.js b/web/admin/src/reports/lib.js new file mode 100644 index 00000000..b96fc8fa --- /dev/null +++ b/web/admin/src/reports/lib.js @@ -0,0 +1,372 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global SignaturePad, modJs */ +/* eslint-disable no-underscore-dangle */ + +import AdapterBase from '../../../api/AdapterBase'; + + +/** + * ReportAdapter + */ + + +class ReportAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this._construct(); + } + + _construct() { + this._formFileds = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'label', validation: '' }], + ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }], + ]; + this.remoteFieldsExists = false; + } + + _initLocalFormFields() { + this._formFileds = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'label', validation: '' }], + ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }], + ]; + } + + setRemoteFieldExists(val) { + this.remoteFieldsExists = val; + } + + getDataMapping() { + return [ + 'id', + 'icon', + 'name', + 'details', + 'parameters', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '', bSortable: false, sWidth: '22px' }, + { sTitle: 'Name', sWidth: '30%' }, + { sTitle: 'Details' }, + { sTitle: 'Parameters', bVisible: false }, + ]; + } + + + getFormFields() { + return this._formFileds; + } + + processFormFieldsWithObject(object) { + const that = this; + this._initLocalFormFields(); + const len = this._formFileds.length; + const fieldIDsToDelete = []; + const fieldsToDelete = []; + this.remoteFieldsExists = false; + for (let i = 0; i < len; i++) { + if (this._formFileds[i][1].type === 'fieldset') { + const newFields = JSON.parse(object[this._formFileds[i][0]]); + fieldsToDelete.push(this._formFileds[i][0]); + newFields.forEach((entry) => { + that._formFileds.push(entry); + if (entry[1]['remote-source'] !== undefined && entry[1]['remote-source'] != null) { + that.remoteFieldsExists = true; + } + }); + } + } + + const tempArray = []; + that._formFileds.forEach((entry) => { + if (jQuery.inArray(entry[0], fieldsToDelete) < 0) { + tempArray.push(entry); + } + }); + + that._formFileds = tempArray; + } + + + renderForm(object) { + const that = this; + this.processFormFieldsWithObject(object); + if (this.remoteFieldsExists) { + const cb = function () { + that.renderFormNew(object); + }; + this.initFieldMasterData(cb); + } else { + this.initFieldMasterData(); + that.renderFormNew(object); + } + + this.currentReport = object; + } + + renderFormNew(object) { + const that = this; + const signatureIds = []; + if (object == null || object === undefined) { + this.currentId = null; + } + + this.preRenderForm(object); + + let formHtml = this.templates.formTemplate; + let html = ''; + const fields = this.getFormFields(); + + for (let i = 0; i < fields.length; i++) { + const metaField = this.getMetaFieldForRendering(fields[i][0]); + if (metaField === '' || metaField === undefined) { + html += this.renderFormField(fields[i]); + } else { + const metaVal = object[metaField]; + if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { + html += this.renderFormField(JSON.parse(metaVal)); + } else { + html += this.renderFormField(fields[i]); + } + } + } + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_submit`); + formHtml = formHtml.replace(/_fields_/g, html); + + + let $tempDomObj; + const randomFormId = this.generateRandom(14); + if (!this.showFormOnPopup) { + $tempDomObj = $(`#${this.getTableName()}Form`); + } else { + $tempDomObj = $('
    '); + $tempDomObj.attr('id', randomFormId); + } + + $tempDomObj.html(formHtml); + + + $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false, + }); + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en', + }); + + $tempDomObj.find('.colorpick').colorpicker(); + + // $tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function () { + $(this).select2().select2('val', $(this).find('option:eq(0)').val()); + }); + + $tempDomObj.find('.select2Multi').each(function () { + $(this).select2().on('change', function (e) { + const parentRow = $(this).parents('.row'); + const height = parentRow.find('.select2-choices').height(); + parentRow.height(parseInt(height, 10)); + }); + }); + + + $tempDomObj.find('.signatureField').each(function () { + // $(this).data('signaturePad',new SignaturePad($(this))); + signatureIds.push($(this).attr('id')); + }); + + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'datagroup') { + $tempDomObj.find(`#${fields[i][0]}`).data('field', fields[i]); + } + } + + if (this.showSave === false) { + $tempDomObj.find('.saveBtn').remove(); + } else { + $tempDomObj.find('.saveBtn').off(); + $tempDomObj.find('.saveBtn').data('modJs', this); + $tempDomObj.find('.saveBtn').on('click', function () { + if ($(this).data('modJs').saveSuccessItemCallback != null && $(this).data('modJs').saveSuccessItemCallback !== undefined) { + $(this).data('modJs').save($(this).data('modJs').retriveItemsAfterSave(), $(this).data('modJs').saveSuccessItemCallback); + } else { + $(this).data('modJs').save(); + } + + return false; + }); + } + + if (this.showCancel === false) { + $tempDomObj.find('.cancelBtn').remove(); + } else { + $tempDomObj.find('.cancelBtn').off(); + $tempDomObj.find('.cancelBtn').data('modJs', this); + $tempDomObj.find('.cancelBtn').on('click', function () { + $(this).data('modJs').cancel(); + return false; + }); + } + + if (!this.showFormOnPopup) { + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object); + } + } else { + // var tHtml = $tempDomObj.wrap('
    ').parent().html(); + // this.showMessage("Edit",tHtml,null,null,true); + this.showMessage('Edit', '', null, null, true); + + $('#plainMessageModel .modal-body').html(''); + $('#plainMessageModel .modal-body').append($tempDomObj); + + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object, `#${randomFormId}`); + } + } + + this.postRenderForm(object, $tempDomObj); + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + addSuccessCallBack(callBackData, serverData) { + const fileName = serverData[0]; + let link; + + if (fileName.indexOf('https:') === 0) { + link = `Download Report `; + } else { + link = `Download Report `; + } + link = link.replace(/_BASE_/g, this.baseUrl); + + if (this.currentReport.output === 'PDF' || this.currentReport.output === 'JSON') { + this.showMessage('Download Report', link); + } else { + if (serverData[1].length === 0) { + this.showMessage('Empty Report', 'There were no data for selected filters'); + return; + } + + + const tableHtml = `${link}

    `; + + // Delete existing temp report table + $('#tempReportTable').remove(); + + // this.showMessage("Report",tableHtml); + + $(`#${this.table}`).html(tableHtml); + $(`#${this.table}`).show(); + $(`#${this.table}Form`).hide(); + + // Prepare headers + const headers = []; + for (const index in serverData[1]) { + headers.push({ sTitle: serverData[1][index] }); + } + + const data = serverData[2]; + + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + aaData: data, + aoColumns: headers, + bSort: false, + iDisplayLength: 15, + iDisplayStart: 0, + }; + + $('#tempReportTable').dataTable(dataTableParams); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + $('.tableActionButton').tooltip(); + } + } + + + fillForm(object) { + const fields = this.getFormFields(); + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'label') { + $(`#${this.getTableName()}Form #${fields[i][0]}`).html(object[fields[i][0]]); + } else { + $(`#${this.getTableName()}Form #${fields[i][0]}`).val(object[fields[i][0]]); + } + } + } +} + + +class ReportGenAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_name_/g, data[1]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +module.exports = { ReportAdapter, ReportGenAdapter }; diff --git a/web/admin/src/salary/index.js b/web/admin/src/salary/index.js new file mode 100644 index 00000000..08a5f45e --- /dev/null +++ b/web/admin/src/salary/index.js @@ -0,0 +1,9 @@ +import { + SalaryComponentTypeAdapter, + SalaryComponentAdapter, + EmployeeSalaryAdapter, +} from './lib'; + +window.SalaryComponentTypeAdapter = SalaryComponentTypeAdapter; +window.SalaryComponentAdapter = SalaryComponentAdapter; +window.EmployeeSalaryAdapter = EmployeeSalaryAdapter; diff --git a/web/admin/src/salary/lib.js b/web/admin/src/salary/lib.js new file mode 100644 index 00000000..e5ef5bb3 --- /dev/null +++ b/web/admin/src/salary/lib.js @@ -0,0 +1,120 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SalaryComponentTypeAdapter + */ + +class SalaryComponentTypeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * SalaryComponentAdapter + */ + +class SalaryComponentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'componentType', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Salary Component Type' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['componentType', { label: 'Salary Component Type', type: 'select2', 'remote-source': ['SalaryComponentType', 'id', 'name'] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * EmployeeSalaryAdapter + */ + +class EmployeeSalaryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'component', + 'amount', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Salary Component' }, + { sTitle: 'Amount' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['component', { label: 'Salary Component', type: 'select2', 'remote-source': ['SalaryComponent', 'id', 'name'] }], + ['amount', { label: 'Amount', type: 'text', validation: 'float' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } +} + +module.exports = { + SalaryComponentTypeAdapter, + SalaryComponentAdapter, + EmployeeSalaryAdapter, +}; diff --git a/web/admin/src/settings/index.js b/web/admin/src/settings/index.js new file mode 100644 index 00000000..831bcc73 --- /dev/null +++ b/web/admin/src/settings/index.js @@ -0,0 +1,3 @@ +import { SettingAdapter } from './lib'; + +window.SettingAdapter = SettingAdapter; diff --git a/web/admin/src/settings/lib.js b/web/admin/src/settings/lib.js new file mode 100644 index 00000000..31d19ea0 --- /dev/null +++ b/web/admin/src/settings/lib.js @@ -0,0 +1,109 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SettingAdapter + */ + +class SettingAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'value', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Value' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['value', { label: 'Value', type: 'text', validation: 'none' }], + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + getMetaFieldForRendering(fieldName) { + if (fieldName === 'value') { + return 'meta'; + } + return ''; + } + + edit(id) { + this.loadRemoteDataForSettings(); + super.edit(id); + } + + + fillForm(object) { + const metaField = this.getMetaFieldForRendering('value'); + const metaVal = object[metaField]; + let formFields = null; + + if (metaVal !== '' && metaVal !== undefined) { + formFields = [ + ['id', { label: 'ID', type: 'hidden' }], + JSON.parse(metaVal), + ]; + } + + super.fillForm(object, null, formFields); + $('#helptext').html(object.description); + } + + + loadRemoteDataForSettings() { + const fields = []; + let field = null; + fields.push(['country', { label: 'Country', type: 'select2multi', 'remote-source': ['Country', 'id', 'name'] }]); + fields.push(['countryCompany', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }]); + fields.push(['currency', { label: 'Currency', type: 'select2multi', 'remote-source': ['CurrencyType', 'id', 'code+name'] }]); + fields.push(['nationality', { label: 'Nationality', type: 'select2multi', 'remote-source': ['Nationality', 'id', 'name'] }]); + fields.push(['supportedLanguage', { + label: 'Value', type: 'select2', 'allow-null': false, 'remote-source': ['SupportedLanguage', 'name', 'description'], + }]); + + for (const index in fields) { + field = fields[index]; + if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] !== null) { + const key = `${field[1]['remote-source'][0]}_${field[1]['remote-source'][1]}_${field[1]['remote-source'][2]}`; + this.fieldMasterDataKeys[key] = false; + this.sourceMapping[field[0]] = field[1]['remote-source']; + + const callBackData = {}; + callBackData.callBack = 'initFieldMasterDataResponse'; + callBackData.callBackData = [key]; + + this.getFieldValues(field[1]['remote-source'], callBackData); + } + } + } + + + getHelpLink() { + return 'http://blog.icehrm.com/docs/settings/'; + } +} + +module.exports = { SettingAdapter }; diff --git a/web/admin/src/travel/index.js b/web/admin/src/travel/index.js new file mode 100644 index 00000000..6a4d434b --- /dev/null +++ b/web/admin/src/travel/index.js @@ -0,0 +1,11 @@ +import { + ImmigrationDocumentAdapter, + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdminAdapter, + CustomFieldAdapter, +} from './lib'; + +window.ImmigrationDocumentAdapter = ImmigrationDocumentAdapter; +window.EmployeeImmigrationAdapter = EmployeeImmigrationAdapter; +window.EmployeeTravelRecordAdminAdapter = EmployeeTravelRecordAdminAdapter; +window.CustomFieldAdapter = CustomFieldAdapter; diff --git a/web/admin/src/travel/lib.js b/web/admin/src/travel/lib.js new file mode 100644 index 00000000..ea62815d --- /dev/null +++ b/web/admin/src/travel/lib.js @@ -0,0 +1,195 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import CustomFieldAdapter from '../../../api/CustomFieldAdapter'; +import ApproveAdminAdapter from '../../../api/ApproveAdminAdapter'; + +/** + * ImmigrationDocumentAdapter + */ + +class ImmigrationDocumentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + 'required', + 'alert_on_missing', + 'alert_before_expiry', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + { sTitle: 'Compulsory' }, + { sTitle: 'Alert If Not Found' }, + { sTitle: 'Alert Before Expiry' }, + ]; + } + + getFormFields() { + const fields = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['required', { label: 'Compulsory', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_on_missing', { label: 'Alert If Not Found', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_before_expiry', { label: 'Alert Before Expiry', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_before_day_number', { label: 'Days for Expiry Alert', type: 'text', validation: '' }], + ]; + + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + return fields; + } +} + + +/** + * EmployeeImmigrationAdapter + */ + + +class EmployeeImmigrationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'documentname', + 'valid_until', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Document Id' }, + { sTitle: 'Valid Until' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['ImmigrationDocument', 'id', 'name'] }], + ['documentname', { label: 'Document Id', type: 'text', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment1', { label: 'Attachment 1', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment 2', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment 3', type: 'fileupload', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } +} + + +/** + * EmployeeTravelRecordAdminAdapter + */ + + +class EmployeeTravelRecordAdminAdapter extends ApproveAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'TravelRequest'; + this.itemNameLower = 'travelrequest'; + this.modulePathName = 'travel'; + } + + getDataMapping() { + return [ + 'id', + 'employee', + 'type', + 'purpose', + 'travel_from', + 'travel_to', + 'travel_date', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Travel Type' }, + { sTitle: 'Purpose' }, + { sTitle: 'From' }, + { sTitle: 'To' }, + { sTitle: 'Travel Date' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return this.addCustomFields([ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['type', { + label: 'Means of Transportation', + type: 'select', + source: [ + ['Plane', 'Plane'], + ['Rail', 'Rail'], + ['Taxi', 'Taxi'], + ['Own Vehicle', 'Own Vehicle'], + ['Rented Vehicle', 'Rented Vehicle'], + ['Other', 'Other'], + ], + }], + ['purpose', { label: 'Purpose of Travel', type: 'textarea', validation: '' }], + ['travel_from', { label: 'Travel From', type: 'text', validation: '' }], + ['travel_to', { label: 'Travel To', type: 'text', validation: '' }], + ['travel_date', { label: 'Travel Date', type: 'datetime', validation: '' }], + ['return_date', { label: 'Return Date', type: 'datetime', validation: '' }], + ['details', { label: 'Notes', type: 'textarea', validation: 'none' }], + ['currency', { + label: 'Currency', type: 'select2', 'allow-null': false, 'remote-source': ['CurrencyType', 'id', 'code'], + }], + ['funding', { + label: 'Total Funding Proposed', type: 'text', validation: 'float', default: '0.00', mask: '9{0,10}.99', + }], + ['attachment1', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]); + } +} + +module.exports = { + ImmigrationDocumentAdapter, + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdminAdapter, + CustomFieldAdapter, +}; diff --git a/web/admin/src/users/index.js b/web/admin/src/users/index.js new file mode 100644 index 00000000..8079bd20 --- /dev/null +++ b/web/admin/src/users/index.js @@ -0,0 +1,7 @@ +import { + UserAdapter, + UserRoleAdapter, +} from './lib'; + +window.UserAdapter = UserAdapter; +window.UserRoleAdapter = UserRoleAdapter; diff --git a/web/admin/src/users/lib.js b/web/admin/src/users/lib.js new file mode 100644 index 00000000..e113f181 --- /dev/null +++ b/web/admin/src/users/lib.js @@ -0,0 +1,201 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import FormValidation from '../../../api/FormValidation'; +import AdapterBase from '../../../api/AdapterBase'; + + +class UserAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'username', + 'email', + 'employee', + 'user_level', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'User Name' }, + { sTitle: 'Authentication Email' }, + { sTitle: 'Employee' }, + { sTitle: 'User Level' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['username', { label: 'User Name', type: 'text', validation: 'username' }], + ['email', { label: 'Email', type: 'text', validation: 'email' }], + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['user_level', { label: 'User Level', type: 'select', source: [['Admin', 'Admin'], ['Manager', 'Manager'], ['Employee', 'Employee'], ['Other', 'Other']] }], + ['user_roles', { label: 'User Roles', type: 'select2multi', 'remote-source': ['UserRole', 'id', 'name'] }], + ['lang', { + label: 'Language', type: 'select2', 'allow-null': true, 'remote-source': ['SupportedLanguage', 'id', 'description'], + }], + ['default_module', { + label: 'Default Module', type: 'select2', 'null-label': 'No Default Module', 'allow-null': true, 'remote-source': ['Module', 'id', 'menu+label'], + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object == null || object === undefined) { + $tempDomObj.find('#changePasswordBtn').remove(); + } + } + + changePassword() { + $('#adminUsersModel').modal('show'); + $('#adminUsersChangePwd #newpwd').val(''); + $('#adminUsersChangePwd #conpwd').val(''); + } + + saveUserSuccessCallBack(callBackData, serverData) { + const user = callBackData[0]; + if (callBackData[1]) { + this.showMessage('Create User', `An email has been sent to ${user.email} with a temporary password to login to IceHrm.`); + } else { + this.showMessage('Create User', 'User created successfully. But there was a problem sending welcome email.'); + } + this.get([]); + } + + saveUserFailCallBack(callBackData, serverData) { + this.showMessage('Error', callBackData); + } + + doCustomValidation(params) { + let msg = null; + if ((params.user_level !== 'Admin' && params.user_level !== 'Other') && params.employee === 'NULL') { + msg = 'For this user type, you have to assign an employee when adding or editing the user.
    '; + msg += " You may create a new employee through 'Admin'->'Employees' menu"; + } + return msg; + } + + save() { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const params = validator.getFormParameters(); + + const msg = this.doCustomValidation(params); + if (msg == null) { + const id = $(`#${this.getTableName()}_submit #id`).val(); + params.csrf = $(`#${this.getTableName()}Form`).data('csrf'); + if (id != null && id !== undefined && id !== '') { + params.id = id; + this.add(params, []); + } else { + const reqJson = JSON.stringify(params); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'saveUserSuccessCallBack'; + callBackData.callBackFail = 'saveUserFailCallBack'; + + this.customAction('saveUser', 'admin=users', reqJson, callBackData); + } + } else { + // $("#"+this.getTableName()+'Form .label').html(msg); + // $("#"+this.getTableName()+'Form .label').show(); + this.showMessage('Error Saving User', msg); + } + } + } + + + changePasswordConfirm() { + $('#adminUsersChangePwd_error').hide(); + + const passwordValidation = function (str) { + return str.length > 7; + }; + + const password = $('#adminUsersChangePwd #newpwd').val(); + + if (!passwordValidation(password)) { + $('#adminUsersChangePwd_error').html('Password should be longer than 7 characters'); + $('#adminUsersChangePwd_error').show(); + return; + } + + const conPassword = $('#adminUsersChangePwd #conpwd').val(); + + if (conPassword !== password) { + $('#adminUsersChangePwd_error').html("Passwords don't match"); + $('#adminUsersChangePwd_error').show(); + return; + } + + const req = { id: this.currentId, pwd: conPassword }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'changePasswordSuccessCallBack'; + callBackData.callBackFail = 'changePasswordFailCallBack'; + + this.customAction('changePassword', 'admin=users', reqJson, callBackData); + } + + closeChangePassword() { + $('#adminUsersModel').modal('hide'); + } + + changePasswordSuccessCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Password Change', 'Password changed successfully'); + } + + changePasswordFailCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Error', callBackData); + } +} + + +/** + * UserRoleAdapter + */ + +class UserRoleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + + postRenderForm(object, $tempDomObj) { + $tempDomObj.find('#changePasswordBtn').remove(); + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + +module.exports = { + UserAdapter, + UserRoleAdapter, +}; diff --git a/web/admin/travel/lib.js b/web/admin/travel/lib.js deleted file mode 100644 index 22a90339..00000000 --- a/web/admin/travel/lib.js +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * ImmigrationDocumentAdapter - */ - -function ImmigrationDocumentAdapter(endPoint) { - this.initAdapter(endPoint); -} - -ImmigrationDocumentAdapter.inherits(AdapterBase); - - - -ImmigrationDocumentAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "details", - "required", - "alert_on_missing", - "alert_before_expiry" - ]; -}); - -ImmigrationDocumentAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Details"}, - { "sTitle": "Compulsory"}, - { "sTitle": "Alert If Not Found"}, - { "sTitle": "Alert Before Expiry"} - ]; -}); - -ImmigrationDocumentAdapter.method('getFormFields', function() { - var fields = [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "required", {"label":"Compulsory","type":"select","source":[["No","No"],["Yes","Yes"]]}], - [ "alert_on_missing", {"label":"Alert If Not Found","type":"select","source":[["No","No"],["Yes","Yes"]]}], - [ "alert_before_expiry", {"label":"Alert Before Expiry","type":"select","source":[["No","No"],["Yes","Yes"]]}], - [ "alert_before_day_number", {"label":"Days for Expiry Alert","type":"text","validation":""}] - ]; - - for(var i=0;i 7; - }; - - var password = $('#adminUsersChangePwd #newpwd').val(); - - if(!passwordValidation(password)){ - $('#adminUsersChangePwd_error').html("Password should be longer than 7 characters"); - $('#adminUsersChangePwd_error').show(); - return; - } - - var conPassword = $('#adminUsersChangePwd #conpwd').val(); - - if(conPassword != password){ - $('#adminUsersChangePwd_error').html("Passwords don't match"); - $('#adminUsersChangePwd_error').show(); - return; - } - - var req = {"id":this.currentId,"pwd":conPassword}; - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'changePasswordSuccessCallBack'; - callBackData['callBackFail'] = 'changePasswordFailCallBack'; - - this.customAction('changePassword','admin=users',reqJson,callBackData); - -}); - -UserAdapter.method('closeChangePassword', function() { - $('#adminUsersModel').modal('hide'); -}); - -UserAdapter.method('changePasswordSuccessCallBack', function(callBackData,serverData) { - this.closeChangePassword(); - this.showMessage("Password Change","Password changed successfully"); -}); - -UserAdapter.method('changePasswordFailCallBack', function(callBackData,serverData) { - this.closeChangePassword(); - this.showMessage("Error",callBackData); -}); - - - - - -/** - * UserRoleAdapter - */ - -function UserRoleAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -UserRoleAdapter.inherits(AdapterBase); - - - -UserRoleAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -UserRoleAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name"} - ]; -}); - - -UserRoleAdapter.method('postRenderForm', function(object, $tempDomObj) { - $tempDomObj.find("#changePasswordBtn").remove(); -}); - -UserRoleAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); diff --git a/web/api-common/Aes.js b/web/api-common/Aes.js new file mode 100644 index 00000000..22d22872 --- /dev/null +++ b/web/api-common/Aes.js @@ -0,0 +1,497 @@ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* AES implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* jshint node:true *//* global define */ + + +/** + * AES (Rijndael cipher) encryption routines, + * + * Reference implementation of FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. + * + * @namespace + */ +var Aes = {}; + + +/** + * AES Cipher function: encrypt 'input' state with Rijndael algorithm [§5.1]; + * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage. + * + * @param {number[]} input - 16-byte (128-bit) input state array. + * @param {number[][]} w - Key schedule as 2D byte-array (Nr+1 x Nb bytes). + * @returns {number[]} Encrypted output state array. + */ +Aes.cipher = function (input, w) { + const Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) + const Nr = w.length / Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys + + let state = [[], [], [], []]; // initialise 4xNb byte-array 'state' with input [§3.4] + for (var i = 0; i < 4 * Nb; i++) state[i % 4][Math.floor(i / 4)] = input[i]; + + state = Aes.addRoundKey(state, w, 0, Nb); + + for (let round = 1; round < Nr; round++) { + state = Aes.subBytes(state, Nb); + state = Aes.shiftRows(state, Nb); + state = Aes.mixColumns(state, Nb); + state = Aes.addRoundKey(state, w, round, Nb); + } + + state = Aes.subBytes(state, Nb); + state = Aes.shiftRows(state, Nb); + state = Aes.addRoundKey(state, w, Nr, Nb); + + const output = new Array(4 * Nb); // convert state to 1-d array before returning [§3.4] + for (var i = 0; i < 4 * Nb; i++) output[i] = state[i % 4][Math.floor(i / 4)]; + + return output; +}; + + +/** + * Perform key expansion to generate a key schedule from a cipher key [§5.2]. + * + * @param {number[]} key - Cipher key as 16/24/32-byte array. + * @returns {number[][]} Expanded key schedule as 2D byte-array (Nr+1 x Nb bytes). + */ +Aes.keyExpansion = function (key) { + const Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) + const Nk = key.length / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys + const Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys + + const w = new Array(Nb * (Nr + 1)); + let temp = new Array(4); + + // initialise first Nk words of expanded key with cipher key + for (var i = 0; i < Nk; i++) { + const r = [key[4 * i], key[4 * i + 1], key[4 * i + 2], key[4 * i + 3]]; + w[i] = r; + } + + // expand the key into the remainder of the schedule + for (var i = Nk; i < (Nb * (Nr + 1)); i++) { + w[i] = new Array(4); + for (var t = 0; t < 4; t++) temp[t] = w[i - 1][t]; + // each Nk'th word has extra transformation + if (i % Nk == 0) { + temp = Aes.subWord(Aes.rotWord(temp)); + for (var t = 0; t < 4; t++) temp[t] ^= Aes.rCon[i / Nk][t]; + } + // 256-bit key has subWord applied every 4th word + else if (Nk > 6 && i % Nk == 4) { + temp = Aes.subWord(temp); + } + // xor w[i] with w[i-1] and w[i-Nk] + for (var t = 0; t < 4; t++) w[i][t] = w[i - Nk][t] ^ temp[t]; + } + + return w; +}; + + +/** + * Apply SBox to state S [§5.1.1] + * @private + */ +Aes.subBytes = function (s, Nb) { + for (let r = 0; r < 4; r++) { + for (let c = 0; c < Nb; c++) s[r][c] = Aes.sBox[s[r][c]]; + } + return s; +}; + + +/** + * Shift row r of state S left by r bytes [§5.1.2] + * @private + */ +Aes.shiftRows = function (s, Nb) { + const t = new Array(4); + for (let r = 1; r < 4; r++) { + for (var c = 0; c < 4; c++) t[c] = s[r][(c + r) % Nb]; // shift into temp copy + for (var c = 0; c < 4; c++) s[r][c] = t[c]; // and copy back + } // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES): + return s; // see asmaes.sourceforge.net/rijndael/rijndaelImplementation.pdf +}; + + +/** + * Combine bytes of each col of state S [§5.1.3] + * @private + */ +Aes.mixColumns = function (s, Nb) { + for (let c = 0; c < 4; c++) { + const a = new Array(4); // 'a' is a copy of the current column from 's' + const b = new Array(4); // 'b' is a•{02} in GF(2^8) + for (let i = 0; i < 4; i++) { + a[i] = s[i][c]; + b[i] = s[i][c] & 0x80 ? s[i][c] << 1 ^ 0x011b : s[i][c] << 1; + } + // a[n] ^ b[n] is a•{03} in GF(2^8) + s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // {02}•a0 + {03}•a1 + a2 + a3 + s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 • {02}•a1 + {03}•a2 + a3 + s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + {02}•a2 + {03}•a3 + s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // {03}•a0 + a1 + a2 + {02}•a3 + } + return s; +}; + + +/** + * Xor Round Key into state S [§5.1.4] + * @private + */ +Aes.addRoundKey = function (state, w, rnd, Nb) { + for (let r = 0; r < 4; r++) { + for (let c = 0; c < Nb; c++) state[r][c] ^= w[rnd * 4 + c][r]; + } + return state; +}; + + +/** + * Apply SBox to 4-byte word w + * @private + */ +Aes.subWord = function (w) { + for (let i = 0; i < 4; i++) w[i] = Aes.sBox[w[i]]; + return w; +}; + + +/** + * Rotate 4-byte word w left by one byte + * @private + */ +Aes.rotWord = function (w) { + const tmp = w[0]; + for (let i = 0; i < 3; i++) w[i] = w[i + 1]; + w[3] = tmp; + return w; +}; + + +// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [§5.1.1] +Aes.sBox = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + + +// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2] +Aes.rCon = [[0x00, 0x00, 0x00, 0x00], + [0x01, 0x00, 0x00, 0x00], + [0x02, 0x00, 0x00, 0x00], + [0x04, 0x00, 0x00, 0x00], + [0x08, 0x00, 0x00, 0x00], + [0x10, 0x00, 0x00, 0x00], + [0x20, 0x00, 0x00, 0x00], + [0x40, 0x00, 0x00, 0x00], + [0x80, 0x00, 0x00, 0x00], + [0x1b, 0x00, 0x00, 0x00], + [0x36, 0x00, 0x00, 0x00]]; + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +if (typeof module !== 'undefined' && module.exports) module.exports = Aes; // CommonJs export +if (typeof define === 'function' && define.amd) define([], () => Aes); // AMD + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* AES Counter-mode implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* jshint node:true *//* global define, escape, unescape, btoa, atob */ +'use strict'; +if (typeof module !== 'undefined' && module.exports) var Aes = require('./aes'); // CommonJS (Node.js) + + +/** + * Aes.Ctr: Counter-mode (CTR) wrapper for AES. + * + * This encrypts a Unicode string to produces a base64 ciphertext using 128/192/256-bit AES, + * and the converse to decrypt an encrypted ciphertext. + * + * See http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf + * + * @augments Aes + */ +Aes.Ctr = {}; + + +/** + * Encrypt a text using AES encryption in Counter mode of operation. + * + * Unicode multi-byte character safe + * + * @param {string} plaintext - Source text to be encrypted. + * @param {string} password - The password to use to generate a key. + * @param {number} nBits - Number of bits to be used in the key; 128 / 192 / 256. + * @returns {string} Encrypted text. + * + * @example + * var encr = Aes.Ctr.encrypt('big secret', 'pāşšŵōřđ', 256); // encr: 'lwGl66VVwVObKIr6of8HVqJr' + */ +Aes.Ctr.encrypt = function (plaintext, password, nBits) { + const blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!(nBits == 128 || nBits == 192 || nBits == 256)) return ''; // standard allows 128/192/256 bit keys + plaintext = String(plaintext).utf8Encode(); + password = String(password).utf8Encode(); + + // use AES itself to encrypt password to get cipher key (using plain password as source for key + // expansion) - gives us well encrypted key (though hashed key might be preferred for prod'n use) + const nBytes = nBits / 8; // no bytes in key (16/24/32) + const pwBytes = new Array(nBytes); + for (var i = 0; i < nBytes; i++) { // use 1st 16/24/32 chars of password for key + pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i); + } + let key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes)); // gives us 16-byte key + key = key.concat(key.slice(0, nBytes - 16)); // expand key to 16/24/32 bytes long + + // initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A §B.2): [0-1] = millisec, + // [2-3] = random, [4-7] = seconds, together giving full sub-millisec uniqueness up to Feb 2106 + const counterBlock = new Array(blockSize); + + const nonce = (new Date()).getTime(); // timestamp: milliseconds since 1-Jan-1970 + const nonceMs = nonce % 1000; + const nonceSec = Math.floor(nonce / 1000); + const nonceRnd = Math.floor(Math.random() * 0xffff); + // for debugging: nonce = nonceMs = nonceSec = nonceRnd = 0; + + for (var i = 0; i < 2; i++) counterBlock[i] = (nonceMs >>> i * 8) & 0xff; + for (var i = 0; i < 2; i++) counterBlock[i + 2] = (nonceRnd >>> i * 8) & 0xff; + for (var i = 0; i < 4; i++) counterBlock[i + 4] = (nonceSec >>> i * 8) & 0xff; + + // and convert it to a string to go on the front of the ciphertext + let ctrTxt = ''; + for (var i = 0; i < 8; i++) ctrTxt += String.fromCharCode(counterBlock[i]); + + // generate key schedule - an expansion of the key into distinct Key Rounds for each round + const keySchedule = Aes.keyExpansion(key); + + const blockCount = Math.ceil(plaintext.length / blockSize); + const ciphertxt = new Array(blockCount); // ciphertext as array of strings + + for (let b = 0; b < blockCount; b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) + for (var c = 0; c < 4; c++) counterBlock[15 - c] = (b >>> c * 8) & 0xff; + for (var c = 0; c < 4; c++) counterBlock[15 - c - 4] = (b / 0x100000000 >>> c * 8); + + const cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block -- + + // block size is reduced on final block + const blockLength = b < blockCount - 1 ? blockSize : (plaintext.length - 1) % blockSize + 1; + const cipherChar = new Array(blockLength); + + for (var i = 0; i < blockLength; i++) { // -- xor plaintext with ciphered counter char-by-char -- + cipherChar[i] = cipherCntr[i] ^ plaintext.charCodeAt(b * blockSize + i); + cipherChar[i] = String.fromCharCode(cipherChar[i]); + } + ciphertxt[b] = cipherChar.join(''); + } + + // use Array.join() for better performance than repeated string appends + let ciphertext = ctrTxt + ciphertxt.join(''); + ciphertext = ciphertext.base64Encode(); + + return ciphertext; +}; + + +/** + * Decrypt a text encrypted by AES in counter mode of operation + * + * @param {string} ciphertext - Source text to be encrypted. + * @param {string} password - Password to use to generate a key. + * @param {number} nBits - Number of bits to be used in the key; 128 / 192 / 256. + * @returns {string} Decrypted text + * + * @example + * var decr = Aes.Ctr.encrypt('lwGl66VVwVObKIr6of8HVqJr', 'pāşšŵōřđ', 256); // decr: 'big secret' + */ +Aes.Ctr.decrypt = function (ciphertext, password, nBits) { + const blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!(nBits == 128 || nBits == 192 || nBits == 256)) return ''; // standard allows 128/192/256 bit keys + ciphertext = String(ciphertext).base64Decode(); + password = String(password).utf8Encode(); + + // use AES to encrypt password (mirroring encrypt routine) + const nBytes = nBits / 8; // no bytes in key + const pwBytes = new Array(nBytes); + for (var i = 0; i < nBytes; i++) { + pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i); + } + let key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes)); + key = key.concat(key.slice(0, nBytes - 16)); // expand key to 16/24/32 bytes long + + // recover nonce from 1st 8 bytes of ciphertext + const counterBlock = new Array(8); + const ctrTxt = ciphertext.slice(0, 8); + for (var i = 0; i < 8; i++) counterBlock[i] = ctrTxt.charCodeAt(i); + + // generate key schedule + const keySchedule = Aes.keyExpansion(key); + + // separate ciphertext into blocks (skipping past initial 8 bytes) + const nBlocks = Math.ceil((ciphertext.length - 8) / blockSize); + const ct = new Array(nBlocks); + for (var b = 0; b < nBlocks; b++) ct[b] = ciphertext.slice(8 + b * blockSize, 8 + b * blockSize + blockSize); + ciphertext = ct; // ciphertext is now array of block-length strings + + // plaintext will get generated block-by-block into array of block-length strings + const plaintxt = new Array(ciphertext.length); + + for (var b = 0; b < nBlocks; b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + for (var c = 0; c < 4; c++) counterBlock[15 - c] = ((b) >>> c * 8) & 0xff; + for (var c = 0; c < 4; c++) counterBlock[15 - c - 4] = (((b + 1) / 0x100000000 - 1) >>> c * 8) & 0xff; + + const cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block + + const plaintxtByte = new Array(ciphertext[b].length); + for (var i = 0; i < ciphertext[b].length; i++) { + // -- xor plaintxt with ciphered counter byte-by-byte -- + plaintxtByte[i] = cipherCntr[i] ^ ciphertext[b].charCodeAt(i); + plaintxtByte[i] = String.fromCharCode(plaintxtByte[i]); + } + plaintxt[b] = plaintxtByte.join(''); + } + + // join array of blocks into single plaintext string + let plaintext = plaintxt.join(''); + plaintext = plaintext.utf8Decode(); // decode from UTF8 back to Unicode multi-byte chars + + return plaintext; +}; + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + +/** Extend String object with method to encode multi-byte string to utf8 + * - monsur.hossa.in/2012/07/20/utf-8-in-javascript.html */ +if (typeof String.prototype.utf8Encode === 'undefined') { + String.prototype.utf8Encode = function () { + return unescape(encodeURIComponent(this)); + }; +} + +/** Extend String object with method to decode utf8 string to multi-byte */ +if (typeof String.prototype.utf8Decode === 'undefined') { + String.prototype.utf8Decode = function () { + try { + return decodeURIComponent(escape(this)); + } catch (e) { + return this; // invalid UTF-8? return as-is + } + }; +} + + +/** Extend String object with method to encode base64 + * - developer.mozilla.org/en-US/docs/Web/API/window.btoa, nodejs.org/api/buffer.html + * note: if btoa()/atob() are not available (eg IE9-), try github.com/davidchambers/Base64.js */ +if (typeof String.prototype.base64Encode === 'undefined') { + String.prototype.base64Encode = function () { + if (typeof btoa !== 'undefined') return btoa(this); // browser + if (typeof Buffer !== 'undefined') return new Buffer(this, 'utf8').toString('base64'); // Node.js + throw new Error('No Base64 Encode'); + }; +} + +/** Extend String object with method to decode base64 */ +if (typeof String.prototype.base64Decode === 'undefined') { + String.prototype.base64Decode = function () { + if (typeof atob !== 'undefined') return atob(this); // browser + if (typeof Buffer !== 'undefined') return new Buffer(this, 'base64').toString('utf8'); // Node.js + throw new Error('No Base64 Decode'); + }; +} + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +if (typeof module !== 'undefined' && module.exports) module.exports = Aes.Ctr; // CommonJs export +if (typeof define === 'function' && define.amd) define(['Aes'], () => Aes.Ctr); // AMD + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* Encrypt/decrypt files */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +function encryptFile(file) { + // use FileReader.readAsArrayBuffer to handle binary files + const reader = new FileReader(); + reader.readAsArrayBuffer(file); + reader.onload = function (evt) { + $('body').css({ cursor: 'wait' }); + + // Aes.Ctr.encrypt expects a string, but converting binary file directly to string could + // give invalid Unicode sequences, so convert bytestream ArrayBuffer to single-byte chars + const contentBytes = new Uint8Array(reader.result); // ≡ evt.target.result + let contentStr = ''; + for (let i = 0; i < contentBytes.length; i++) { + contentStr += String.fromCharCode(contentBytes[i]); + } + + const password = $('#password-file').val(); + + const t1 = new Date(); + const ciphertext = Aes.Ctr.encrypt(contentStr, password, 256); + const t2 = new Date(); + + // use Blob to save encrypted file + const blob = new Blob([ciphertext], { type: 'text/plain' }); + const filename = `${file.name}.encrypted`; + saveAs(blob, filename); + + $('#encrypt-file-time').html(`${(t2 - t1) / 1000}s`); // display time taken + $('body').css({ cursor: 'default' }); + }; +} + +function decryptFile(file) { + // use FileReader.ReadAsText to read (base64-encoded) ciphertext file + const reader = new FileReader(); + reader.readAsText(file); + reader.onload = function (evt) { + $('body').css({ cursor: 'wait' }); + + const content = reader.result; // ≡ evt.target.result + const password = $('#password-file').val(); + + const t1 = new Date(); + const plaintext = Aes.Ctr.decrypt(content, password, 256); + const t2 = new Date(); + + // convert single-byte character stream to ArrayBuffer bytestream + const contentBytes = new Uint8Array(plaintext.length); + for (let i = 0; i < plaintext.length; i++) { + contentBytes[i] = plaintext.charCodeAt(i); + } + + // use Blob to save decrypted file + const blob = new Blob([contentBytes], { type: 'application/octet-stream' }); + const filename = `${file.name.replace(/\.encrypted$/, '')}.decrypted`; + saveAs(blob, filename); + + $('#decrypt-file-time').html(`${(t2 - t1) / 1000}s`); // display time taken + $('body').css({ cursor: 'default' }); + }; +} + +export default Aes; diff --git a/web/api-common/Notifications.js b/web/api-common/Notifications.js new file mode 100644 index 00000000..1bdf5994 --- /dev/null +++ b/web/api-common/Notifications.js @@ -0,0 +1,124 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +class NotificationManager { + constructor() { + this.baseUrl = ''; + this.templates = {}; + } + + setBaseUrl(url) { + this.baseUrl = url; + } + + setTemplates(data) { + this.templates = data; + } + + setTimeUtils(timeUtils) { + this.timeUtils = timeUtils; + } + + getNotifications(name, data) { + const that = this; + $.getJSON(this.baseUrl, { a: 'getNotifications' }, (_data) => { + if (_data.status === 'SUCCESS') { + that.renderNotifications(_data.data[1], _data.data[0]); + } + }); + } + + clearPendingNotifications(name, data) { + const that = this; + $.getJSON(this.baseUrl, { a: 'clearNotifications' }, (_data) => { + + }); + } + + renderNotifications(notifications, unreadCount) { + if (notifications.length === 0) { + return; + } + + let t = this.templates.notifications; + if (unreadCount > 0) { + t = t.replace('#_count_#', unreadCount); + if (unreadCount > 1) { + t = t.replace('#_header_#', `You have ${unreadCount} new notifications`); + } else { + t = t.replace('#_header_#', `You have ${unreadCount} new notification`); + } + } else { + t = t.replace('#_count_#', ''); + t = t.replace('#_header_#', 'You have no new notifications'); + } + + let notificationStr = ''; + + for (const index in notifications) { + notificationStr += this.renderNotification(notifications[index]); + } + + t = t.replace('#_notifications_#', notificationStr); + + const $obj = $(t); + + if (unreadCount === 0) { + $obj.find('.label-danger').remove(); + } + + $obj.attr('id', 'notifications'); + const k = $('#notifications'); + k.replaceWith($obj); + + $('.navbar .menu').slimscroll({ + height: '320px', + alwaysVisible: false, + size: '3px', + }).css('width', '100%'); + + this.timeUtils.convertToRelativeTime($('.notificationTime')); + } + + + renderNotification(notification) { + let t = this.templates.notification; + t = t.replace('#_image_#', notification.image); + + try { + const json = JSON.parse(notification.action); + t = t.replace('#_url_#', this.baseUrl.replace('service.php', '?') + json.url); + } catch (e) { + t = t.replace('#_url_#', ''); + } + + t = t.replace('#_time_#', notification.time); + t = t.replace('#_fromName_#', notification.type); + t = t.replace('#_message_#', this.getLineBreakString(notification.message, 27)); + return t; + } + + + getLineBreakString(str, len) { + let t = ''; + try { + const arr = str.split(' '); + let count = 0; + for (let i = 0; i < arr.length; i++) { + count += arr[i].length + 1; + if (count > len) { + t += `${arr[i]}
    `; + count = 0; + } else { + t += `${arr[i]} `; + } + } + } catch (e) { + // Do nothing + } + return t; + } +} + +export default NotificationManager; diff --git a/web/api-common/RequestCache.js b/web/api-common/RequestCache.js new file mode 100644 index 00000000..961e5030 --- /dev/null +++ b/web/api-common/RequestCache.js @@ -0,0 +1,69 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/** + * RequestCache + */ + +class RequestCache { + getKey(url, params) { + let key = `${url}|`; + for (const index in params) { + key += `${index}=${params[index]}|`; + } + return key; + } + + invalidateTable(table) { + let key; + for (let i = 0; i < localStorage.length; i++) { + key = localStorage.key(i); + if (key.indexOf(`t=${table}`) > 0) { + localStorage.removeItem(key); + } + } + } + + + getData(key) { + let data; + + if (typeof (Storage) === 'undefined') { + return null; + } + + const strData = localStorage.getItem(key); + if (strData !== undefined && strData != null && strData !== '') { + data = JSON.parse(strData); + if (data === undefined || data == null) { + return null; + } + + if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') { + return null; + } + + return data; + } + + return null; + } + + setData(key, data) { + if (typeof (Storage) === 'undefined') { + return null; + } + + if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') { + return null; + } + + const strData = JSON.stringify(data); + localStorage.setItem(key, strData); + return strData; + } +} + +export default RequestCache; diff --git a/web/api-common/TimeUtils.js b/web/api-common/TimeUtils.js new file mode 100644 index 00000000..7f432d74 --- /dev/null +++ b/web/api-common/TimeUtils.js @@ -0,0 +1,143 @@ +/* eslint-disable camelcase,brace-style */ + +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +class TimeUtils { + setServerGMToffset(serverGMToffset) { + this.serverGMToffset = serverGMToffset; + } + + getMySQLFormatDate(date) { + const format = function (val) { + if (val < 10) { return `0${val}`; } + return val; + }; + + return `${date.getUTCFullYear()}-${format(date.getUTCMonth() + 1)}-${format(date.getUTCDate())}`; + } + + convertToRelativeTime(selector) { + const that = this; + + const getAmPmTime = function (curHour, curMin) { + let amPm = 'am'; + let amPmHour = curHour; + if (amPmHour >= 12) { + amPm = 'pm'; + if (amPmHour > 12) { + amPmHour -= 12; + } + } + let prefixCurMin = ''; + if (curMin < 10) { + prefixCurMin = '0'; + } + + let prefixCurHour = ''; + if (curHour === 0) { + prefixCurHour = '0'; + } + return ` at ${prefixCurHour}${amPmHour}:${prefixCurMin}${curMin}${amPm}`; + }; + + const getBrowserTimeZone = function () { + const current_date = new Date(); + const gmt_offset = current_date.getTimezoneOffset() / 60; + return -gmt_offset; + }; + + const curDate = new Date(); + const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; + const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + + + const timezoneDiff = this.serverGMToffset - getBrowserTimeZone(); + const timezoneTimeDiff = timezoneDiff * 60 * 60 * 1000; + + + selector.each(function () { + try { + const thisValue = $(this).html(); + // Split value into date and time + const thisValueArray = thisValue.split(' '); + const thisValueDate = thisValueArray[0]; + const thisValueTime = thisValueArray[1]; + + // Split date into components + const thisValueDateArray = thisValueDate.split('-'); + const curYear = thisValueDateArray[0]; + const curMonth = thisValueDateArray[1] - 1; + const curDay = thisValueDateArray[2]; + + // Split time into components + const thisValueTimeArray = thisValueTime.split(':'); + const curHour = thisValueTimeArray[0]; + const curMin = thisValueTimeArray[1]; + const curSec = thisValueTimeArray[2]; + + // Create this date + const thisDate = new Date(curYear, curMonth, curDay, curHour, curMin, curSec); + const thisTime = thisDate.getTime(); + const tzDate = new Date(thisTime - timezoneTimeDiff); + // var tzDay = tzDate.getDay();//getDay will return the day of the week not the month + // var tzDay = tzDate.getUTCDate(); //getUTCDate will return the day of the month + const tzDay = tzDate.toString('d'); // + const tzYear = tzDate.getFullYear(); + const tzHour = tzDate.getHours(); + const tzMin = tzDate.getMinutes(); + + // Create the full date + // var fullDate = days[tzDate.getDay()] + ", " + months[tzDate.getMonth()] + " " + tzDay + ", " + tzYear + getAmPmTime(tzHour, tzMin); + const fullDate = `${days[tzDate.getDay()]}, ${months[tzDate.getMonth()]} ${tzDay}, ${tzYear}${getAmPmTime(tzHour, tzMin)}`; + + // Get the time different + const timeDiff = (curDate.getTime() - tzDate.getTime()) / 1000; + const minDiff = Math.abs(timeDiff / 60); + const hourDiff = Math.abs(timeDiff / (60 * 60)); + const dayDiff = Math.abs(timeDiff / (60 * 60 * 24)); + const yearDiff = Math.abs(timeDiff / (60 * 60 * 24 * 365)); + + // If more than a day old, display the month, day and time (and year, if applicable) + let fbDate = ''; + if (dayDiff > 1) { + // fbDate = curDay + " " + months[tzDate.getMonth()].substring(0,3); + fbDate = `${tzDay} ${months[tzDate.getMonth()].substring(0, 3)}`; + // Add the year, if applicable + if (yearDiff > 1) { + fbDate = `${fbDate} ${curYear}`; + } + + // Add the time + fbDate += getAmPmTime(tzHour, tzMin); + } + // Less than a day old, and more than an hour old + else if (hourDiff >= 1) { + const roundedHour = Math.round(hourDiff); + if (roundedHour === 1) fbDate = 'about an hour ago'; + else fbDate = `${roundedHour} hours ago`; + } + // Less than an hour, and more than a minute + else if (minDiff >= 1) { + const roundedMin = Math.round(minDiff); + if (roundedMin === 1) fbDate = 'about a minute ago'; + else fbDate = `${roundedMin} minutes ago`; + } + // Less than a minute + else if (minDiff < 1) { + fbDate = 'less than a minute ago'; + } + + // Update this element + $(this).html(fbDate); + $(this).attr('title', fullDate); + } catch (e) { + // Do nothing + } + }); + } +} + +export default TimeUtils; diff --git a/web/js/app-global.js b/web/api-common/app-global.js similarity index 100% rename from web/js/app-global.js rename to web/api-common/app-global.js diff --git a/web/themejs/plugins/datatables/dataTables.bootstrap.js b/web/api-common/datatables/dataTables.bootstrap.js similarity index 100% rename from web/themejs/plugins/datatables/dataTables.bootstrap.js rename to web/api-common/datatables/dataTables.bootstrap.js diff --git a/web/themejs/plugins/datatables/jquery.dataTables.js b/web/api-common/datatables/jquery.dataTables.js similarity index 99% rename from web/themejs/plugins/datatables/jquery.dataTables.js rename to web/api-common/datatables/jquery.dataTables.js index 0762a0c7..0d7e3748 100644 --- a/web/themejs/plugins/datatables/jquery.dataTables.js +++ b/web/api-common/datatables/jquery.dataTables.js @@ -172,12 +172,14 @@ /* Cache the data get and set functions for speed */ var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null; var mData = _fnGetObjectDataFn( oCol.mData ); - + var headers = modJs.getHeaders(); oCol.fnGetData = function (oData, sSpecific) { var modData = []; for (var index in oData) { - if (oData.hasOwnProperty(index)) { + if (oData.hasOwnProperty(index) && headers[index] && headers[index]['translate']) { modData[index] = modJs.gt(oData[index]); + } else { + modData[index] = oData[index]; } } var innerData = mData( modData, sSpecific ); diff --git a/web/api-common/entry.js b/web/api-common/entry.js new file mode 100644 index 00000000..47f23d58 --- /dev/null +++ b/web/api-common/entry.js @@ -0,0 +1,28 @@ +/* global timeUtils */ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import NotificationManager from './Notifications'; +import TimeUtils from './TimeUtils'; + +import RequestCache from './RequestCache'; + +const Aes = require('./Aes'); + +window.RequestCache = RequestCache; + +window.setupTimeUtils = (diffHoursBetweenServerTimezoneWithGMT) => { + const timeUtils = new TimeUtils(); + timeUtils.setServerGMToffset(diffHoursBetweenServerTimezoneWithGMT); + + return timeUtils; +}; + +window.setupNotifications = (baseUrl) => { + const notificationManager = new NotificationManager(); + notificationManager.setBaseUrl(baseUrl); + notificationManager.setTimeUtils(timeUtils); + + return notificationManager; +}; diff --git a/web/api/AdapterBase.js b/web/api/AdapterBase.js index 88418058..66ca0ca8 100644 --- a/web/api/AdapterBase.js +++ b/web/api/AdapterBase.js @@ -1,1557 +1,465 @@ +/* global baseUrl, clientUrl */ /* - This file is part of Ice Framework. - - Ice Framework is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Ice Framework is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Ice Framework. If not, see . - - ------------------------------------------------------------------ - - Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] - Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ - -function AdapterBase(endPoint) { - -} - -this.moduleRelativeURL = null; -this.tableData = new Array(); -this.sourceData = new Array(); -this.filter = null; -this.origFilter = null; -this.orderBy = null; -this.currentElement = null; - -AdapterBase.inherits(IceHRMBase); - -AdapterBase.method('initAdapter' , function(endPoint,tab,filter,orderBy) { - this.moduleRelativeURL = baseUrl; - this.table = endPoint; - if(tab == undefined || tab == null){ - this.tab = endPoint; - }else{ - this.tab = tab; - } - - if(filter == undefined || filter == null){ - this.filter = null; - }else{ - this.filter = filter; - } - - this.origFilter = this.filter; - - if(orderBy == undefined || orderBy == null){ - this.orderBy = null; - }else{ - this.orderBy = orderBy; - } - - this.trackEvent("initAdapter",tab); - - this.requestCache = new RequestCache(); - -}); - -AdapterBase.method('setFilter', function(filter) { - this.filter = filter; -}); - -AdapterBase.method('preSetFilterExternal', function(filter) { - this.initialFilter = filter; -}); - -AdapterBase.method('setFilterExternal', function(filter) { - if(filter == undefined || filter == null){ - filter = this.initialFilter; - } - - if(filter == undefined || filter == null){ - return; - } - - this.setFilter(filter); - this.filtersAlreadySet = true; - $("#"+this.getTableName()+"_resetFilters").show(); - this.currentFilterString = this.getFilterString(filter); -}); - -AdapterBase.method('getFilter', function() { - return this.filter; -}); - -AdapterBase.method('setOrderBy', function(orderBy) { - this.orderBy = orderBy; -}); - -AdapterBase.method('getOrderBy', function() { - return this.orderBy; -}); - -/** - * @method add - * @param object {Array} object data to be added to database - * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters - * @param callGetFunction {Boolean} if false the get function of the module will not be called (default: true) - * @param successCallback {Function} this will get called after success response - */ - -AdapterBase.method('add', function(object,getFunctionCallBackData,callGetFunction,successCallback) { - var that = this; - if(callGetFunction == undefined || callGetFunction == null){ - callGetFunction = true; - } - $(object).attr('a','add'); - $(object).attr('t',this.table); - that.showLoader(); - this.requestCache.invalidateTable(this.table); - $.post(this.moduleRelativeURL, object, function(data) { - if(data.status == "SUCCESS"){ - that.addSuccessCallBack(getFunctionCallBackData,data.object, callGetFunction, successCallback, that); - }else{ - that.addFailCallBack(getFunctionCallBackData,data.object); - } - },"json").always(function() {that.hideLoader()}); - this.trackEvent("add",this.tab,this.table); -}); - -AdapterBase.method('addSuccessCallBack', function(callBackData,serverData, callGetFunction, successCallback, thisObject) { - if(callGetFunction){ - this.get(callBackData); - } - this.initFieldMasterData(); - if(successCallback != undefined && successCallback != null){ - successCallback.apply(thisObject,[serverData]); - } - this.trackEvent("addSuccess",this.tab,this.table); -}); - -AdapterBase.method('addFailCallBack', function(callBackData,serverData) { - try{ - this.closePlainMessage(); - }catch(e){} - this.showMessage("Error saving",serverData); - this.trackEvent("addFailed",this.tab,this.table); -}); - -AdapterBase.method('deleteObj', function(id,callBackData) { - var that = this; - that.showLoader(); - this.requestCache.invalidateTable(this.table); - $.post(this.moduleRelativeURL, {'t':this.table,'a':'delete','id':id}, function(data) { - if(data.status == "SUCCESS"){ - that.deleteSuccessCallBack(callBackData,data.object); - }else{ - that.deleteFailCallBack(callBackData,data.object); - } - },"json").always(function() {that.hideLoader()}); - this.trackEvent("delete",this.tab,this.table); -}); - -AdapterBase.method('deleteSuccessCallBack', function(callBackData,serverData) { - this.get(callBackData); - this.clearDeleteParams(); -}); - -AdapterBase.method('deleteFailCallBack', function(callBackData,serverData) { - this.clearDeleteParams(); - this.showMessage("Error Occurred while Deleting Item",serverData); -}); - -AdapterBase.method('get', function(callBackData) { - var that = this; - - if(this.getRemoteTable()){ - this.createTableServer(this.getTableName()); - $("#"+this.getTableName()+'Form').hide(); - $("#"+this.getTableName()).show(); - return; - } - - var sourceMappingJson = JSON.stringify(this.getSourceMapping()); - - var filterJson = ""; - if(this.getFilter() != null){ - filterJson = JSON.stringify(this.getFilter()); - } - - var orderBy = ""; - if(this.getOrderBy() != null){ - orderBy = this.getOrderBy(); - } - - sourceMappingJson = this.fixJSON(sourceMappingJson); - filterJson = this.fixJSON(filterJson); - - that.showLoader(); - $.post(this.moduleRelativeURL, {'t':this.table,'a':'get','sm':sourceMappingJson,'ft':filterJson,'ob':orderBy}, function(data) { - if(data.status == "SUCCESS"){ - that.getSuccessCallBack(callBackData,data.object); - }else{ - that.getFailCallBack(callBackData,data.object); - } - },"json").always(function() {that.hideLoader()}); - - that.initFieldMasterData(); - - this.trackEvent("get",this.tab,this.table); - //var url = this.getDataUrl(); - //console.log(url); -}); - - -AdapterBase.method('getDataUrl', function(columns) { - var that = this; - var sourceMappingJson = JSON.stringify(this.getSourceMapping()); - - var columns = JSON.stringify(columns); - - var filterJson = ""; - if(this.getFilter() != null){ - filterJson = JSON.stringify(this.getFilter()); - } - - var orderBy = ""; - if(this.getOrderBy() != null){ - orderBy = this.getOrderBy(); - } - - var url = this.moduleRelativeURL.replace("service.php","data.php"); - url = url+"?"+"t="+this.table; - url = url+"&"+"sm="+this.fixJSON(sourceMappingJson); - url = url+"&"+"cl="+this.fixJSON(columns); - url = url+"&"+"ft="+this.fixJSON(filterJson); - url = url+"&"+"ob="+orderBy; - - if(this.isSubProfileTable()){ - url = url+"&"+"type=sub"; - } - - if(this.remoteTableSkipProfileRestriction()){ - url = url+"&"+"skip=1"; - } - - return url; -}); - -AdapterBase.method('isSubProfileTable', function() { - return false; -}); - -AdapterBase.method('remoteTableSkipProfileRestriction', function() { - return false; -}); - -AdapterBase.method('preProcessTableData', function(row) { - return row; -}); - -AdapterBase.method('getSuccessCallBack', function(callBackData,serverData) { - var data = []; - var mapping = this.getDataMapping(); - for(var i=0;i
  • '; - var editButton = ''; - - var table = $('
    '); - - //add Header - var header = this.getSubHeader(); - table.append(header); - if(data.length == 0){ - table.append(''+this.getNoDataMessage()+''); - }else{ - for(var i=0;i

    '+this.getSubHeaderTitle()+'

    '); - return header; -}); - - - -/** - * IdNameAdapter - */ - -function IdNameAdapter(endPoint) { - this.initAdapter(endPoint); -} - -IdNameAdapter.inherits(AdapterBase); - - - -IdNameAdapter.method('getDataMapping', function() { - return [ - "id", - "name" - ]; -}); - -IdNameAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name"} - ]; -}); - -IdNameAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}] - ]; -}); - - -/** - * LogViewAdapter - */ - -function LogViewAdapter(endPoint,tab,filter,orderBy){ - this.initAdapter(endPoint,tab,filter,orderBy); -} - -LogViewAdapter.inherits(AdapterBase); - -LogViewAdapter.method('getLogs', function(id) { - var that = this; - var object = {"id":id}; - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getLogsSuccessCallBack'; - callBackData['callBackFail'] = 'getLogsFailCallBack'; - - this.customAction('getLogs','admin='+this.modulePathName,reqJson,callBackData); -}); - -LogViewAdapter.method('getLogsSuccessCallBack', function(callBackData) { - - var tableLog = '_days_
    Notes
    '; - var rowLog = '_date_  _status_
    _note_'; - - var logs = callBackData.data; - var html = ""; - var rowsLogs = ""; - - - for(var i=0;i "+logs[i].status_to); - trow = trow.replace(/_note_/g,logs[i].note); - rowsLogs += trow; - } - - if(rowsLogs != ""){ - tableLog = tableLog.replace('_days_',rowsLogs); - html+= tableLog; - } - - this.showMessage("Logs",html); - - timeUtils.convertToRelativeTime($(".logTime")); -}); - -LogViewAdapter.method('getLogsFailCallBack', function(callBackData) { - this.showMessage("Error","Error occured while getting data"); -}); - -/** - * ApproveAdminAdapter - */ - -function ApproveAdminAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -ApproveAdminAdapter.inherits(LogViewAdapter); - -ApproveAdminAdapter.method('getStatusFieldPosition', function() { - var dm = this.getDataMapping(); - return dm.length - 1; -}); - -ApproveAdminAdapter.method('openStatus', function(id,status) { - $('#'+this.itemNameLower+'StatusModel').modal('show'); - $('#'+this.itemNameLower+'_status').html(this.getStatusOptions(status)); - $('#'+this.itemNameLower+'_status').val(status); - this.statusChangeId = id; -}); - -ApproveAdminAdapter.method('closeDialog', function() { - $('#'+this.itemNameLower+'StatusModel').modal('hide'); -}); - -ApproveAdminAdapter.method('changeStatus', function() { - var status = $('#'+this.itemNameLower+'_status').val(); - var reason = $('#'+this.itemNameLower+'_reason').val(); - - if(status == undefined || status == null || status == ""){ - this.showMessage("Error", "Please select "+this.itemNameLower+" status"); - return; - } - - var object = {"id":this.statusChangeId,"status":status,"reason":reason}; - - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'changeStatusSuccessCallBack'; - callBackData['callBackFail'] = 'changeStatusFailCallBack'; - - this.customAction('changeStatus','admin='+this.modulePathName,reqJson,callBackData); - - this.closeDialog(); - this.statusChangeId = null; -}); - -ApproveAdminAdapter.method('changeStatusSuccessCallBack', function(callBackData) { - this.showMessage("Successful", this.itemName + " Request status changed successfully"); - this.get([]); -}); - -ApproveAdminAdapter.method('changeStatusFailCallBack', function(callBackData) { - this.showMessage("Error", "Error occurred while changing "+this.itemName+" request status"); -}); - - - -ApproveAdminAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var statusChangeButton = ''; - var viewLogsButton = ''; - - var html = '
    _edit__delete__status__logs_
    '; - - var optiondata = this.getStatusOptionsData(data[this.getStatusFieldPosition()]); - if(Object.keys(optiondata).length > 0){ - html = html.replace('_status_',statusChangeButton); - }else{ - html = html.replace('_status_',''); - } - - html = html.replace('_logs_',viewLogsButton); - - if(this.showDelete){ - html = html.replace('_delete_',deleteButton); - - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - html = html.replace(/_cstatus_/g,data[this.getStatusFieldPosition()]); - return html; -}); - -ApproveAdminAdapter.method('isSubProfileTable', function() { - if(this.user.user_level == "Admin"){ - return false; - }else{ - return true; - } -}); - -ApproveAdminAdapter.method('getStatusOptionsData', function(currentStatus) { - var data = {}; - if(currentStatus == 'Approved'){ - - }else if(currentStatus == 'Pending'){ - data["Approved"] = "Approved"; - data["Rejected"] = "Rejected"; - - }else if(currentStatus == 'Rejected'){ - - }else if(currentStatus == 'Cancelled'){ - - }else if(currentStatus == 'Processing'){ - - }else{ - data["Cancellation Requested"] = "Cancellation Requested"; - data["Cancelled"] = "Cancelled"; - } - - return data; -}); - -ApproveAdminAdapter.method('getStatusOptions', function(currentStatus) { - - return this.generateOptions(this.getStatusOptionsData(currentStatus)); -}); - - -/** - * ApproveModuleAdapter - */ - -function ApproveModuleAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -ApproveModuleAdapter.inherits(LogViewAdapter); - -ApproveModuleAdapter.method('cancelRequest', function(id) { - var that = this; - var object = {}; - object['id'] = id; - - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'cancelSuccessCallBack'; - callBackData['callBackFail'] = 'cancelFailCallBack'; - - this.customAction('cancel','modules='+this.modulePathName,reqJson,callBackData); -}); - -ApproveModuleAdapter.method('cancelSuccessCallBack', function(callBackData) { - this.showMessage("Successful", this.itemName + " cancellation request sent"); - this.get([]); -}); - -ApproveModuleAdapter.method('cancelFailCallBack', function(callBackData) { - this.showMessage("Error Occurred while cancelling "+this.itemName, callBackData); -}); - -ApproveModuleAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var requestCancellationButton = ''; - var viewLogsButton = ''; - - - var html = '
    _edit__logs__delete_
    '; - - html = html.replace('_logs_',viewLogsButton); - - if(this.showDelete){ - if (data[7] === "Approved") { - html = html.replace('_delete_',requestCancellationButton); - } else if(data[7] === "Pending" || this.user.user_level === "Admin") { - html = html.replace('_delete_',deleteButton); - } else { - html = html.replace('_delete_',''); - } - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -/** - * ApproveApproverAdapter - */ - -function ApproveApproverAdapter() { -} - -ApproveApproverAdapter.method('getActionButtonsHtml', function(id,data) { - var statusChangeButton = ''; - var viewLogsButton = ''; - - var html = '
    _status__logs_
    '; - - - html = html.replace('_logs_',viewLogsButton); - - - if(data[this.getStatusFieldPosition()] == 'Processing'){ - html = html.replace('_status_',statusChangeButton); - - }else{ - html = html.replace('_status_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - html = html.replace(/_cstatus_/g,data[this.getStatusFieldPosition()]); - return html; -}); - -ApproveApproverAdapter.method('getStatusOptionsData', function(currentStatus) { - var data = {}; - if(currentStatus != 'Processing'){ - - }else{ - data["Approved"] = "Approved"; - data["Rejected"] = "Rejected"; - - } - - return data; -}); - -ApproveApproverAdapter.method('getStatusOptions', function(currentStatus) { - return this.generateOptions(this.getStatusOptionsData(currentStatus)); -}); - - - - -/** - * TableEditAdapter - */ - -function TableEditAdapter(endPoint) { - this.initAdapter(endPoint); - this.cellDataUpdates = {}; - this.modulePath = ''; - this.rowFieldName = ''; - this.columnFieldName = ''; - this.rowTable = ''; - this.columnTable = ''; - this.valueTable = ''; - this.csvData = []; - this.columnIDMap = {}; -} - -TableEditAdapter.inherits(AdapterBase); - -TableEditAdapter.method('setModulePath', function(path) { - this.modulePath = path; -}); - -TableEditAdapter.method('setRowFieldName', function(name) { - this.rowFieldName = name; -}); - -TableEditAdapter.method('setTables', function(rowTable, columnTable, valueTable) { - this.rowTable = rowTable; - this.columnTable = columnTable; - this.valueTable = valueTable; -}); - -TableEditAdapter.method('setColumnFieldName', function(name) { - this.columnFieldName = name; -}); - -TableEditAdapter.method('getDataMapping', function() { - return [ - ]; -}); - - -TableEditAdapter.method('getFormFields', function() { - return [ - ]; -}); - -TableEditAdapter.method('get', function() { - this.getAllData(); -}); - -TableEditAdapter.method('getAllData', function(save) { - var req = {}; - req.rowTable = this.rowTable; - req.columnTable = this.columnTable; - req.valueTable = this.valueTable; - req = this.addAdditionalRequestData('getAllData', req); - req.save = (save == undefined || save == null || save == false)?0:1; - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getAllDataSuccessCallBack'; - callBackData['callBackFail'] = 'getAllDataFailCallBack'; - - this.customAction('getAllData',this.modulePath,reqJson,callBackData); -}); - -TableEditAdapter.method('getDataItem', function(row,column,allData) { - var columnData = allData[1]; - var rowData = allData[0]; - var serverData = allData[2]; - - if(column == -1){ - return rowData[row].name; - }else{ - return this.getDataItemByKeyValues(this.rowFieldName, rowData[row].id, this.columnFieldName, columnData[column].id, serverData); - } -}); - -TableEditAdapter.method('getDataItemByKeyValues', function(rowKeyName, rowKeyVal, colKeyName, colKeyVal, data) { - for(var i=0;i
    '; - - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*15 - 15; - } - - $('#'+elementId).html(html); - - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "aaData": data, - "aoColumns": headers, - "bSort": false, - "iDisplayLength": 15, - "iDisplayStart": start - }; - - - var customTableParams = this.getCustomTableParams(); - - $.extend(dataTableParams, customTableParams); - - $('#'+elementId+' #grid').dataTable( dataTableParams ); - - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - //$('.tableActionButton').tooltip(); - $('#'+elementId+' #grid').editableTableWidget(); - - $('#'+elementId+' #grid .editcell').on('validate', function(evt, newValue) { - - return modJs.validateCellValue($(this), evt, newValue); - - }); - - this.afterCreateTable(elementId); -}); - -TableEditAdapter.method('afterCreateTable', function(elementId) { - -}); - -TableEditAdapter.method('addCellDataUpdate' , function(colId, rowId, data) { - - this.cellDataUpdates[colId+"="+rowId] = [colId, rowId, data]; -}); - -TableEditAdapter.method('addAdditionalRequestData' , function(type, req) { - return req; -}); - -TableEditAdapter.method('sendCellDataUpdates' , function() { - var req = this.cellDataUpdates; - req.rowTable = this.rowTable; - req.columnTable = this.columnTable; - req.valueTable = this.valueTable; - req = this.addAdditionalRequestData('updateData', req); - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'updateDataSuccessCallBack'; - callBackData['callBackFail'] = 'updateDataFailCallBack'; - this.showLoader(); - this.customAction('updateData',this.modulePath,reqJson,callBackData); -}); - -TableEditAdapter.method('updateDataSuccessCallBack', function(callBackData,serverData) { - this.hideLoader(); - modJs.cellDataUpdates = {}; - modJs.get(); -}); - -TableEditAdapter.method('updateDataFailCallBack', function(callBackData,serverData) { - this.hideLoader(); -}); - -TableEditAdapter.method('sendAllCellDataUpdates' , function() { - - var req = this.cellDataUpdates; - req.rowTable = this.rowTable; - req.columnTable = this.columnTable; - req.valueTable = this.valueTable; - req = this.addAdditionalRequestData('updateAllData', req); - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'updateDataAllSuccessCallBack'; - callBackData['callBackFail'] = 'updateDataAllFailCallBack'; - this.showLoader(); - this.customAction('updateAllData',this.modulePath,reqJson,callBackData); -}); - -TableEditAdapter.method('updateDataAllSuccessCallBack', function(callBackData,serverData) { - this.hideLoader(); - modJs.cellDataUpdates = {}; - modJs.getAllData(true); -}); - -TableEditAdapter.method('updateDataAllFailCallBack', function(callBackData,serverData) { - this.hideLoader(); -}); - -TableEditAdapter.method('showActionButtons' , function() { - return false; -}); - - - - - - - -/** - * RequestCache - */ - -function RequestCache() { - -} - -RequestCache.method('getKey', function(url,params) { - var key = url+"|"; - for(index in params){ - key += index+"="+params[index]+"|"; - } - return key; -}); - -RequestCache.method('invalidateTable', function(table) { - - var key; - for (var i = 0; i < localStorage.length; i++){ - key = localStorage.key(i); - if(key.indexOf('t='+table) > 0){ - localStorage.removeItem(key); - } - - } -}); - - -RequestCache.method('getData', function(key) { - var data; - - if (typeof(Storage) == "undefined") { - return null; - } - - var strData = localStorage.getItem(key); - if(strData != undefined && strData != null && strData != ""){ - data = JSON.parse(strData); - if(data == undefined || data == null){ - return null; - } - - if(data.status != undefined && data.status != null && data.status != "SUCCESS"){ - return null; - } - - return data; - } - - return null; -}); - -RequestCache.method('setData', function(key, data) { - - if (typeof(Storage) == "undefined") { - return null; - } - - if(data.status != undefined && data.status != null && data.status != "SUCCESS"){ - return null; - } - - var strData = JSON.stringify(data); - localStorage.setItem(key,strData); - return strData; -}); - - -/** -* ObjectAdapter -*/ - -function ObjectAdapter(endPoint,tab,filter,orderBy){ - this.initAdapter(endPoint,tab,filter,orderBy); - this.container = null; - this.loadMoreButton = null; - this.start = 0; - this.pageSize = 6; - this.currentPage = 1; - this.hasMoreData = true; - this.searchTerm = ""; - this.searchInput = null; -} - -ObjectAdapter.inherits(AdapterBase); - -ObjectAdapter.method('getObjectHTML', function(object) { - var template = this.getCustomTemplate(this.getTemplateName()); - var t = template; - for(index in object){ - t = t.replace(new RegExp('#_'+index+'_#', 'g'), object[index]); - } - return t; - -}); - -ObjectAdapter.method('setPageSize', function(pageSize) { - this.pageSize = pageSize; -}); - -ObjectAdapter.method('addDomEvents', function(object) { - -}); - -ObjectAdapter.method('getTemplateName', function() { - return ''; -}); - -ObjectAdapter.method('renderObject', function(object) { - - var objDom = this.getObjectDom(object.id); - - var html = this.getObjectHTML(object); - var domObj = $(html); - - - if(objDom != undefined && objDom != null){ - objDom.replace(domObj); - }else{ - this.container.append(domObj); - } - - this.addDomEvents(domObj); -}); - -ObjectAdapter.method('setContainer', function(container) { - this.container = container; -}); - -ObjectAdapter.method('setLoadMoreButton', function(loadMoreButton) { - var that = this; - this.loadMoreButton = loadMoreButton; - this.loadMoreButton.off().on('click',function(){ - that.loadMoreButton.attr('disabled','disabled'); - that.loadMore([]); - } - ); -}); - -ObjectAdapter.method('showLoadError', function(msg) { - $("#"+this.getTableName()+"_error").html(msg); - $("#"+this.getTableName()+"_error").show(); -}); - -ObjectAdapter.method('hideLoadError', function() { - $("#"+this.getTableName()+"_error").hide(); -}); - -ObjectAdapter.method('setSearchBox', function(searchInput) { - var that = this; - this.searchInput = searchInput; - this.searchInput.off(); - this.searchInput.keydown(function(event){ - var val = $(this).val(); - if ( event.which == 13 ) { - event.preventDefault(); - that.search([]); - }else if(( event.which == 8 || event.which == 46) && val.length == 1 && that.searchTerm != ''){ - that.search([]); - } - }); -}); - -ObjectAdapter.method('getObjectDom', function(id) { - obj = this.container.find("#obj_"+id); - if(obj.length){ - return obj; - } - return null; -}); - -ObjectAdapter.method('loadMore', function(callBackData) { - if(!this.hasMoreData){ - return; - } - this.currentPage++; - this.get(callBackData, true); -}); - -ObjectAdapter.method('get', function(callBackData, loadMore) { - var that = this; - - this.hideLoadError(); - - if(!loadMore){ - this.currentPage = 1; - if(this.container != null){ - this.container.html(''); - } - this.hasMoreData = true; - this.tableData = []; - } - - this.start = (this.currentPage - 1) * this.pageSize; - - - this.container = $("#"+this.getTableName()).find('.objectList'); - - that.showLoader(); - - - var url = this.getDataUrl(that.getDataMapping()) + - "&iDisplayStart="+this.start+"&iDisplayLength="+this.pageSize+"&objects=1"; - - if(this.searchTerm != "" && this.searchTerm != undefined && this.searchTerm != null){ - url += "&sSearch="+this.searchTerm; - } - - $.post(url, function(data) { - that.getSuccessCallBack(callBackData,data); - },"json").always(function() {that.hideLoader()}); - - that.initFieldMasterData(); - - this.trackEvent("get",this.tab,this.table); -}); - -ObjectAdapter.method('search', function(callBackData) { - var that = this; - this.searchTerm = $("#"+this.getTableName()+"_search").val(); - - this.get(callBackData); - -}); - - -ObjectAdapter.method('getSuccessCallBack', function(callBackData,serverData) { - var data = []; - - if(serverData.length == 0 && this.container.html() == ""){ - this.showLoadError("No Results Found !!!"); - return; - } - - if(this.getFilters() == null){ - $("#"+this.getTableName()+"_filterBtn").hide(); - $("#"+this.getTableName()+"_resetFilters").hide(); - }else{ - $("#"+this.getTableName()+"_filterBtn").show(); - $("#"+this.getTableName()+"_resetFilters").show(); - if(this.currentFilterString != "" && this.currentFilterString != null){ - $("#"+this.getTableName()+"_resetFilters").html(this.currentFilterString+''); - }else{ - $("#"+this.getTableName()+"_resetFilters").html('Reset Filters'); - $("#"+this.getTableName()+"_resetFilters").hide(); - } - } - - $("#"+this.getTableName()).find('.search-controls').show(); - if(serverData.length > this.pageSize){ - this.hasMoreData = true; - serverData.pop(); - this.loadMoreButton.removeAttr('disabled'); - this.loadMoreButton.show(); - }else{ - this.hasMoreData = false; - this.loadMoreButton.hide(); - } - - this.scrollToElementBottom(this.container); - for(var i=0;i
    #_delete_##_edit_##_label_#:#_value_#
    ', - "validation":"none" - }], - [ "display_order", {"label":"Priority","type":"text","validation":"number"}], - [ "display_section", {"label":"Display Section","type":"text","validation":"none"}] - ]; -}); - -CustomFieldAdapter.method('setTableType', function(type) { - this.tableType = type; -}); - -CustomFieldAdapter.method('doCustomValidation', function(params) { - var validateName= function (str) { - var name = /^[a-z][a-z0-9\._]+$/; - return str != null && name.test(str); +import ModuleBase from './ModuleBase'; +import RequestCache from '../api-common/RequestCache'; + +class AdapterBase extends ModuleBase { + constructor(endPoint, tab, filter, orderBy) { + super(); + this.moduleRelativeURL = null; + this.tableData = []; + this.sourceData = []; + this.filter = null; + this.origFilter = null; + this.orderBy = null; + this.currentElement = null; + this.initAdapter(endPoint, tab, filter, orderBy); + } + + initAdapter(endPoint, tab, filter, orderBy) { + this.moduleRelativeURL = baseUrl; + this.table = endPoint; + if (tab === undefined || tab === null) { + this.tab = endPoint; + } else { + this.tab = tab; + } + + if (filter === undefined || filter === null) { + this.filter = null; + } else { + this.filter = filter; + } + + this.origFilter = this.filter; + + if (orderBy === undefined || orderBy === null) { + this.orderBy = null; + } else { + this.orderBy = orderBy; + } + + this.trackEvent('initAdapter', tab); + + this.requestCache = new RequestCache(); + } + + setFilter(filter) { + this.filter = filter; + } + + preSetFilterExternal(filter) { + this.initialFilter = filter; + } + + setFilterExternal(_filter) { + let filter = _filter; + if (filter === undefined || filter === null) { + filter = this.initialFilter; + } + + if (filter === undefined || filter === null) { + return; + } + + this.setFilter(filter); + this.filtersAlreadySet = true; + $(`#${this.getTableName()}_resetFilters`).show(); + this.currentFilterString = this.getFilterString(filter); + } + + getFilter() { + return this.filter; + } + + setOrderBy(orderBy) { + this.orderBy = orderBy; + } + + getOrderBy() { + return this.orderBy; + } + + /** + * @method add + * @param object {Array} object data to be added to database + * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters + * @param _callGetFunction {Boolean} if false the get function of the module will not be called (default: true) + * @param successCallback {Function} this will get called after success response + */ + + add(object, getFunctionCallBackData, callGetFunction, successCallback) { + const that = this; + if (callGetFunction === undefined || callGetFunction === null) { + // eslint-disable-next-line no-param-reassign + callGetFunction = true; + } + $(object).attr('a', 'add'); + $(object).attr('t', this.table); + that.showLoader(); + this.requestCache.invalidateTable(this.table); + $.post(this.moduleRelativeURL, object, (data) => { + if (data.status === 'SUCCESS') { + that.addSuccessCallBack(getFunctionCallBackData, data.object, callGetFunction, successCallback, that); + } else { + that.addFailCallBack(getFunctionCallBackData, data.object); + } + }, 'json').always(() => { that.hideLoader(); }); + this.trackEvent('add', this.tab, this.table); + } + + addSuccessCallBack(callBackData, serverData, callGetFunction, successCallback, thisObject) { + if (callGetFunction) { + this.get(callBackData); + } + this.initFieldMasterData(); + if (successCallback !== undefined && successCallback !== null) { + successCallback.apply(thisObject, [serverData]); + } + this.trackEvent('addSuccess', this.tab, this.table); + } + + addFailCallBack(callBackData, serverData) { + try { + this.closePlainMessage(); + } catch (e) { + // No need to report + } + this.showMessage('Error saving', serverData); + this.trackEvent('addFailed', this.tab, this.table); + } + + deleteObj(id, callBackData) { + const that = this; + that.showLoader(); + this.requestCache.invalidateTable(this.table); + $.post(this.moduleRelativeURL, { t: this.table, a: 'delete', id }, (data) => { + if (data.status === 'SUCCESS') { + that.deleteSuccessCallBack(callBackData, data.object); + } else { + that.deleteFailCallBack(callBackData, data.object); + } + }, 'json').always(() => { that.hideLoader(); }); + this.trackEvent('delete', this.tab, this.table); + } + + // eslint-disable-next-line no-unused-vars + deleteSuccessCallBack(callBackData, serverData) { + this.get(callBackData); + this.clearDeleteParams(); + } + + deleteFailCallBack(callBackData, serverData) { + this.clearDeleteParams(); + this.showMessage('Error Occurred while Deleting Item', serverData); + } + + get(callBackData) { + const that = this; + + if (this.getRemoteTable()) { + this.createTableServer(this.getTableName()); + $(`#${this.getTableName()}Form`).hide(); + $(`#${this.getTableName()}`).show(); + return; + } + + let sourceMappingJson = JSON.stringify(this.getSourceMapping()); + + let filterJson = ''; + if (this.getFilter() !== null) { + filterJson = JSON.stringify(this.getFilter()); + } + + let orderBy = ''; + if (this.getOrderBy() !== null) { + orderBy = this.getOrderBy(); + } + + sourceMappingJson = this.fixJSON(sourceMappingJson); + filterJson = this.fixJSON(filterJson); + + that.showLoader(); + $.post(this.moduleRelativeURL, { + t: this.table, a: 'get', sm: sourceMappingJson, ft: filterJson, ob: orderBy, + }, (data) => { + if (data.status === 'SUCCESS') { + that.getSuccessCallBack(callBackData, data.object); + } else { + that.getFailCallBack(callBackData, data.object); + } + }, 'json').always(() => { that.hideLoader(); }); + + that.initFieldMasterData(); + + this.trackEvent('get', this.tab, this.table); + // var url = this.getDataUrl(); + // console.log(url); + } + + + getDataUrl(_columns) { + const sourceMappingJson = JSON.stringify(this.getSourceMapping()); + + const columns = JSON.stringify(_columns); + + let filterJson = ''; + if (this.getFilter() !== null) { + filterJson = JSON.stringify(this.getFilter()); + } + + let orderBy = ''; + if (this.getOrderBy() !== null) { + orderBy = this.getOrderBy(); + } + + let url = this.moduleRelativeURL.replace('service.php', 'data.php'); + url = `${url}?t=${this.table}`; + url = `${url}&sm=${this.fixJSON(sourceMappingJson)}`; + url = `${url}&cl=${this.fixJSON(columns)}`; + url = `${url}&ft=${this.fixJSON(filterJson)}`; + url = `${url}&ob=${orderBy}`; + + if (this.isSubProfileTable()) { + url = `${url}&type=sub`; + } + + if (this.remoteTableSkipProfileRestriction()) { + url = `${url}&skip=1`; + } + + return url; + } + + isSubProfileTable() { + return false; + } + + remoteTableSkipProfileRestriction() { + return false; + } + + preProcessTableData(row) { + return row; + } + + getSuccessCallBack(callBackData, serverData) { + const data = []; + const mapping = this.getDataMapping(); + for (let i = 0; i < serverData.length; i++) { + const row = []; + for (let j = 0; j < mapping.length; j++) { + row[j] = serverData[i][mapping[j]]; + } + data.push(this.preProcessTableData(row)); + } + this.sourceData = serverData; + if (callBackData.callBack !== undefined && callBackData.callBack !== null) { + if (callBackData.callBackData === undefined || callBackData.callBackData === null) { + callBackData.callBackData = []; + } + callBackData.callBackData.push(serverData); + callBackData.callBackData.push(data); + this.callFunction(callBackData.callBack, callBackData.callBackData); + } + + this.tableData = data; + + if (!(callBackData.noRender !== undefined && callBackData.noRender !== null && callBackData.noRender === true)) { + this.createTable(this.getTableName()); + $(`#${this.getTableName()}Form`).hide(); + $(`#${this.getTableName()}`).show(); + } + } + + // eslint-disable-next-line no-unused-vars + getFailCallBack(callBackData, serverData) { + + } + + + getElement(id, callBackData, clone) { + const that = this; + let sourceMappingJson = JSON.stringify(this.getSourceMapping()); + sourceMappingJson = this.fixJSON(sourceMappingJson); + that.showLoader(); + $.post(this.moduleRelativeURL, { + t: this.table, a: 'getElement', id, sm: sourceMappingJson, + }, function (data) { + if (data.status === 'SUCCESS') { + if (clone) { + delete data.object.id; + } + this.currentElement = data.object; + that.getElementSuccessCallBack.apply(that, [callBackData, data.object]); + } else { + that.getElementFailCallBack.apply(that, [callBackData, data.object]); + } + }, 'json').always(() => { that.hideLoader(); }); + this.trackEvent('getElement', this.tab, this.table); + } + + getElementSuccessCallBack(callBackData, serverData) { + if (callBackData.callBack !== undefined && callBackData.callBack !== null) { + if (callBackData.callBackData === undefined || callBackData.callBackData === null) { + callBackData.callBackData = []; + } + callBackData.callBackData.push(serverData); + this.callFunction(callBackData.callBack, callBackData.callBackData, this); + } + this.currentElement = serverData; + if (!(callBackData.noRender !== undefined && callBackData.noRender !== null && callBackData.noRender === true)) { + this.renderForm(serverData); + } + } + + // eslint-disable-next-line no-unused-vars + getElementFailCallBack(callBackData, serverData) { + + } + + + getTableData() { + return this.tableData; + } + + getTableName() { + return this.tab; + } + + getFieldValues(fieldMaster, callBackData) { + const that = this; + let method = ''; + let methodParams = ''; + if (fieldMaster[3] !== undefined && fieldMaster[3] !== null) { + // eslint-disable-next-line prefer-destructuring + method = fieldMaster[3]; + } + + if (fieldMaster[4] !== undefined && fieldMaster[4] !== null) { + methodParams = JSON.stringify(fieldMaster[4]); + } + + const key = this.requestCache.getKey(this.moduleRelativeURL, { + t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method, methodParams, a: 'getFieldValues', + }); + const cacheData = this.requestCache.getData(key); + + if (cacheData !== null && cacheData !== undefined) { + if (cacheData.status === 'SUCCESS') { + callBackData.callBackData.push(cacheData.data); + if (callBackData.callBackSuccess !== null && callBackData.callBackSuccess !== undefined) { + callBackData.callBackData.push(callBackData.callBackSuccess); + } + that.callFunction(callBackData.callBack, callBackData.callBackData); + } + } + + const callbackWraper = function (data) { + if (data.status === 'SUCCESS') { + that.requestCache.setData(this.success.key, data); + const localCallBackData = callBackData; + localCallBackData.callBackData = [callBackData.callBackData[0]]; + localCallBackData.callBackData.push(data.data); + if (localCallBackData.callBackSuccess !== null && localCallBackData.callBackSuccess !== undefined) { + localCallBackData.callBackData.push(callBackData.callBackSuccess); + } + that.callFunction(localCallBackData.callBack, localCallBackData.callBackData); + } else if (data.message === 'Access violation') { + alert(`Error : ${callbackWraper.table} ${data.message}`); + } }; - if(!validateName(params.name)){ - return "Invalid name for custom field"; + callbackWraper.key = key; + // eslint-disable-next-line prefer-destructuring + callbackWraper.table = fieldMaster[0]; + + $.post(this.moduleRelativeURL, { + t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method, methodParams, a: 'getFieldValues', + }, callbackWraper, 'json'); + } + + setAdminProfile(empId) { + try { + localStorage.clear(); + } catch (e) { + // No need to report } + $.post(this.moduleRelativeURL, { a: 'setAdminEmp', empid: empId }, () => { + // eslint-disable-next-line no-restricted-globals + top.location.href = clientUrl; + }, 'json'); + } - - return null; -}); - -CustomFieldAdapter.method('forceInjectValuesBeforeSave', function(params) { - - - //Build data field - var data = [params.name], options = [], optionsData; - data.push({}); - data[1]['label'] = params.field_label; - data[1]['type'] = params.field_type; - data[1]['validation'] = params.field_validation; - if(["select","select2","select2multi"].indexOf(params.field_type) >= 0){ - optionsData = JSON.parse(params.field_options); - for(index in optionsData){ - options.push([optionsData[index].value, optionsData[index].label]); + customAction(subAction, module, request, callBackData, isPost) { + const that = this; + request = this.fixJSON(request); + if (!isPost) { + $.getJSON(this.moduleRelativeURL, { + t: this.table, a: 'ca', sa: subAction, mod: module, req: request, + }, (data) => { + if (data.status === 'SUCCESS') { + callBackData.callBackData.push(data.data); + that.callFunction(callBackData.callBackSuccess, callBackData.callBackData); + } else { + callBackData.callBackData.push(data.data); + that.callFunction(callBackData.callBackFail, callBackData.callBackData); } - data[1]['source'] = options; + }); + } else { + $.post(this.moduleRelativeURL, { + t: this.table, a: 'ca', sa: subAction, mod: module, req: request, + }, (data) => { + if (data.status === 'SUCCESS') { + callBackData.callBackData.push(data.data); + that.callFunction(callBackData.callBackSuccess, callBackData.callBackData); + } else { + callBackData.callBackData.push(data.data); + that.callFunction(callBackData.callBackFail, callBackData.callBackData); + } + }, 'json'); } - if(params.field_validation == null || params.field_validation == undefined){ - params.field_validation = ""; - } - params.data = JSON.stringify(data); - params.type = this.tableType; - return params; -}); + } + + sendCustomRequest(action, params, successCallback, failCallback) { + params.a = action; + $.post(this.moduleRelativeURL, params, (data) => { + if (data.status === 'SUCCESS') { + successCallback(data.data); + } else { + failCallback(data.data); + } + }, 'json'); + } + + + getCustomActionUrl(action, params) { + params.a = action; + let str = ''; + for (const key in params) { + if (params.hasOwnProperty(key)) { + if (str !== '') { + str += '&'; + } + str += `${key}=${params[key]}`; + } + } + return `${this.moduleRelativeURL}?${str}`; + } + + + getClientDataUrl() { + return `${this.moduleRelativeURL.replace('service.php', '')}data/`; + } + + getCustomUrl(str) { + return this.moduleRelativeURL.replace('service.php', str); + } +} + +export default AdapterBase; diff --git a/web/api/AesCrypt.js b/web/api/AesCrypt.js deleted file mode 100644 index d5204009..00000000 --- a/web/api/AesCrypt.js +++ /dev/null @@ -1,503 +0,0 @@ -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* AES implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -/* jshint node:true *//* global define */ -'use strict'; - - -/** - * AES (Rijndael cipher) encryption routines, - * - * Reference implementation of FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. - * - * @namespace - */ -var Aes = {}; - - -/** - * AES Cipher function: encrypt 'input' state with Rijndael algorithm [§5.1]; - * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage. - * - * @param {number[]} input - 16-byte (128-bit) input state array. - * @param {number[][]} w - Key schedule as 2D byte-array (Nr+1 x Nb bytes). - * @returns {number[]} Encrypted output state array. - */ -Aes.cipher = function(input, w) { - var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) - var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys - - var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [§3.4] - for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i]; - - state = Aes.addRoundKey(state, w, 0, Nb); - - for (var round=1; round 6 && i%Nk == 4) { - temp = Aes.subWord(temp); - } - // xor w[i] with w[i-1] and w[i-Nk] - for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t]; - } - - return w; -}; - - -/** - * Apply SBox to state S [§5.1.1] - * @private - */ -Aes.subBytes = function(s, Nb) { - for (var r=0; r<4; r++) { - for (var c=0; c>> i*8) & 0xff; - for (var i=0; i<2; i++) counterBlock[i+2] = (nonceRnd >>> i*8) & 0xff; - for (var i=0; i<4; i++) counterBlock[i+4] = (nonceSec >>> i*8) & 0xff; - - // and convert it to a string to go on the front of the ciphertext - var ctrTxt = ''; - for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]); - - // generate key schedule - an expansion of the key into distinct Key Rounds for each round - var keySchedule = Aes.keyExpansion(key); - - var blockCount = Math.ceil(plaintext.length/blockSize); - var ciphertxt = new Array(blockCount); // ciphertext as array of strings - - for (var b=0; b>> c*8) & 0xff; - for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8); - - var cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block -- - - // block size is reduced on final block - var blockLength = b>> c*8) & 0xff; - for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff; - - var cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block - - var plaintxtByte = new Array(ciphertext[b].length); - for (var i=0; i'; + const viewLogsButton = ''; + + let html = '
    _edit__delete__status__logs_
    '; + + const optiondata = this.getStatusOptionsData(data[this.getStatusFieldPosition()]); + if (Object.keys(optiondata).length > 0) { + html = html.replace('_status_', statusChangeButton); + } else { + html = html.replace('_status_', ''); + } + + html = html.replace('_logs_', viewLogsButton); + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); + return html; + } + + isSubProfileTable() { + if (this.user.user_level == 'Admin') { + return false; + } + return true; + } + + getStatusOptionsData(currentStatus) { + const data = {}; + if (currentStatus == 'Approved') { + + } else if (currentStatus == 'Pending') { + data.Approved = 'Approved'; + data.Rejected = 'Rejected'; + } else if (currentStatus == 'Rejected') { + + } else if (currentStatus == 'Cancelled') { + + } else if (currentStatus == 'Processing') { + + } else { + data['Cancellation Requested'] = 'Cancellation Requested'; + data.Cancelled = 'Cancelled'; + } + + return data; + } + + getStatusOptions(currentStatus) { + return this.generateOptions(this.getStatusOptionsData(currentStatus)); + } +} + +export default ApproveAdminAdapter; diff --git a/web/api/ApproveApproverAdapter.js b/web/api/ApproveApproverAdapter.js new file mode 100644 index 00000000..55a321bb --- /dev/null +++ b/web/api/ApproveApproverAdapter.js @@ -0,0 +1,50 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/** + * ApproveApproverAdapter + */ + +class ApproveApproverAdapter { + getActionButtonsHtml(id, data) { + const statusChangeButton = ''; + const viewLogsButton = ''; + + let html = '
    _status__logs_
    '; + + + html = html.replace('_logs_', viewLogsButton); + + + if (data[this.getStatusFieldPosition()] == 'Processing') { + html = html.replace('_status_', statusChangeButton); + } else { + html = html.replace('_status_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); + return html; + } + + getStatusOptionsData(currentStatus) { + const data = {}; + if (currentStatus != 'Processing') { + + } else { + data.Approved = 'Approved'; + data.Rejected = 'Rejected'; + } + + return data; + } + + getStatusOptions(currentStatus) { + return this.generateOptions(this.getStatusOptionsData(currentStatus)); + } +} + +export default ApproveApproverAdapter; diff --git a/web/api/ApproveModuleAdapter.js b/web/api/ApproveModuleAdapter.js new file mode 100644 index 00000000..72d29d3f --- /dev/null +++ b/web/api/ApproveModuleAdapter.js @@ -0,0 +1,68 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import LogViewAdapter from './LogViewAdapter'; + +class ApproveModuleAdapter extends LogViewAdapter { + cancelRequest(id) { + const object = {}; + object.id = id; + + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'cancelSuccessCallBack'; + callBackData.callBackFail = 'cancelFailCallBack'; + + this.customAction('cancel', `modules=${this.modulePathName}`, reqJson, callBackData); + } + + // eslint-disable-next-line no-unused-vars + cancelSuccessCallBack(callBackData) { + this.showMessage('Successful', `${this.itemName} cancellation request sent`); + this.get([]); + } + + cancelFailCallBack(callBackData) { + this.showMessage(`Error Occurred while cancelling ${this.itemName}`, callBackData); + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + const deleteButton = ''; + const requestCancellationButton = ``; + const viewLogsButton = ''; + + + let html = '
    _edit__logs__delete_
    '; + + html = html.replace('_logs_', viewLogsButton); + + if (this.showDelete) { + if (data[7] === 'Approved') { + html = html.replace('_delete_', requestCancellationButton); + } else if (data[7] === 'Pending' || this.user.user_level === 'Admin') { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + +export default ApproveModuleAdapter; diff --git a/web/api/Base.js b/web/api/Base.js deleted file mode 100644 index 8534f331..00000000 --- a/web/api/Base.js +++ /dev/null @@ -1,2639 +0,0 @@ -/* -This file is part of Ice Framework. - -Ice Framework is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ice Framework is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Ice Framework. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - - - -/** - * The base class for providing core functions to all module classes. - * @class Base.js - */ -function IceHRMBase() { - this.deleteParams = {}; - this.createRemoteTable = false; - this.instanceId = "None"; - this.ga = []; - this.showEdit = true; - this.showDelete = true; - this.showSave = true; - this.showCancel = true; - this.showFormOnPopup = false; - this.filtersAlreadySet = false; - this.currentFilterString = ""; - this.sorting = 0; - this.settings = {}; - this.translations = {}; - this.customFields = []; - this.csrfRequired = false; -} - -this.fieldTemplates = null; -this.templates = null; -this.customTemplates = null; -this.emailTemplates = null; -this.fieldMasterData = null; -this.fieldMasterDataKeys = null; -this.fieldMasterDataCallback = null; -this.sourceMapping = null; -this.currentId = null; -this.currentElement = null; -this.user = null; -this.currentProfile = null; -this.permissions = {}; - - - -this.baseUrl = null; - -IceHRMBase.method('init' , function(appName, currentView, dataUrl, permissions) { - -}); - -/** - * Some browsers do not support sending JSON in get parameters. Set this to true to avoid sending JSON - * @method setNoJSONRequests - * @param val {Boolean} - */ -IceHRMBase.method('setNoJSONRequests' , function(val) { - this.noJSONRequests = val; -}); - - -IceHRMBase.method('setPermissions' , function(permissions) { - this.permissions = permissions; -}); - -IceHRMBase.method('sortingStarted' , function(val) { - this.sorting = val; -}); - -/** - * Check if the current user has a permission - * @method checkPermission - * @param permission {String} - * @example - * this.checkPermission("Upload/Delete Profile Image") - */ -IceHRMBase.method('checkPermission' , function(permission) { - if(this.permissions[permission] == undefined || this.permissions[permission] == null || this.permissions[permission] == "Yes"){ - return "Yes"; - }else{ - return this.permissions[permission]; - } -}); - -IceHRMBase.method('setBaseUrl' , function(url) { - this.baseUrl = url; -}); - -IceHRMBase.method('setUser' , function(user) { - this.user = user; -}); - -IceHRMBase.method('getUser' , function() { - return this.user; -}); - -IceHRMBase.method('setInstanceId' , function(id) { - this.instanceId = id; -}); - -IceHRMBase.method('setCSRFRequired' , function(val) { - this.csrfRequired = val; -}); - -IceHRMBase.method('setGoogleAnalytics' , function(ga) { - this.ga = ga; -}); - -IceHRMBase.method('scrollToTop' , function() { - $("html, body").animate({ scrollTop: 0 }, "fast"); -}); - -IceHRMBase.method('scrollToBottom' , function() { - $("html, body").animate({ scrollTop: $(document).height() }, "slow"); -}); - -IceHRMBase.method('scrollToElement' , function(element) { - if($(window).height() <= element.offset().top){ - $("html, body").animate({ scrollTop: element.offset().top }, "slow"); - } - -}); - -IceHRMBase.method('scrollToElementBottom' , function(element) { - if($(window).height() <= element.offset().top + element.height()){ - $("html, body").animate({ scrollTop: element.offset().top + element.height() }, "slow"); - } - -}); - - -IceHRMBase.method('setTranslations' , function(txt) { - this.translations = txt['messages']['']; -}); - -IceHRMBase.method('setTranslationsSubModules' , function(translations) { - this.translations = translations; -}); - -IceHRMBase.method('gt' , function(key) { - if(this.translations[key] === undefined || this.translations[key] === null){ - return key; - } - return this.translations[key][0]; -}); - -IceHRMBase.method('addToLangTerms' , function(key) { - var termsArr; - var terms = localStorage.getItem("terms"); - if(terms == undefined){ - termsArr = {}; - }else{ - try{ - termsArr = JSON.parse(terms); - }catch(e){ - termsArr = {}; - } - - } - - if(this.translations[key] == undefined){ - termsArr[key] = key; - localStorage.setItem("terms", JSON.stringify(termsArr)); - } -}); - -/** - * If this method returned false the action buttons in data table for modules will not be displayed. - * Override this method in module lib.js to hide action buttons - * @method showActionButtons - * @param permission {String} - * @example - * EmployeeLeaveEntitlementAdapter.method('showActionButtons' , function() { - * return false; - * }); - */ -IceHRMBase.method('showActionButtons' , function() { - return true; -}); - -IceHRMBase.method('trackEvent' , function(action, label, value) { - try{ - if(label == undefined || label == null){ - this.ga.push(['_trackEvent', this.instanceId, action]); - }else if(value == undefined || value == null){ - this.ga.push(['_trackEvent', this.instanceId, action, label]); - }else{ - this.ga.push(['_trackEvent', this.instanceId, action, label, value]); - } - }catch(e){ - - } - - -}); - - -IceHRMBase.method('setCurrentProfile' , function(currentProfile) { - this.currentProfile = currentProfile; -}); - -/** - * Get the current profile - * @method getCurrentProfile - * @returns Profile of the current user if the profile is not switched if not switched profile - */ - -IceHRMBase.method('getCurrentProfile' , function() { - return this.currentProfile; -}); - -/** - * Retrive data required to create select boxes for add new /edit forms for a given module. This is called when loading the module - * @method initFieldMasterData - * @param callback {Function} call this once loading completed - * @param callback {Function} call this once all field loading completed. This indicate that the form can be displayed saftly - * @example - * ReportAdapter.method('renderForm', function(object) { - * var that = this; - * this.processFormFieldsWithObject(object); - * var cb = function(){ - * that.uber('renderForm',object); - * }; - * this.initFieldMasterData(cb); - * }); - */ -IceHRMBase.method('initFieldMasterData' , function(callback, loadAllCallback, loadAllCallbackData) { - var values; - if(this.showAddNew == undefined || this.showAddNew == null){ - this.showAddNew = true; - } - this.fieldMasterData = {}; - this.fieldMasterDataKeys = {}; - this.fieldMasterDataCallback = loadAllCallback; - this.fieldMasterDataCallbackData = loadAllCallbackData; - this.sourceMapping = {}; - var fields = this.getFormFields(); - var filterFields = this.getFilters(); - - if(filterFields != null){ - for(var j=0;j'; - } - - if(this.getFilters() != null){ - if(html != ""){ - html += "  "; - } - html+=''; - html += "  "; - if(this.filtersAlreadySet){ - html+=''; - }else{ - html+=''; - } - - } - - html = html.replace(/__id__/g, this.getTableName()); - - if(this.currentFilterString != "" && this.currentFilterString != null){ - html = html.replace(/__filterString__/g, this.currentFilterString); - }else{ - html = html.replace(/__filterString__/g, 'Reset Filters'); - } - - if(html != ""){ - html = '
    '+html+'
    '; - } - - return html; -}); - - -IceHRMBase.method('getActionButtonHeader', function() { - return { "sTitle": "", "sClass": "center" }; -}); - -IceHRMBase.method('getTableHTMLTemplate', function() { - return '
    '; -}); - -IceHRMBase.method('isSortable', function() { - return true; -}); - -/** - * Create the data table on provided element id - * @method createTable - * @param val {Boolean} - */ - -IceHRMBase.method('createTable', function(elementId) { - - - var that = this; - - if(this.getRemoteTable()){ - this.createTableServer(elementId); - return; - } - - - var headers = this.getHeaders(); - - //add translations - for(index in headers){ - headers[index].sTitle = this.gt(headers[index].sTitle); - } - - var data = this.getTableData(); - - if(this.showActionButtons()){ - headers.push(this.getActionButtonHeader()); - } - - - if(this.showActionButtons()){ - for(var i=0;i
    '; - }else{ - html = '
    '; - } - */ - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*15 - 15; - } - - $('#'+elementId).html(html); - - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "aaData": data, - "aoColumns": headers, - "bSort": that.isSortable(), - "iDisplayLength": 15, - "iDisplayStart": start - }; - - - var customTableParams = this.getCustomTableParams(); - - $.extend(dataTableParams, customTableParams); - - $('#'+elementId+' #grid').dataTable( dataTableParams ); - - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - $('.tableActionButton').tooltip(); -}); - -/** - * Create a data table on provided element id which loads data page by page - * @method createTableServer - * @param val {Boolean} - */ - -IceHRMBase.method('createTableServer', function(elementId) { - var that = this; - var headers = this.getHeaders(); - - headers.push({ "sTitle": "", "sClass": "center" }); - - //add translations - for(index in headers){ - headers[index].sTitle = this.gt(headers[index].sTitle); - } - - var html = ""; - html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); - /* - if(this.getShowAddNew()){ - html = this.getTableTopButtonHtml()+'
    '; - }else{ - html = '
    '; - } - */ - - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*15 - 15; - } - - - $('#'+elementId).html(html); - - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "bProcessing": true, - "bServerSide": true, - "sAjaxSource": that.getDataUrl(that.getDataMapping()), - "aoColumns": headers, - "bSort": that.isSortable(), - "parent":that, - "iDisplayLength": 15, - "iDisplayStart": start - }; - - if(this.showActionButtons()){ - dataTableParams["aoColumnDefs"] = [ - { - "fnRender": that.getActionButtons, - "aTargets": [that.getDataMapping().length] - } - ]; - } - - var customTableParams = this.getCustomTableParams(); - - $.extend(dataTableParams, customTableParams); - - $('#'+elementId+' #grid').dataTable( dataTableParams ); - - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - - $('.tableActionButton').tooltip(); - -}); - -/** - * This should be overridden in module lib.js classes to return module headers which are used to create the data table. - * @method getHeaders - * @example - SettingAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Value"}, - { "sTitle": "Details"} - ]; - }); - */ -IceHRMBase.method('getHeaders', function() { - -}); - - -/** - * This should be overridden in module lib.js classes to return module field values which are used to create the data table. - * @method getDataMapping - * @example - SettingAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "value", - "description" - ]; - }); - */ - -IceHRMBase.method('getDataMapping', function() { - -}); - -/** - * This should be overridden in module lib.js classes to return module from fields which are used to create the add/edit form and also used for initializing select box values in form. - * @method getFormFields - * @example - SettingAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "value", {"label":"Value","type":"text","validation":"none"}] - ]; - }); - */ -IceHRMBase.method('getFormFields', function() { - -}); - -IceHRMBase.method('getTableData', function() { - -}); - -/** - * This can be overridden in module lib.js classes inorder to show a filter form - * @method getFilters - * @example - EmployeeAdapter.method('getFilters', function() { - return [ - [ "job_title", {"label":"Job Title","type":"select2","allow-null":true,"null-label":"All Job Titles","remote-source":["JobTitle","id","name"]}], - [ "department", {"label":"Department","type":"select2","allow-null":true,"null-label":"All Departments","remote-source":["CompanyStructure","id","title"]}], - [ "supervisor", {"label":"Supervisor","type":"select2","allow-null":true,"null-label":"Anyone","remote-source":["Employee","id","first_name+last_name"]}] - ]; - }); - */ -IceHRMBase.method('getFilters', function() { - return null; -}); - -/** - * Show the edit form for an item - * @method edit - * @param id {int} id of the item to edit - */ -IceHRMBase.method('edit', function(id) { - this.currentId = id; - this.getElement(id,[]); -}); - -IceHRMBase.method('copyRow', function(id) { - this.getElement(id,[],true); -}); - -IceHRMBase.method('renderModel', function(id,header,body) { - $('#'+id+'ModelBody').html(""); - - if(body == undefined || body == null){ - body = ""; - } - - $('#'+id+'ModelLabel').html(header); - $('#'+id+'ModelBody').html(body); -}); - - -IceHRMBase.method('renderYesNoModel', function(header,body,yesBtnName,noBtnName,callback, callbackParams) { - var that = this; - var modelId = "#yesnoModel"; - - if(body == undefined || body == null){ - body = ""; - } - - $(modelId+'Label').html(header); - $(modelId+'Body').html(body); - if(yesBtnName != null){ - $(modelId+'YesBtn').html(yesBtnName); - } - if(noBtnName != null){ - $(modelId+'NoBtn').html(noBtnName); - } - - $(modelId+'YesBtn').off().on('click',function(){ - if(callback != undefined && callback != null){ - callback.apply(that,callbackParams); - that.cancelYesno(); - } - }); - - $(modelId).modal({ - backdrop: 'static' - }); - - -}); - -IceHRMBase.method('renderModelFromDom', function(id,header,element) { - $('#'+id+'ModelBody').html(""); - - if(element == undefined || element == null){ - element = $("
    "); - } - - $('#'+id+'ModelLabel').html(header); - $('#'+id+'ModelBody').html(""); - $('#'+id+'ModelBody').append(element); -}); - -/** - * Delete an item - * @method deleteRow - * @param id {int} id of the item to edit - */ - -IceHRMBase.method('deleteRow', function(id) { - this.deleteParams['id'] = id; - this.renderModel('delete',"Confirm Deletion","Are you sure you want to delete this item ?"); - $('#deleteModel').modal('show'); - -}); - -/** - * Show a popup with message - * @method showMessage - * @param title {String} title of the message box - * @param message {String} message - * @param closeCallback {Function} this will be called once the dialog is closed (optional) - * @param closeCallback {Function} data to pass to close callback (optional) - * @param isPlain {Boolean} if true buttons are not shown (optional / default = true) - * @example - * this.showMessage("Error Occured while Applying Leave", callBackData); - */ -IceHRMBase.method('showMessage', function(title,message,closeCallback,closeCallbackData, isPlain) { - var that = this; - var modelId = ""; - if(isPlain){ - modelId = "#plainMessageModel"; - }else{ - modelId = "#messageModel"; - } - - $(modelId).off(); - - if(isPlain){ - this.renderModel('plainMessage',title,message); - }else{ - this.renderModel('message',title,message); - } - - if(closeCallback !== null && closeCallback !== undefined){ - $(modelId).modal({show:true}); - $(modelId).on('hidden.bs.modal',function(){ - closeCallback.apply(that,closeCallbackData); - $('.modal-backdrop').remove(); - }); - } else { - $(modelId).modal({ - backdrop: 'static' - }); - } -}); - -IceHRMBase.method('showDomElement', function(title,element,closeCallback,closeCallbackData, isPlain) { - var that = this; - var modelId = ""; - if (isPlain) { - modelId = "#dataMessageModel"; - } else{ - modelId = "#messageModel"; - } - - $(modelId).unbind('hide'); - - if(isPlain){ - this.renderModelFromDom('dataMessage',title,element); - }else{ - this.renderModelFromDom('message',title,element); - } - - - if(closeCallback !== null && closeCallback !== undefined){ - $(modelId).modal({show:true}); - $(modelId).on('hidden.bs.modal',function(){ - closeCallback.apply(that,closeCallbackData); - $('.modal-backdrop').remove(); - }); - } else { - $(modelId).modal({ - backdrop: 'static' - }); - } -}); - -IceHRMBase.method('confirmDelete', function() { - if(this.deleteParams['id'] != undefined || this.deleteParams['id'] != null){ - this.deleteObj(this.deleteParams['id'],[]); - } - $('#deleteModel').modal('hide'); -}); - -IceHRMBase.method('cancelDelete', function() { - $('#deleteModel').modal('hide'); - this.deleteParams['id'] = null; -}); - -IceHRMBase.method('closeMessage', function() { - $('#messageModel').modal('hide'); -}); - -IceHRMBase.method('cancelYesno', function() { - $('#yesnoModel').modal('hide'); -}); - -IceHRMBase.method('closePlainMessage', function() { - $('#plainMessageModel').modal('hide'); - $('#dataMessageModel').modal('hide'); -}); - -IceHRMBase.method('closeDataMessage', function() { - $('#dataMessageModel').modal('hide'); -}); - - -/** - * Create or edit an element - * @method save - * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters - * @param successCallback {Function} this will get called after success response - */ - -IceHRMBase.method('save', function(callGetFunction, successCallback) { - var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - params = this.forceInjectValuesBeforeSave(params); - var msg = this.doCustomValidation(params); - if(msg == null){ - if (this.csrfRequired) { - params['csrf'] = $('#'+this.getTableName()+'Form').data('csrf'); - } - var id = $('#'+this.getTableName()+"_submit #id").val(); - if(id != null && id != undefined && id != ""){ - params['id'] = id; - } - params = this.makeEmptyDateFieldsNull(params); - this.add(params,[],callGetFunction, successCallback); - }else{ - $("#"+this.getTableName()+'Form .label').html(msg); - $("#"+this.getTableName()+'Form .label').show(); - this.scrollToTop(); - } - - } -}); - - -IceHRMBase.method('makeEmptyDateFieldsNull', function(params) { - var fields = this.getFormFields(); - fields.forEach(function(field) { - if((field[1].type == 'date' || field[1].type == 'datetime') - && (params[field[0]] === '' || params[field[0]] === '0000-00-00' || params[field[0]] === '0000-00-00 00:00:00')){ - delete params[field[0]]; - } - }); - return params; -}); - -/** - * Override this method to inject attitional parameters or modify existing parameters retrived from add/edit form before sending to the server - * @method forceInjectValuesBeforeSave - * @param params {Array} keys and values in form - * @returns {Array} modified parameters - */ -IceHRMBase.method('forceInjectValuesBeforeSave', function(params) { - return params; -}); - -/** - * Override this method to do custom validations at client side - * @method doCustomValidation - * @param params {Array} keys and values in form - * @returns {Null or String} return null if validation success, returns error message if unsuccessful - * @example - EmployeeLeaveAdapter.method('doCustomValidation', function(params) { - try{ - if(params['date_start'] != params['date_end']){ - var ds = new Date(params['date_start']); - var de = new Date(params['date_end']); - if(de < ds){ - return "Start date should be earlier than end date of the leave period"; - } - } - }catch(e){ - - } - return null; -}); - */ -IceHRMBase.method('doCustomValidation', function(params) { - return null; -}); - -IceHRMBase.method('filterQuery', function() { - - var validator = new FormValidation(this.getTableName()+"_filter",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - if(this.doCustomFilterValidation(params)){ - - //remove null params - for (var prop in params) { - if(params.hasOwnProperty(prop)){ - if(params[prop] == "NULL"){ - delete(params[prop]); - } - } - } - - this.setFilter(params); - this.filtersAlreadySet = true; - $("#"+this.getTableName()+"_resetFilters").show(); - this.currentFilterString = this.getFilterString(params); - - this.get([]); - this.closePlainMessage(); - } - - } -}); - - -IceHRMBase.method('getFilterString', function(filters) { - - var str = ''; - var rmf, source, values, select2MVal, value, valueOrig; - - var filterFields = this.getFilters(); - - - if(values == null){ - values = []; - } - - for (var prop in filters) { - if(filters.hasOwnProperty(prop)){ - values = this.getMetaFieldValues(prop,filterFields); - value = ""; - valueOrig = null; - - if((values['type'] == 'select' || values['type'] == 'select2')){ - - if(values['remote-source']!= undefined && values['remote-source']!= null){ - rmf = values['remote-source']; - if(filters[prop] == "NULL"){ - if(values['null-label'] != undefined && values['null-label'] != null){ - value = values['null-label']; - }else{ - value = "Not Selected"; - } - }else{ - value = this.fieldMasterData[rmf[0]+"_"+rmf[1]+"_"+rmf[2]][filters[prop]]; - valueOrig = value; - } - - - }else{ - source = values['source'][0]; - if(filters[prop] == "NULL"){ - if(values['null-label'] != undefined && values['null-label'] != null){ - value = values['null-label']; - }else{ - value = "Not Selected"; - } - }else{ - for(var i=0; i'); - $tempDomObj.attr('id',randomFormId); - - $tempDomObj.html(formHtml); - - - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false - }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' - }); - - $tempDomObj.find('.colorpick').colorpicker(); - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); - - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); - - //$tempDomObj.find('.select2Field').select2(); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - }); - - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - }); - - /* - $tempDomObj.find('.signatureField').each(function() { - $(this).data('signaturePad',new SignaturePad($(this))); - }); - */ - - //var tHtml = $tempDomObj.wrap('
    ').parent().html(); - this.showDomElement("Edit",$tempDomObj,null,null,true); - $(".filterBtn").off(); - $(".filterBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.filterQuery(); - - }catch(e){ - }; - return false; - }); - - if (this.filter != undefined && this.filter != null && this.filter != '') { - this.fillForm(this.filter,"#"+this.getTableName()+"_filter", this.getFilters()); - } - -}); - - -/** - * Override this method in your module class to make changes to data fo the form before showing the form - * @method preRenderForm - * @param object {Array} keys value list for populating form - */ - -IceHRMBase.method('preRenderForm', function(object) { - -}); - -/** - * Create the form - * @method renderForm - * @param object {Array} keys value list for populating form - */ - -IceHRMBase.method('renderForm', function(object) { - - var that = this; - var signatureIds = []; - if(object == null || object == undefined){ - this.currentId = null; - } - - this.preRenderForm(object); - - var formHtml = this.templates['formTemplate']; - var html = ""; - var fields = this.getFormFields(); - - for(var i=0;i
    '); - $tempDomObj.attr('id',randomFormId); - - } - - $tempDomObj.html(formHtml); - - - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false - }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' - }); - - $tempDomObj.find('.colorpick').colorpicker(); - - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); - - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); - - //$tempDomObj.find('.select2Field').select2(); - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - - }); - - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - - }); - - - $tempDomObj.find('.signatureField').each(function() { - //$(this).data('signaturePad',new SignaturePad($(this))); - signatureIds.push($(this).attr('id')); - }); - - for(var i=0;i').parent().html(); - //this.showMessage("Edit",tHtml,null,null,true); - this.showMessage("Edit","",null,null,true); - - $("#plainMessageModel .modal-body").html(""); - $("#plainMessageModel .modal-body").append($tempDomObj); - - - for(var i=0;i
  • '; - editButton = '
  • '; - - template = field[1]['html']; - - if(data != null && data != undefined && field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ - data.sort(field[1]['sort-function']); - } - - - html = $('
    '); - - - - for(i=0;i'); - } - t = t.replace('#_'+key+'_#', itemVal); - } - - if(field[1]['render'] != undefined && field[1]['render'] != null){ - t = t.replace('#_renderFunction_#', field[1]['render'](item)); - } - - itemHtml = $(t); - itemHtml.attr('fieldId',field[0]+"_div"); - html.append(itemHtml); - } - - - - return html; -}); - -/** - * Reset the DataGroup for a given field - * @method resetDataGroup - * @param field {Array} field meta data - */ -IceHRMBase.method('resetDataGroup', function(field) { - $("#"+field[0]).val(""); - $("#"+field[0]+"_div").html(""); -}); - -IceHRMBase.method('showDataGroup', function(field, object) { - var formHtml = this.templates['datagroupTemplate']; - var html = ""; - var fields = field[1]['form']; - - if(object != undefined && object != null && object.id != undefined){ - this.currentDataGroupItemId = object.id; - }else{ - this.currentDataGroupItemId = null; - } - - for(var i=0;i'); - $tempDomObj.attr('id',randomFormId); - - $tempDomObj.html(formHtml); - - - $tempDomObj.find('.datefield').datepicker({'viewMode':2}); - $tempDomObj.find('.timefield').datetimepicker({ - language: 'en', - pickDate: false - }); - $tempDomObj.find('.datetimefield').datetimepicker({ - language: 'en' - }); - - $tempDomObj.find('.colorpick').colorpicker(); - - tinymce.init({ - selector: '#'+$tempDomObj.attr('id')+' .tinymce', - height: "400" - }); - - $tempDomObj.find('.simplemde').each(function() { - var simplemde = new SimpleMDE({ element: $(this)[0] }); - $(this).data('simplemde', simplemde); - //simplemde.value($(this).val()); - }); - - $tempDomObj.find('.select2Field').each(function() { - $(this).select2().select2('val', $(this).find("option:eq(0)").val()); - }); - - - $tempDomObj.find('.select2Multi').each(function() { - $(this).select2().on("change",function(e){ - var parentRow = $(this).parents(".row"); - var height = parentRow.find(".select2-choices").height(); - parentRow.height(parseInt(height)); - }); - }); - - /* - $tempDomObj.find('.signatureField').each(function() { - $(this).data('signaturePad',new SignaturePad($(this))); - }); - */ - - this.currentDataGroupField = field; - this.showDomElement("Add "+field[1]['label'],$tempDomObj,null,null,true); - - if (object != undefined && object != null) { - this.fillForm(object,"#"+this.getTableName()+"_field_"+field[0], field[1]['form']); - } else { - this.setDefaultValues("#"+this.getTableName()+"_field_"+field[0], field[1]['form']); - } - - - $(".groupAddBtn").off(); - if(object != undefined && object != null && object.id != undefined){ - $(".groupAddBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.editDataGroup(); - - }catch(e){ - }; - return false; - }); - }else{ - $(".groupAddBtn").on('click',function(e) { - e.preventDefault(); - e.stopPropagation(); - try{ - modJs.addDataGroup(); - - }catch(e){ - }; - return false; - }); - } - - -}); - -IceHRMBase.method('addDataGroup', function() { - var field = this.currentDataGroupField, tempParams; - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(""); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").hide(); - var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ - tempParams = field[1]['custom-validate-function'].apply(this,[params]); - if(tempParams['valid']){ - params = tempParams['params']; - }else{ - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); - return false; - } - } - - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); - - params['id'] = field[0]+"_"+this.dataGroupGetNextAutoIncrementId(data); - data.push(params); - - - if(field[1]['sort-function'] != undefined && field[1]['sort-function'] != null){ - data.sort(field[1]['sort-function']); - } - - val = JSON.stringify(data); - - var html = this.dataGroupToHtml(val,field); - - $("#"+field[0]+"_div").html(""); - $("#"+field[0]+"_div").append(html); - - this.makeDataGroupSortable(field, $("#"+field[0]+"_div_inner")); - - - $("#"+field[0]).val(val); - this.orderDataGroup(field); - - this.closeDataMessage(); - - this.showMessage("Item Added","This change will be effective only when you save the form"); - - - } -}); - -IceHRMBase.method('nl2br' , function(str, len) { - var t = ""; - try{ - var arr = str.split(" "); - var count = 0; - for(var i=0;i len){ - t += arr[i] + "
    "; - count = 0; - }else{ - t += arr[i] + " "; - } - } - }catch(e){} - return t; -}); - -IceHRMBase.method('makeDataGroupSortable', function(field, obj) { - obj.data('field',field); - obj.data('firstSort',true); - obj.sortable({ - - create:function(){ - $(this).height($(this).height()); - }, - - 'ui-floating': false, - start: function(e, ui) { - $('#sortable-ul-selector-id').sortable({ - sort: function(event, ui) { - var $target = $(event.target); - if (!/html|body/i.test($target.offsetParent()[0].tagName)) { - var top = event.pageY - $target.offsetParent().offset().top - (ui.helper.outerHeight(true) / 2); - ui.helper.css({'top' : top + 'px'}); - } - } - }); - - }, - revert: true, - stop: function() { - modJs.orderDataGroup($(this).data('field')); - }, - axis: "y", - scroll: false, - placeholder: "sortable-placeholder", - cursor: "move" - }); - - -}); - -IceHRMBase.method('orderDataGroup', function(field) { - var newArr = [], id; - var list = $("#"+field[0]+"_div_inner [fieldid='"+field[0]+"_div']"); - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); - list.each(function(){ - id = $(this).attr('id'); - for(index in data){ - if(data[index].id == id){ - newArr.push(data[index]); - break; - } - } - }); - - $("#"+field[0]).val(JSON.stringify(newArr)); - - -}); - - -IceHRMBase.method('editDataGroup', function() { - var field = this.currentDataGroupField; - var id = this.currentDataGroupItemId; - var validator = new FormValidation(this.getTableName()+"_field_"+field[0],true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - var params = validator.getFormParameters(); - - if(field[1]['custom-validate-function'] != undefined && field[1]['custom-validate-function'] != null){ - tempParams = field[1]['custom-validate-function'].apply(this,[params]); - if(tempParams['valid']){ - params = tempParams['params']; - }else{ - $("#"+this.getTableName()+"_field_"+field[0]+"_error").html(tempParams['message']); - $("#"+this.getTableName()+"_field_"+field[0]+"_error").show(); - return false; - } - } - - - if(this.doCustomFilterValidation(params)){ - - var val = $("#"+field[0]).val(); - if(val == ""){ - val = "[]"; - } - var data = JSON.parse(val); - - var editVal = {}; - var editValIndex = -1; - var newVals = []; - for(var i=0;i= autoId){ - autoId = parseInt(id) + 1; - } - } - - return autoId; - -}); - - -IceHRMBase.method('deleteDataGroupItem', function(id) { - var fieldId = id.substring(0,id.lastIndexOf("_")); - - var val = $("#"+fieldId).val(); - var data = JSON.parse(val); - - var newVal = []; - - for(var i=0;i'); - }catch(e){} - - } - - $(formId + ' #'+fields[i][0]).html(placeHolderVal); - }else if(fields[i][1].type == 'fileupload'){ - if(object[fields[i][0]] != null && object[fields[i][0]] != undefined && object[fields[i][0]] != ""){ - $(formId + ' #'+fields[i][0]).html(object[fields[i][0]]); - $(formId + ' #'+fields[i][0]).attr("val",object[fields[i][0]]); - $(formId + ' #'+fields[i][0]).show(); - $(formId + ' #'+fields[i][0]+"_download").show(); - $(formId + ' #'+fields[i][0]+"_remove").show(); - - } - if(fields[i][1].readonly == true){ - $(formId + ' #'+fields[i][0]+"_upload").remove(); - } - }else if(fields[i][1].type == 'select'){ - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - - }else if(fields[i][1].type == 'select2'){ - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } - $(formId + ' #'+fields[i][0]).select2('val',object[fields[i][0]]); - - }else if(fields[i][1].type == 'select2multi'){ - //TODO - SM - if(object[fields[i][0]] == undefined || object[fields[i][0]] == null || object[fields[i][0]] == ""){ - object[fields[i][0]] = "NULL"; - } - - var msVal = []; - if(object[fields[i][0]] != undefined && object[fields[i][0]] != null && object[fields[i][0]] != ""){ - try{ - msVal = JSON.parse(object[fields[i][0]]); - }catch(e){} - } - - $(formId + ' #'+fields[i][0]).select2('val',msVal); - var select2Height = $(formId + ' #'+fields[i][0]).find(".select2-choices").height(); - $(formId + ' #'+fields[i][0]).find(".controls").css('min-height', select2Height+"px"); - $(formId + ' #'+fields[i][0]).css('min-height', select2Height+"px"); - - }else if(fields[i][1].type == 'datagroup'){ - try{ - var html = this.dataGroupToHtml(object[fields[i][0]],fields[i]); - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - $(formId + ' #'+fields[i][0]+"_div").html(""); - $(formId + ' #'+fields[i][0]+"_div").append(html); - - this.makeDataGroupSortable(fields[i], $(formId + ' #'+fields[i][0]+"_div_inner")); - - - }catch(e){} - - }else if(fields[i][1].type == 'signature'){ - - if(object[fields[i][0]] != '' || object[fields[i][0]] != undefined - || object[fields[i][0]] != null){ - $(formId + ' #'+fields[i][0]).data('signaturePad').fromDataURL(object[fields[i][0]]); - } - }else if(fields[i][1].type == 'simplemde'){ - $(formId + ' #'+fields[i][0]).data('simplemde').value(object[fields[i][0]]); - }else{ - $(formId + ' #'+fields[i][0]).val(object[fields[i][0]]); - } - - } -}); - -/** - * Cancel edit or add new on modules - * @method cancel - */ - -IceHRMBase.method('cancel', function() { - $("#"+this.getTableName()+'Form').hide(); - $("#"+this.getTableName()).show(); -}); - -IceHRMBase.method('renderFormField', function(field) { - var userId = 0; - if(this.fieldTemplates[field[1].type] == undefined || this.fieldTemplates[field[1].type] == null){ - return ""; - } - var t = this.fieldTemplates[field[1].type]; - field[1].label = this.gt(field[1].label); - if(field[1].validation != "none" && field[1].validation != "emailOrEmpty" && field[1].validation != "numberOrEmpty" && field[1].type != "placeholder" && field[1].label.indexOf('*') < 0){ - var tempSelectBoxes = ['select','select2']; - if(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] == true){ - - }else{ - field[1].label = field[1].label + '*'; - } - - } - if(field[1].type == 'text' || field[1].type == 'textarea' || field[1].type == 'hidden' || field[1].type == 'label' || field[1].type == 'placeholder'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'select' || field[1].type == 'select2' || field[1].type == 'select2multi'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - if(field[1]['source'] != undefined && field[1]['source'] != null ){ - t = t.replace('_options_',this.renderFormSelectOptions(field[1].source, field)); - }else if(field[1]['remote-source'] != undefined && field[1]['remote-source'] != null ){ - var key = field[1]['remote-source'][0]+"_"+field[1]['remote-source'][1]+"_"+field[1]['remote-source'][2]; - t = t.replace('_options_',this.renderFormSelectOptionsRemote(this.fieldMasterData[key],field)); - } - - }else if(field[1].type == 'colorpick'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'date'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'datetime'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'time'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'fileupload'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - var ce = this.getCurrentProfile(); - if(ce != null && ce != undefined){ - userId = ce.id; - }else{ - userId = this.getUser().id * -1; - } - t = t.replace(/_userId_/g,userId); - t = t.replace(/_group_/g,this.tab); - - if(field[1].filetypes != undefined && field[1].filetypes != null){ - t = t.replace(/_filetypes_/g,field[1].filetypes); - }else{ - t = t.replace(/_filetypes_/g,'all'); - } - - t = t.replace(/_rand_/g,this.generateRandom(14)); - - }else if(field[1].type == 'datagroup'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'signature'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - - }else if(field[1].type == 'tinymce' || field[1].type == 'simplemde'){ - t = t.replace(/_id_/g,field[0]); - t = t.replace(/_label_/g,field[1].label); - } - - - if(field[1].validation != undefined && field[1].validation != null && field[1].validation != "") { - t = t.replace(/_validation_/g,'validation="'+field[1].validation+'"'); - }else{ - t = t.replace(/_validation_/g,''); - } - - if(field[1].help !== undefined && field[1].help !== null){ - t = t.replace(/_helpline_/g,field[1].help); - t = t.replace(/_hidden_class_help_/g,''); - }else{ - t = t.replace(/_helpline_/g,''); - t = t.replace(/_hidden_class_help_/g,'hide'); - } - - if (field[1].placeholder !== undefined && field[1].placeholder !== null) { - t = t.replace(/_placeholder_/g,'placeholder="'+field[1].placeholder+'"'); - }else{ - t = t.replace(/_placeholder_/g,''); - } - - if (field[1].mask !== undefined && field[1].mask !== null) { - t = t.replace(/_mask_/g,'mask="'+field[1].mask+'"'); - }else{ - t = t.replace(/_mask_/g,''); - } - - return t; -}); - -IceHRMBase.method('renderFormSelectOptions', function(options, field) { - var html = ""; - - if(field != null && field != undefined){ - if(field[1]['allow-null'] == true){ - if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ - html += ''; - }else{ - html += ''; - } - - } - } - - - //Sort options - - var tuples = []; - - for (var key in options) { - tuples.push(options[key]); - } - if(field[1]['sort'] === true){ - tuples.sort(function(a, b) { - a = a[1]; - b = b[1]; - - return a < b ? -1 : (a > b ? 1 : 0); - }); - } - - - for (var i = 0; i < tuples.length; i++) { - var prop = tuples[i][0]; - var value = tuples[i][1]; - var t = ''; - t = t.replace('_id_', prop); - t = t.replace('_val_', this.gt(value)); - html += t; - - } - return html; - -}); - -IceHRMBase.method('renderFormSelectOptionsRemote', function(options,field) { - var html = ""; - if(field[1]['allow-null'] == true){ - if(field[1]['null-label'] != undefined && field[1]['null-label'] != null){ - html += ''; - }else{ - html += ''; - } - - } - - //Sort options - - var tuples = []; - - for (var key in options) { - tuples.push([key, options[key]]); - } - if(field[1]['sort'] === 'true') { - tuples.sort(function (a, b) { - a = a[1]; - b = b[1]; - - return a < b ? -1 : (a > b ? 1 : 0); - }); - } - - for (var i = 0; i < tuples.length; i++) { - var prop = tuples[i][0]; - var value = tuples[i][1]; - - var t = ''; - t = t.replace('_id_', prop); - t = t.replace('_val_', this.gt(value)); - html += t; - } - - - return html; - -}); - -IceHRMBase.method('setTemplates', function(templates) { - this.templates = templates; -}); - -IceHRMBase.method('setCustomTemplates', function(templates) { - this.customTemplates = templates; -}); - -IceHRMBase.method('setEmailTemplates', function(templates) { - this.emailTemplates = templates; -}); - -IceHRMBase.method('getCustomTemplate', function(file) { - return this.customTemplates[file]; -}); - -IceHRMBase.method('setFieldTemplates', function(templates) { - this.fieldTemplates = templates; -}); - - -IceHRMBase.method('getMetaFieldForRendering', function(fieldName) { - return ""; -}); - -IceHRMBase.method('clearDeleteParams', function() { - this.deleteParams = {}; -}); - -IceHRMBase.method('getShowAddNew', function() { - return this.showAddNew; -}); - -/** - * Override this method to change add new button label - * @method getAddNewLabel - */ - -IceHRMBase.method('getAddNewLabel', function() { - return "Add New"; -}); - -/** - * Used to set whether to show the add new button for a module - * @method setShowAddNew - * @param showAddNew {Boolean} value - */ - -IceHRMBase.method('setShowAddNew', function(showAddNew) { - this.showAddNew = showAddNew; -}); - -/** - * Used to set whether to show delete button for each entry in module - * @method setShowDelete - * @param val {Boolean} value - */ -IceHRMBase.method('setShowDelete', function(val) { - this.showDelete = val; -}); - - -/** - * Used to set whether to show edit button for each entry in module - * @method setShowEdit - * @param val {Boolean} value - */ - -IceHRMBase.method('setShowEdit', function(val) { - this.showEdit = val; -}); - -/** - * Used to set whether to show save button in form - * @method setShowSave - * @param val {Boolean} value - */ - - -IceHRMBase.method('setShowSave', function(val) { - this.showSave = val; -}); - - -/** - * Used to set whether to show cancel button in form - * @method setShowCancel - * @param val {Boolean} value - */ - -IceHRMBase.method('setShowCancel', function(val) { - this.showCancel = val; -}); - -/** - * Datatable option array will be extended with associative array provided here - * @method getCustomTableParams - * @param val {Boolean} value - */ - - -IceHRMBase.method('getCustomTableParams', function() { - return {}; -}); - -IceHRMBase.method('getActionButtons', function(obj) { - return modJs.getActionButtonsHtml(obj.aData[0],obj.aData); -}); - - -/** - * This return html for action buttons in each row. Override this method if you need to make changes to action buttons. - * @method getActionButtonsHtml - * @param id {int} id of the row - * @param data {Array} data for the row - * @returns {String} html for action buttons - */ - -IceHRMBase.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var cloneButton = ''; - var html = '
    _edit__delete__clone_
    '; - - if(this.showAddNew){ - html = html.replace('_clone_',cloneButton); - }else{ - html = html.replace('_clone_',''); - } - - if(this.showDelete){ - html = html.replace('_delete_',deleteButton); - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - - -/** - * Generates a random string - * @method generateRandom - * @param length {int} required length of the string - * @returns {String} random string - */ - -IceHRMBase.method('generateRandom', function(length) { - var d = new Date(); - var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - var result = ''; - for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; - return result+d.getTime(); -}); - - - -IceHRMBase.method('checkFileType', function (elementName, fileTypes) { - var fileElement = document.getElementById(elementName); - var fileExtension = ""; - if (fileElement.value.lastIndexOf(".") > 0) { - fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf(".") + 1, fileElement.value.length); - } - - fileExtension = fileExtension.toLowerCase(); - - var allowed = fileTypes.split(","); - - if (allowed.indexOf(fileExtension) < 0) { - fileElement.value = ""; - this.showMessage("File Type Error",'Selected file type is not supported'); - this.clearFileElement(elementName); - return false; - } - - return true; - -}); - -IceHRMBase.method('clearFileElement', function (elementName) { - - var control = $("#"+elementName); - control.replaceWith( control = control.val('').clone( true ) ); -}); - - -IceHRMBase.method('fixJSON', function (json) { - if(this.noJSONRequests == "1"){ - json = window.btoa(json); - } - return json; - -}); - - -IceHRMBase.method('getClientDate', function (date) { - - var offset = this.getClientGMTOffset(); - var tzDate = date.addMinutes(offset*60); - return tzDate; - -}); - -IceHRMBase.method('getClientGMTOffset', function () { - - var rightNow = new Date(); - var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); - var temp = jan1.toGMTString(); - var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); - var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); - - return std_time_offset; - -}); - -/** - * Override this method in a module to provide the help link for the module. Help link of the module on frontend will get updated with this. - * @method getHelpLink - * @returns {String} help link - */ - -IceHRMBase.method('getHelpLink', function () { - - return null; - -}); - -IceHRMBase.method('showLoader', function () { - $('#iceloader').show(); -}); - -IceHRMBase.method('hideLoader', function () { - $('#iceloader').hide(); -}); - -IceHRMBase.method('generateOptions', function (data) { - var template = ''; - var options = ""; - for(index in data){ - options += template.replace("__val__",index).replace("__text__",data[index]); - } - - return options; -}); - -IceHRMBase.method('isModuleInstalled', function (type, name) { - if(modulesInstalled == undefined || modulesInstalled == null){ - return false; - } - - return (modulesInstalled[type+"_"+name] == 1); -}); - - -IceHRMBase.method('setCustomFields', function(fields) { - var field, parsed; - for(var i=0;i this.pageSize){ - this.hasMoreData = true; - serverData.pop(); - this.loadMoreButton.removeAttr('disabled'); - this.loadMoreButton.show(); + const data = []; + if (!addToTop && serverData.length > this.pageSize) { + this.hasMoreData = true; + serverData.pop(); + this.loadMoreButton.removeAttr('disabled'); + this.loadMoreButton.show(); } else if (!addToTop) { - this.hasMoreData = false; - this.loadMoreButton.hide(); + this.hasMoreData = false; + this.loadMoreButton.hide(); } if (!addToTop) { - this.scrollToElementBottom(this.container); + this.scrollToElementBottom(this.container); } - for(var i=0;i this.topLimit || this.topLimit === 0) { - this.topLimit = data[i].timeint; - this.topLimitUpdated = true; - } + if (data[i].timeint > this.topLimit || this.topLimit === 0) { + this.topLimit = data[i].timeint; + this.topLimitUpdated = true; + } } this.hideConversationLoader(); -}); + } -ConversationsAdapter.method('getConversationsFailCallBack', function(callBackData) { + getConversationsFailCallBack() { this.hideLoader(); this.hideConversationLoader(); if (this.timer !== null) { - clearTimeout(this.timer); - this.timer = null; + clearTimeout(this.timer); + this.timer = null; } -}); + } -ConversationsAdapter.method('getObjectHTML', function(object) { - var t = this.getCustomTemplate(this.getTemplateName()); + getObjectHTML(object) { + let t = this.getCustomTemplate(this.getTemplateName()); t = t.replace(new RegExp('#_id_#', 'g'), object.id); t = t.replace(new RegExp('#_message_#', 'g'), object.message); t = t.replace(new RegExp('#_employeeName_#', 'g'), object.employeeName); t = t.replace(new RegExp('#_employeeImage_#', 'g'), object.employeeImage); t = t.replace(new RegExp('#_date_#', 'g'), object.date); - if (object.attachment !== '' && object.attachment !== null && object.attachment !== undefined) { - var at = this.getCustomTemplate('attachment.html'); - at = at.replace(new RegExp('#_attachment_#', 'g'), object.attachment); - at = at.replace(new RegExp('#_icon_#', 'g'), this.getIconByFileType(object.file.type)); - at = at.replace(new RegExp('#_color_#', 'g'), this.getColorByFileType(object.file.type)); - at = at.replace(new RegExp('#_name_#', 'g'), object.file.name); - at = at.replace(new RegExp('#_size_#', 'g'), object.file.size_text); - t = t.replace(new RegExp('#_attachment_#', 'g'), at); + if (object.attachment !== '' && object.attachment !== null && object.attachment !== undefined) { + let at = this.getCustomTemplate('attachment.html'); + at = at.replace(new RegExp('#_attachment_#', 'g'), object.attachment); + at = at.replace(new RegExp('#_icon_#', 'g'), this.getIconByFileType(object.file.type)); + at = at.replace(new RegExp('#_color_#', 'g'), this.getColorByFileType(object.file.type)); + at = at.replace(new RegExp('#_name_#', 'g'), object.file.name); + at = at.replace(new RegExp('#_size_#', 'g'), object.file.size_text); + t = t.replace(new RegExp('#_attachment_#', 'g'), at); } else { - t = t.replace(new RegExp('#_attachment_#', 'g'), ''); + t = t.replace(new RegExp('#_attachment_#', 'g'), ''); } return t; + } -}); - -ConversationsAdapter.method('setPageSize', function(pageSize) { + setPageSize(pageSize) { this.pageSize = pageSize; -}); + } -ConversationsAdapter.method('addDomEvents', function(object) { + // eslint-disable-next-line no-unused-vars + addDomEvents(object) { -}); + } -ConversationsAdapter.method('getTemplateName', function() { + getTemplateName() { return 'conversation.html'; -}); + } -ConversationsAdapter.method('renderObject', function(object, addToTop) { + renderObject(object, addToTop) { + const objDom = this.getObjectDom(object.id); - var objDom = this.getObjectDom(object.id); - - var html = this.getObjectHTML(object); - var domObj = $(html); + const html = this.getObjectHTML(object); + const domObj = $(html); - if (objDom !== undefined && objDom !== null) { - objDom.replace(domObj); + if (objDom !== undefined && objDom !== null) { + objDom.replace(domObj); } else if (addToTop) { - this.container.prepend(domObj); - $('#obj_'+object.id).css('background-color', '#FFF8DC'); - $('#obj_'+object.id).fadeIn('slow'); - $('#obj_'+object.id).animate({backgroundColor: '#FFF'}, 'slow'); + this.container.prepend(domObj); + $(`#obj_${object.id}`).css('background-color', '#FFF8DC'); + $(`#obj_${object.id}`).fadeIn('slow'); + $(`#obj_${object.id}`).animate({ backgroundColor: '#FFF' }, 'slow'); } else { - this.container.append(domObj); - $('#obj_'+object.id).fadeIn('slow'); + this.container.append(domObj); + $(`#obj_${object.id}`).fadeIn('slow'); } if (domObj.find('.conversation-body').prop('scrollHeight') > 290) { - domObj.find('.conversation-expand').show(); + domObj.find('.conversation-expand').show(); } if (object.actionDelete === 1) { - domObj.find('.delete-button').show(); + domObj.find('.delete-button').show(); } this.addDomEvents(domObj); -}); + } -ConversationsAdapter.method('setContainer', function(container) { + setContainer(container) { this.container = container; -}); + } -ConversationsAdapter.method('setLoadMoreButton', function(loadMoreButton) { - var that = this; + setLoadMoreButton(loadMoreButton) { + const that = this; this.loadMoreButton = loadMoreButton; - this.loadMoreButton.off().on('click',function(){ - that.loadMoreButton.attr('disabled','disabled'); - that.loadMore([]); - } - ); -}); + this.loadMoreButton.off().on('click', () => { + that.loadMoreButton.attr('disabled', 'disabled'); + that.loadMore([]); + }); + } -ConversationsAdapter.method('showLoadError', function(msg) { - $("#"+this.getTableName()+"_error").html(msg); - $("#"+this.getTableName()+"_error").show(); -}); + showLoadError(msg) { + $(`#${this.getTableName()}_error`).html(msg); + $(`#${this.getTableName()}_error`).show(); + } -ConversationsAdapter.method('hideLoadError', function() { - $("#"+this.getTableName()+"_error").hide(); -}); + hideLoadError() { + $(`#${this.getTableName()}_error`).hide(); + } -ConversationsAdapter.method('setSearchBox', function(searchInput) { - var that = this; + setSearchBox(searchInput) { + const that = this; this.searchInput = searchInput; this.searchInput.off(); - this.searchInput.keydown(function(event){ - var val = $(this).val(); - if ( event.which == 13 ) { - event.preventDefault(); - that.search([]); - }else if(( event.which == 8 || event.which == 46) && val.length == 1 && that.searchTerm != ''){ - that.search([]); - } + this.searchInput.keydown(function (event) { + const val = $(this).val(); + if (event.which === 13) { + event.preventDefault(); + that.search([]); + } else if ((event.which === 8 || event.which === 46) && val.length === 1 && that.searchTerm !== '') { + that.search([]); + } }); -}); + } -ConversationsAdapter.method('getObjectDom', function(id) { - obj = this.container.find("#obj_"+id); - if(obj.length){ - return obj; + getObjectDom(id) { + const obj = this.container.find(`#obj_${id}`); + if (obj.length) { + return obj; } return null; -}); + } -ConversationsAdapter.method('loadMore', function(callBackData) { - if(!this.hasMoreData){ - return; + loadMore(callBackData) { + if (!this.hasMoreData) { + return; } this.currentPage++; this.get(callBackData, true); -}); + } -ConversationsAdapter.method('get', function(callBackData, loadMore) { - var that = this; + get(callBackData, loadMore) { + const that = this; this.hideLoadError(); - if(!loadMore){ - this.currentPage = 1; - if(this.container != null){ - this.container.html(''); - } - this.hasMoreData = true; - this.tableData = []; + if (!loadMore) { + this.currentPage = 1; + if (this.container != null) { + this.container.html(''); + } + this.hasMoreData = true; + this.tableData = []; } this.start = (this.currentPage === 1) ? 0 : this.bottomLimit; - this.container = $("#"+this.getTableName()).find('.objectList'); + this.container = $(`#${this.getTableName()}`).find('.objectList'); that.showLoader(); this.getConversations(this.start, this.pageSize, false); if (this.timer === null && that.getTimeout() > 0) { - this.timeoutDelay = 0; - this.timer = setTimeout(function tick() { - that.getConversations(that.topLimit, that.pageSize, true); - that.timeoutDelay += that.getTimeout(); - if (that.topLimitUpdated) { - that.timeoutDelay = 0; - } - that.timer = setTimeout(tick, that.getTimeout() + that.timeoutDelay); - }, that.getTimeout() + that.timeoutDelay); + this.timeoutDelay = 0; + this.timer = setTimeout(function tick() { + that.getConversations(that.topLimit, that.pageSize, true); + that.timeoutDelay += that.getTimeout(); + if (that.topLimitUpdated) { + that.timeoutDelay = 0; + } + that.timer = setTimeout(tick, that.getTimeout() + that.timeoutDelay); + }, that.getTimeout() + that.timeoutDelay); } + } -}); - -ConversationsAdapter.method('getTimeout', function() { + getTimeout() { return 0; -}); + } -ConversationsAdapter.method('getTimeoutUpper', function() { + getTimeoutUpper() { return 0; -}); + } -ConversationsAdapter.method('showConversationLoader', function() { - //Do nothing -}); + showConversationLoader() { + // Do nothing + } -ConversationsAdapter.method('hideConversationLoader', function() { - //Do nothing -}); + hideConversationLoader() { + // Do nothing + } -ConversationsAdapter.method('search', function(callBackData) { - this.searchTerm = $("#"+this.getTableName()+"_search").val(); + search(callBackData) { + this.searchTerm = $(`#${this.getTableName()}_search`).val(); this.get(callBackData); + } +} -}); +export default ConversationsAdapter; diff --git a/web/api/CustomFieldAdapter.js b/web/api/CustomFieldAdapter.js new file mode 100644 index 00000000..fc9ff64d --- /dev/null +++ b/web/api/CustomFieldAdapter.js @@ -0,0 +1,102 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from './AdapterBase'; + +/* + * CustomFieldAdapter + */ + +class CustomFieldAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.tableType = ''; + } + + getDataMapping() { + return [ + 'id', + 'name', + 'display', + 'display_order', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Display Status' }, + { sTitle: 'Priority' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['display', { label: 'Display Status', type: 'select', source: [['Form', 'Show'], ['Hidden', 'Hidden']] }], + ['field_type', { label: 'Field Type', type: 'select', source: [['text', 'Text Field'], ['textarea', 'Text Area'], ['select', 'Select'], ['select2', 'Select2'], ['select2multi', 'Multi Select'], ['fileupload', 'File Upload'], ['date', 'Date'], ['datetime', 'Date Time'], ['time', 'Time']] }], + ['field_label', { label: 'Field Label', type: 'text', validation: '' }], + ['field_validation', { + label: 'Validation', type: 'select2', validation: 'none', sort: 'none', 'null-label': 'Required', 'allow-null': true, source: [['none', 'None'], ['number', 'Number'], ['numberOrEmpty', 'Number or Empty'], ['float', 'Decimal'], ['email', 'Email'], ['emailOrEmpty', 'Email or Empty']], + }], + ['field_options', { + label: 'Field Options', + type: 'datagroup', + form: [ + ['label', { label: 'Label', type: 'text', validation: '' }], + ['value', { label: 'Value', type: 'text', validation: 'none' }], + ], + html: '
    #_delete_##_edit_##_label_#:#_value_#
    ', + validation: 'none', + }], + ['display_order', { label: 'Priority', type: 'text', validation: 'number' }], + ['display_section', { label: 'Display Section', type: 'text', validation: 'none' }], + ]; + } + + setTableType(type) { + this.tableType = type; + } + + doCustomValidation(params) { + const validateName = function (str) { + const name = /^[a-z][a-z0-9._]+$/; + return str != null && name.test(str); + }; + + if (!validateName(params.name)) { + return 'Invalid name for custom field'; + } + + + return null; + } + + forceInjectValuesBeforeSave(params) { + const data = [params.name]; const options = []; let + optionsData; + data.push({}); + data[1].label = params.field_label; + data[1].type = params.field_type; + data[1].validation = params.field_validation; + if (['select', 'select2', 'select2multi'].indexOf(params.field_type) >= 0) { + optionsData = (params.field_options === '' || params.field_options === undefined) + ? [] : JSON.parse(params.field_options); + for (const index in optionsData) { + options.push([optionsData[index].value, optionsData[index].label]); + } + data[1].source = options; + } + if (params.field_validation == null || params.field_validation === undefined) { + params.field_validation = ''; + } + params.data = JSON.stringify(data); + params.type = this.tableType; + return params; + } +} + +export default CustomFieldAdapter; diff --git a/web/api/FormValidation.js b/web/api/FormValidation.js index 152a5d9b..8c2c3a3e 100644 --- a/web/api/FormValidation.js +++ b/web/api/FormValidation.js @@ -1,280 +1,246 @@ /* -This file is part of Ice Framework. - -Ice Framework is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ice Framework is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Ice Framework. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ +/* global tinyMCE */ +const ValidationRules = { -ValidationRules = { - - float: function (str) { - var floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; - if (str != null && str.match(floatstr)) { - return true; - } else { - return false; - } - }, - - number: function (str) { - var numstr = /^[0-9]+$/; - if (str != null && str.match(numstr)) { - return true; - } else { - return false; - } - }, - - numberOrEmpty: function (str) { - if(str == ""){ - return true; - } - var numstr = /^[0-9]+$/; - if (str != null && str.match(numstr)) { - return true; - } else { - return false; - } - }, - - email: function (str) { - var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; - return str != null && emailPattern.test(str); - }, - - emailOrEmpty: function (str) { - if(str == ""){ - return true; - } - var emailPattern = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; - return str != null && emailPattern.test(str); - }, - - username: function (str) { - var username = /^[a-zA-Z0-9\.-]+$/; - return str != null && username.test(str); - }, - - input: function (str) { - if (str != null && str.length > 0) { - return true; - } else { - return false; - } + float(str) { + const floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; + if (str != null && str.match(floatstr)) { + return true; } + return false; + }, + + number(str) { + const numstr = /^[0-9]+$/; + if (str != null && str.match(numstr)) { + return true; + } + return false; + }, + + numberOrEmpty(str) { + if (str === '') { + return true; + } + const numstr = /^[0-9]+$/; + if (str != null && str.match(numstr)) { + return true; + } + return false; + }, + + email(str) { + const emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; + return str != null && emailPattern.test(str); + }, + + emailOrEmpty(str) { + if (str === '') { + return true; + } + const emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; + return str != null && emailPattern.test(str); + }, + + username(str) { + const username = /^[a-zA-Z0-9.-]+$/; + return str != null && username.test(str); + }, + + input(str) { + if (str != null && str.length > 0) { + return true; + } + return false; + }, }; -function FormValidation(formId,validateAll,options) { +class FormValidation { + constructor(formId, validateAll, options) { this.tempOptions = {}; - this.formId = formId; - this.formError = false; + this.formId = formId; + this.formError = false; this.formObject = null; - this.errorMessages = ""; + this.errorMessages = ''; this.popupDialog = null; this.validateAll = validateAll; - this.errorMap = new Array(); + this.errorMap = []; - this.settings = {"thirdPartyPopup":null,"LabelErrorClass":false, "ShowPopup":true}; + this.settings = { thirdPartyPopup: null, LabelErrorClass: false, ShowPopup: true }; - this.settings = jQuery.extend(this.settings,options); + this.settings = jQuery.extend(this.settings, options); - this.inputTypes = new Array( "text", "radio", "checkbox", "file", "password", "select-one","select-multi", "textarea","fileupload" ,"signature"); + this.inputTypes = ['text', 'radio', 'checkbox', 'file', 'password', 'select-one', 'select-multi', 'textarea', 'fileupload', 'signature']; this.validator = ValidationRules; + } -} + // eslint-disable-next-line no-unused-vars + clearError(formInput, overrideMessage) { + const id = formInput.attr('id'); + $(`#${this.formId} #field_${id}`).removeClass('error'); + $(`#${this.formId} #help_${id}`).html(''); + } -FormValidation.method('clearError' , function(formInput, overrideMessage) { - var id = formInput.attr("id"); - $('#'+ this.formId +' #field_'+id).removeClass('error'); - $('#'+ this.formId +' #help_'+id).html(''); -}); - -FormValidation.method('addError' , function(formInput, overrideMessage) { + // eslint-disable-next-line no-unused-vars + addError(formInput, overrideMessage) { this.formError = true; - if(formInput.attr("message") != null) { - this.errorMessages += (formInput.attr("message") + "\n"); - this.errorMap[formInput.attr("name")] = formInput.attr("message"); - }else{ - this.errorMap[formInput.attr("name")] = ""; + if (formInput.attr('message') != null) { + this.errorMessages += (`${formInput.attr('message')}\n`); + this.errorMap[formInput.attr('name')] = formInput.attr('message'); + } else { + this.errorMap[formInput.attr('name')] = ''; } - var id = formInput.attr("id"); - var validation = formInput.attr("validation"); - var message = formInput.attr("validation"); - $('#'+ this.formId +' #field_'+id).addClass('error'); - if(message == undefined || message == null || message == ""){ - $('#'+ this.formId +' #help_err_'+id).html(message); - }else{ - if(validation == undefined || validation == null || validation == ""){ - $('#'+ this.formId +' #help_err_'+id).html("Required"); - }else{ - if(validation == "float" || validation == "number"){ - $('#'+ this.formId +' #help_err_'+id).html("Number required"); - }else if(validation == "email"){ - $('#'+ this.formId +' #help_err_'+id).html("Email required"); - }else{ - $('#'+ this.formId +' #help_err_'+id).html("Required"); - } + const id = formInput.attr('id'); + const validation = formInput.attr('validation'); + const message = formInput.attr('validation'); + $(`#${this.formId} #field_${id}`).addClass('error'); + if (message === undefined || message == null || message === '') { + $(`#${this.formId} #help_err_${id}`).html(message); + } else if (validation === undefined || validation == null || validation === '') { + $(`#${this.formId} #help_err_${id}`).html('Required'); + } else if (validation === 'float' || validation === 'number') { + $(`#${this.formId} #help_err_${id}`).html('Number required'); + } else if (validation === 'email') { + $(`#${this.formId} #help_err_${id}`).html('Email required'); + } else { + $(`#${this.formId} #help_err_${id}`).html('Required'); + } + } + + + showErrors() { + if (this.formError) { + if (this.settings.thirdPartyPopup !== undefined && this.settings.thirdPartyPopup != null) { + this.settings.thirdPartyPopup.alert(); + } else if (this.settings.ShowPopup === true) { + if (this.tempOptions.popupTop !== undefined && this.tempOptions.popupTop != null) { + this.alert('Errors Found', this.errorMessages, this.tempOptions.popupTop); + } else { + this.alert('Errors Found', this.errorMessages, -1); } + } } + } -}); - - -FormValidation.method('showErrors' , function() { - if(this.formError) { - if(this.settings['thirdPartyPopup'] != undefined && this.settings['thirdPartyPopup'] != null){ - this.settings['thirdPartyPopup'].alert(); - }else{ - if(this.settings['ShowPopup'] == true){ - if(this.tempOptions['popupTop'] != undefined && this.tempOptions['popupTop'] != null){ - this.alert("Errors Found",this.errorMessages,this.tempOptions['popupTop']); - }else{ - this.alert("Errors Found",this.errorMessages,-1); - } - - } - } - } -}); - - -FormValidation.method('checkValues' , function(options) { + checkValues(options) { this.tempOptions = options; - var that = this; + const that = this; this.formError = false; - this.errorMessages = ""; - this.formObject = new Object(); - var validate = function (inputObject) { - if(that.settings['LabelErrorClass'] != false){ - $("label[for='" + name + "']").removeClass(that.settings['LabelErrorClass']); - } - var id = inputObject.attr("id"); - var name = inputObject.attr("name"); - var type = inputObject.attr("type"); + this.errorMessages = ''; + this.formObject = {}; + // eslint-disable-next-line consistent-return + const validate = function (inputObject) { + let inputValue = null; + const name = inputObject.attr('name'); + if (that.settings.LabelErrorClass !== false) { + $(`label[for='${name}']`).removeClass(that.settings.LabelErrorClass); + } + const id = inputObject.attr('id'); + const type = inputObject.attr('type'); - if(inputObject.hasClass('select2-focusser') || inputObject.hasClass('select2-input')){ - return true; + if (inputObject.hasClass('select2-focusser') || inputObject.hasClass('select2-input')) { + return true; + } + + if (jQuery.inArray(type, that.inputTypes) >= 0) { + if (inputObject.hasClass('uploadInput')) { + inputValue = inputObject.attr('val'); + } else if (type === 'radio' || type === 'checkbox') { + inputValue = $(`input[name='${name}']:checked`).val(); + } else if (inputObject.hasClass('select2Field')) { + if ($(`#${that.formId} #${id}`).select2('data') != null && $(`#${that.formId} #${id}`).select2('data') !== undefined) { + inputValue = $(`#${that.formId} #${id}`).select2('data').id; + } else { + inputValue = ''; + } + } else if (inputObject.hasClass('select2Multi')) { + if ($(`#${that.formId} #${id}`).select2('data') != null && $(`#${that.formId} #${id}`).select2('data') !== undefined) { + const inputValueObjects = $(`#${that.formId} #${id}`).select2('data'); + inputValue = []; + for (let i = 0; i < inputValueObjects.length; i++) { + inputValue.push(inputValueObjects[i].id); + } + inputValue = JSON.stringify(inputValue); + } else { + inputValue = ''; + } + } else if (inputObject.hasClass('signatureField')) { + if ($(`#${that.formId} #${id}`).data('signaturePad').isEmpty()) { + inputValue = ''; + } else { + inputValue = $(`#${id}`).data('signaturePad').toDataURL(); + } + } else if (inputObject.hasClass('simplemde')) { + inputValue = $(`#${that.formId} #${id}`).data('simplemde').value(); + } else if (inputObject.hasClass('tinymce')) { + inputValue = tinyMCE.get(id).getContent({ format: 'raw' }); + } else { + inputValue = inputObject.val(); } - if(jQuery.inArray(type, that.inputTypes ) >= 0) { - if(inputObject.hasClass('uploadInput')){ - inputValue = inputObject.attr("val"); - //}else if(inputObject.hasClass('datetimeInput')){ - //inputValue = inputObject.getDate()+":00"; - }else{ - //inputValue = (type == "radio" || type == "checkbox")?$("input[name='" + name + "']:checked").val():inputObject.val(); + const validation = inputObject.attr('validation'); + let valid = false; - inputValue = null; - if(type == "radio" || type == "checkbox"){ - inputValue = $("input[name='" + name + "']:checked").val(); - }else if(inputObject.hasClass('select2Field')){ - if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ - inputValue = $('#'+id).select2('data').id; - }else{ - inputValue = ""; - } - - }else if(inputObject.hasClass('select2Multi')){ - if($('#'+id).select2('data') != null && $('#'+id).select2('data') != undefined){ - inputValueObjects = $('#'+id).select2('data'); - inputValue = []; - for(var i=0;i ${logs[i].status_to}`); + trow = trow.replace(/_note_/g, logs[i].note); + rowsLogs += trow; + } + + if (rowsLogs !== '') { + tableLog = tableLog.replace('_days_', rowsLogs); + html += tableLog; + } + + this.showMessage('Logs', html); + + timeUtils.convertToRelativeTime($('.logTime')); + } + + // eslint-disable-next-line no-unused-vars + getLogsFailCallBack(callBackData) { + this.showMessage('Error', 'Error occured while getting data'); + } +} + +export default LogViewAdapter; diff --git a/web/api/ModuleBase.js b/web/api/ModuleBase.js new file mode 100644 index 00000000..79ec52c6 --- /dev/null +++ b/web/api/ModuleBase.js @@ -0,0 +1,2528 @@ +/* global tinymce, SimpleMDE, modJs, SignaturePad, modulesInstalled */ +/* eslint-disable prefer-destructuring */ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import FormValidation from './FormValidation'; +/** + * The base class for providing core functions to all module classes. + * @class Base.js + */ + +class ModuleBase { + constructor() { + this.deleteParams = {}; + this.createRemoteTable = false; + this.instanceId = 'None'; + this.ga = []; + this.showEdit = true; + this.showDelete = true; + this.showSave = true; + this.showCancel = true; + this.showFormOnPopup = false; + this.filtersAlreadySet = false; + this.currentFilterString = ''; + this.sorting = 0; + this.settings = {}; + this.translations = {}; + this.customFields = []; + this.csrfRequired = false; + + this.fieldTemplates = null; + this.templates = null; + this.customTemplates = null; + this.emailTemplates = null; + this.fieldMasterData = null; + this.fieldMasterDataKeys = null; + this.fieldMasterDataCallback = null; + this.sourceMapping = null; + this.currentId = null; + this.currentElement = null; + this.user = null; + this.currentProfile = null; + this.permissions = {}; + this.baseUrl = null; + } + + // eslint-disable-next-line no-unused-vars + init(appName, currentView, dataUrl, permissions) { + + } + + /** + * Some browsers do not support sending JSON in get parameters. Set this to true to avoid sending JSON + * @method setNoJSONRequests + * @param val {Boolean} + */ + setNoJSONRequests(val) { + this.noJSONRequests = val; + } + + + setPermissions(permissions) { + this.permissions = permissions; + } + + sortingStarted(val) { + this.sorting = val; + } + + /** + * Check if the current user has a permission + * @method checkPermission + * @param permission {String} + * @example + * this.checkPermission("Upload/Delete Profile Image") + */ + checkPermission(permission) { + if (this.permissions[permission] === undefined || this.permissions[permission] == null || this.permissions[permission] === 'Yes') { + return 'Yes'; + } + return this.permissions[permission]; + } + + setBaseUrl(url) { + this.baseUrl = url; + } + + setUser(user) { + this.user = user; + } + + getUser() { + return this.user; + } + + setInstanceId(id) { + this.instanceId = id; + } + + setCSRFRequired(val) { + this.csrfRequired = val; + } + + scrollToTop() { + $('html, body').animate({ scrollTop: 0 }, 'fast'); + } + + scrollToBottom() { + $('html, body').animate({ scrollTop: $(document).height() }, 'slow'); + } + + scrollToElement(element) { + if ($(window).height() <= element.offset().top) { + $('html, body').animate({ scrollTop: element.offset().top }, 'slow'); + } + } + + scrollToElementBottom(element) { + if ($(window).height() <= element.offset().top + element.height()) { + $('html, body').animate({ scrollTop: element.offset().top + element.height() }, 'slow'); + } + } + + + setTranslations(txt) { + this.translations = txt.messages['']; + } + + setTranslationsSubModules(translations) { + this.translations = translations; + } + + gt(key) { + if (this.translations[key] === undefined || this.translations[key] === null) { + return key; + } + return this.translations[key][0]; + } + + addToLangTerms(key) { + let termsArr; + const terms = localStorage.getItem('terms'); + if (terms === undefined) { + termsArr = {}; + } else { + try { + termsArr = JSON.parse(terms); + } catch (e) { + termsArr = {}; + } + } + + if (this.translations[key] === undefined) { + termsArr[key] = key; + localStorage.setItem('terms', JSON.stringify(termsArr)); + } + } + + /** + * If this method returned false the action buttons in data table for modules will not be displayed. + * Override this method in module lib.js to hide action buttons + * @method showActionButtons + * @param permission {String} + * @example + * EmployeeLeaveEntitlementAdapter.method('showActionButtons() { + * return false; + * } + */ + showActionButtons() { + return true; + } + + trackEvent(action, label, value) { + try { + if (label === undefined || label == null) { + this.ga.push(['_trackEvent', this.instanceId, action]); + } else if (value === undefined || value == null) { + this.ga.push(['_trackEvent', this.instanceId, action, label]); + } else { + this.ga.push(['_trackEvent', this.instanceId, action, label, value]); + } + } catch (e) { + // Do nothing + } + } + + + setCurrentProfile(currentProfile) { + this.currentProfile = currentProfile; + } + + /** + * Get the current profile + * @method getCurrentProfile + * @returns Profile of the current user if the profile is not switched if not switched profile + */ + + getCurrentProfile() { + return this.currentProfile; + } + + /** + * Retrive data required to create select boxes for add new /edit forms for a given module. This is called when loading the module + * @method initFieldMasterData + * @param callback {Function} call this once loading completed + * @param callback {Function} call this once all field loading completed. This indicate that the form can be displayed saftly + * @example + * ReportAdapter.method('renderForm(object) { + * var that = this; + * this.processFormFieldsWithObject(object); + * var cb = function(){ + * that.super.renderForm(object); + * }; + * this.initFieldMasterData(cb); + * } + */ + initFieldMasterData(callback, loadAllCallback, loadAllCallbackData) { + let values; + if (this.showAddNew === undefined || this.showAddNew == null) { + this.showAddNew = true; + } + this.fieldMasterData = {}; + this.fieldMasterDataKeys = {}; + this.fieldMasterDataCallback = loadAllCallback; + this.fieldMasterDataCallbackData = loadAllCallbackData; + this.sourceMapping = {}; + const fields = this.getFormFields(); + const filterFields = this.getFilters(); + + if (filterFields != null) { + for (let j = 0; j < filterFields.length; j++) { + values = this.getMetaFieldValues(filterFields[j][0], fields); + if (values == null || (values.type !== 'select' && values.type !== 'select2' && values.type !== 'select2multi')) { + fields.push(filterFields[j]); + } + } + } + + + const remoteSourceFields = []; + const remoteSourceFieldKeys = []; + let field = null; + let fieldSub = null; + for (let i = 0; i < fields.length; i++) { + field = fields[i]; + if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] !== null) { + const key = `${field[1]['remote-source'][0]}_${field[1]['remote-source'][1]}_${field[1]['remote-source'][2]}`; + // if(remoteSourceFieldKeys.indexOf(key) < 0){ + remoteSourceFields.push(field); + remoteSourceFieldKeys.push(key); + // } + } else if (field[1].form !== undefined && field[1].form !== null) { + for (let j = 0; j < field[1].form.length; j++) { + fieldSub = field[1].form[j]; + if (fieldSub[1]['remote-source'] !== undefined && fieldSub[1]['remote-source'] !== null) { + const key = `${fieldSub[1]['remote-source'][0]}_${fieldSub[1]['remote-source'][1]}_${fieldSub[1]['remote-source'][2]}`; + if (remoteSourceFieldKeys.indexOf(key) < 0) { + remoteSourceFields.push(fieldSub); + remoteSourceFieldKeys.push(key); + } + } + } + } + } + + for (let i = 0; i < remoteSourceFields.length; i++) { + const fieldRemote = remoteSourceFields[i]; + if (fieldRemote[1]['remote-source'] !== undefined && fieldRemote[1]['remote-source'] != null) { + const key = `${fieldRemote[1]['remote-source'][0]}_${fieldRemote[1]['remote-source'][1]}_${fieldRemote[1]['remote-source'][2]}`; + this.fieldMasterDataKeys[key] = false; + this.sourceMapping[fieldRemote[0]] = fieldRemote[1]['remote-source']; + + const callBackData = {}; + callBackData.callBack = 'initFieldMasterDataResponse'; + callBackData.callBackData = [key]; + if (callback !== null && callback !== undefined) { + callBackData.callBackSuccess = callback; + } + this.getFieldValues(fieldRemote[1]['remote-source'], callBackData); + } + } + } + + /** + * Pass true to this method after creating module JS object to open new/edit entry form for the module on a popup. + * @method setShowFormOnPopup + * @param val {Boolean} + * @example + * modJs.subModJsList['tabCandidateApplication'] = new CandidateApplicationAdapter('Application','CandidateApplication',{"candidate":data.id} + * modJs.subModJsList['tabCandidateApplication'].setShowFormOnPopup(true); + */ + + setShowFormOnPopup(val) { + this.showFormOnPopup = val; + } + + /** + * Set this to true to if you need the datatable to load data page by page instead of loading all data at once. + * @method setRemoteTable + * @param val {Boolean} + * @example + * modJs.subModJsList['tabCandidateApplication'] = new CandidateApplicationAdapter('Application','CandidateApplication',{"candidate":data.id} + * modJs.subModJsList['tabCandidateApplication'].setRemoteTable(true); + */ + + setRemoteTable(val) { + this.createRemoteTable = val; + } + + setSettings(val) { + this.settings = val; + } + + getRemoteTable() { + return this.createRemoteTable; + } + + isAllLoaded(fieldMasterDataKeys) { + for (const key in fieldMasterDataKeys) { + if (fieldMasterDataKeys[key] === false) { + return false; + } + } + return true; + } + + // eslint-disable-next-line no-unused-vars + initFieldMasterDataResponse(key, data, callback, loadAllCallbackData) { + this.fieldMasterData[key] = data; + this.fieldMasterDataKeys[key] = true; + + if (callback !== undefined && callback !== null) { + callback(); + } + + if (this.fieldMasterDataCallback !== null + && this.fieldMasterDataCallback !== undefined + && this.isAllLoaded(this.fieldMasterDataKeys) + && (this.fieldMasterDataCallbackData !== null && this.fieldMasterDataCallbackData !== undefined) + ) { + this.fieldMasterDataCallback(this.fieldMasterDataCallbackData); + } else if (this.fieldMasterDataCallback !== null + && this.fieldMasterDataCallback !== undefined + && this.isAllLoaded(this.fieldMasterDataKeys) + ) { + this.fieldMasterDataCallback(); + } + } + + getMetaFieldValues(key, fields) { + for (let i = 0; i < fields.length; i++) { + if (key === fields[i][0]) { + return fields[i][1]; + } + } + return null; + } + + getThemeColors() { + const colors = ['red', 'yellow', 'aqua', 'blue', + 'light-blue', 'green', 'navy', 'teal', 'olive', 'orange', + 'fuchsia', 'purple']; + + return colors; + } + + getColorByRandomString(string) { + const colors = this.getThemeColors(); + const k = string.charCodeAt(0); + return colors[k % colors.length]; + } + + getColorByFileType(type) { + type = type.toLowerCase(); + + const colorMap = {}; + colorMap.pdf = 'red'; + colorMap.csv = 'yellow'; + colorMap.xls = 'green'; + colorMap.xlsx = 'green'; + colorMap.doc = 'light-blue'; + colorMap.docx = 'light-blue'; + colorMap.docx = 'blue'; + colorMap.ppt = 'orange'; + colorMap.pptx = 'orange'; + colorMap.jpg = 'teal'; + colorMap.jpeg = 'teal'; + colorMap.gif = 'green'; + colorMap.png = 'yellow'; + colorMap.bmp = 'fuchsia'; + + + if (colorMap[type] !== undefined || colorMap[type] != null) { + return colorMap[type]; + } + return this.getColorByRandomString(type); + } + + getIconByFileType(type) { + type = type.toLowerCase(); + + const iconMap = {}; + iconMap.pdf = 'fa fa-file-pdf-o'; + iconMap.csv = 'fa fa fa-file-code-o'; + iconMap.xls = 'fa fa-file-excel-o'; + iconMap.xlsx = 'fa fa-file-excel-o'; + iconMap.doc = 'fa fa-file-word-o'; + iconMap.docx = 'fa fa-file-word-o'; + iconMap.ppt = 'fa fa-file-powerpoint-o'; + iconMap.pptx = 'fa fa-file-powerpoint-o'; + iconMap.jpg = 'fa fa-file-image-o'; + iconMap.jpeg = 'fa fa-file-image-o'; + iconMap.gif = 'fa fa-file-image-o'; + iconMap.png = 'fa fa-file-image-o'; + iconMap.bmp = 'fa fa-file-image-o'; + iconMap.txt = 'fa fa-file-text-o'; + iconMap.rtf = 'fa fa-file-text-o'; + + + if (iconMap[type] !== undefined || iconMap[type] != null) { + return iconMap[type]; + } + return 'fa fa-file-o'; + } + + getSourceMapping() { + return this.sourceMapping; + } + + setTesting(testing) { + this.testing = testing; + } + + consoleLog(message) { + if (this.testing) { + console.log(message); + } + } + + setClientMessages(msgList) { + this.msgList = msgList; + } + + setTemplates(templates) { + this.templates = templates; + } + + + getWSProperty(array, key) { + if (array.hasOwnProperty(key)) { + return array[key]; + } + return null; + } + + + getClientMessage(key) { + return this.getWSProperty(this.msgList, key); + } + + + getTemplate(key) { + return this.getWSProperty(this.templates, key); + } + + setGoogleAnalytics(gaq) { + this.gaq = gaq; + } + + + showView(view) { + if (this.currentView != null) { + this.previousView = this.currentView; + $(`#${this.currentView}`).hide(); + } + $(`#${view}`).show(); + this.currentView = view; + this.moveToTop(); + } + + showPreviousView() { + this.showView(this.previousView); + } + + + moveToTop() { + + } + + + callFunction(callback, cbParams, thisParam) { + if ($.isFunction(callback)) { + try { + if (thisParam === undefined || thisParam === null) { + callback.apply(document, cbParams); + } else { + callback.apply(thisParam, cbParams); + } + } catch (e) { + console.log(e.message); + } + } else { + const f = this[callback]; + if ($.isFunction(f)) { + try { + f.apply(this, cbParams); + } catch (e) { + console.log(e.message); + } + } + } + } + + getTableTopButtonHtml() { + let html = ''; + if (this.getShowAddNew()) { + html = ``; + } + + if (this.getFilters() != null) { + if (html !== '') { + html += '  '; + } + html += ``; + html += '  '; + if (this.filtersAlreadySet) { + html += ''; + } else { + html += ''; + } + } + + html = html.replace(/__id__/g, this.getTableName()); + + if (this.currentFilterString !== '' && this.currentFilterString != null) { + html = html.replace(/__filterString__/g, this.currentFilterString); + } else { + html = html.replace(/__filterString__/g, 'Reset Filters'); + } + + if (html !== '') { + html = `
    ${html}
    `; + } + + return html; + } + + + getActionButtonHeader() { + return { sTitle: '', sClass: 'center' }; + } + + getTableHTMLTemplate() { + return '
    '; + } + + isSortable() { + return true; + } + + /** + * Create the data table on provided element id + * @method createTable + * @param val {Boolean} + */ + + createTable(elementId) { + const that = this; + + if (this.getRemoteTable()) { + this.createTableServer(elementId); + return; + } + + + const headers = this.getHeaders(); + + // add translations + for (const index in headers) { + headers[index].sTitle = this.gt(headers[index].sTitle); + } + + const data = this.getTableData(); + + if (this.showActionButtons()) { + headers.push(this.getActionButtonHeader()); + } + + + if (this.showActionButtons()) { + for (let i = 0; i < data.length; i++) { + data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); + } + } + + let html = ''; + html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); + /* + if(this.getShowAddNew()){ + html = this.getTableTopButtonHtml()+'
    '; + }else{ + html = '
    '; + } + */ + // Find current page + const activePage = $(`#${elementId} .dataTables_paginate .active a`).html(); + let start = 0; + if (activePage !== undefined && activePage != null) { + start = parseInt(activePage, 10) * 15 - 15; + } + + $(`#${elementId}`).html(html); + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + aaData: data, + aoColumns: headers, + bSort: that.isSortable(), + iDisplayLength: 15, + iDisplayStart: start, + }; + + + const customTableParams = this.getCustomTableParams(); + + $.extend(dataTableParams, customTableParams); + + $(`#${elementId} #grid`).dataTable(dataTableParams); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + $('.tableActionButton').tooltip(); + } + + /** + * Create a data table on provided element id which loads data page by page + * @method createTableServer + * @param val {Boolean} + */ + + createTableServer(elementId) { + const that = this; + const headers = this.getHeaders(); + + headers.push({ sTitle: '', sClass: 'center' }); + + // add translations + for (const index in headers) { + headers[index].sTitle = this.gt(headers[index].sTitle); + } + + let html = ''; + html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); + + // Find current page + const activePage = $(`#${elementId} .dataTables_paginate .active a`).html(); + let start = 0; + if (activePage !== undefined && activePage != null) { + start = parseInt(activePage, 10) * 15 - 15; + } + + + $(`#${elementId}`).html(html); + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + bProcessing: true, + bServerSide: true, + sAjaxSource: that.getDataUrl(that.getDataMapping()), + aoColumns: headers, + bSort: that.isSortable(), + parent: that, + iDisplayLength: 15, + iDisplayStart: start, + }; + + if (this.showActionButtons()) { + dataTableParams.aoColumnDefs = [ + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ]; + } + + const customTableParams = this.getCustomTableParams(); + + $.extend(dataTableParams, customTableParams); + + $(`#${elementId} #grid`).dataTable(dataTableParams); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + + $('.tableActionButton').tooltip(); + } + + /** + * This should be overridden in module lib.js classes to return module headers which are used to create the data table. + * @method getHeaders + * @example + SettingAdapter.method('getHeaders() { + return [ + { "sTitle": "ID" ,"bVisible":false}, + { "sTitle": "Name" }, + { "sTitle": "Value"}, + { "sTitle": "Details"} + ]; + } + */ + getHeaders() { + + } + + + /** + * This should be overridden in module lib.js classes to return module field values which are used to create the data table. + * @method getDataMapping + * @example + SettingAdapter.method('getDataMapping() { + return [ + "id", + "name", + "value", + "description" + ]; + } + */ + + getDataMapping() { + + } + + /** + * This should be overridden in module lib.js classes to return module from fields which are used to create the add/edit form and also used for initializing select box values in form. + * @method getFormFields + * @example + SettingAdapter.method('getFormFields() { + return [ + [ "id", {"label":"ID","type":"hidden"}], + [ "value", {"label":"Value","type":"text","validation":"none"}] + ]; + } + */ + getFormFields() { + + } + + getTableData() { + + } + + /** + * This can be overridden in module lib.js classes inorder to show a filter form + * @method getFilters + * @example + EmployeeAdapter.method('getFilters() { + return [ + [ "job_title", {"label":"Job Title","type":"select2","allow-null":true,"null-label":"All Job Titles","remote-source":["JobTitle","id","name"]}], + [ "department", {"label":"Department","type":"select2","allow-null":true,"null-label":"All Departments","remote-source":["CompanyStructure","id","title"]}], + [ "supervisor", {"label":"Supervisor","type":"select2","allow-null":true,"null-label":"Anyone","remote-source":["Employee","id","first_name+last_name"]}] + ]; + } + */ + getFilters() { + return null; + } + + /** + * Show the edit form for an item + * @method edit + * @param id {int} id of the item to edit + */ + edit(id) { + this.currentId = id; + this.getElement(id, []); + } + + copyRow(id) { + this.getElement(id, [], true); + } + + renderModel(id, header, body) { + $(`#${id}ModelBody`).html(''); + + if (body === undefined || body == null) { + body = ''; + } + + $(`#${id}ModelLabel`).html(header); + $(`#${id}ModelBody`).html(body); + } + + + renderYesNoModel(header, body, yesBtnName, noBtnName, callback, callbackParams) { + const that = this; + const modelId = '#yesnoModel'; + + if (body === undefined || body == null) { + body = ''; + } + + $(`${modelId}Label`).html(header); + $(`${modelId}Body`).html(body); + if (yesBtnName != null) { + $(`${modelId}YesBtn`).html(yesBtnName); + } + if (noBtnName != null) { + $(`${modelId}NoBtn`).html(noBtnName); + } + + $(`${modelId}YesBtn`).off().on('click', () => { + if (callback !== undefined && callback != null) { + callback.apply(that, callbackParams); + that.cancelYesno(); + } + }); + + $(modelId).modal({ + backdrop: 'static', + }); + } + + renderModelFromDom(id, header, element) { + $(`#${id}ModelBody`).html(''); + + if (element === undefined || element == null) { + element = $('
    '); + } + + $(`#${id}ModelLabel`).html(header); + $(`#${id}ModelBody`).html(''); + $(`#${id}ModelBody`).append(element); + } + + /** + * Delete an item + * @method deleteRow + * @param id {int} id of the item to edit + */ + + deleteRow(id) { + this.deleteParams.id = id; + this.renderModel('delete', 'Confirm Deletion', 'Are you sure you want to delete this item ?'); + $('#deleteModel').modal('show'); + } + + /** + * Show a popup with message + * @method showMessage + * @param title {String} title of the message box + * @param message {String} message + * @param closeCallback {Function} this will be called once the dialog is closed (optional) + * @param closeCallback {Function} data to pass to close callback (optional) + * @param closeCallbackData + * @param isPlain {Boolean} if true buttons are not shown (optional / default = true) + * @example + * this.showMessage("Error Occured while Applying Leave", callBackData); + */ + showMessage(title, message, closeCallback = null, closeCallbackData = null, isPlain = false) { + const that = this; + let modelId = ''; + if (isPlain) { + modelId = '#plainMessageModel'; + } else { + modelId = '#messageModel'; + } + + $(modelId).off(); + + if (isPlain) { + this.renderModel('plainMessage', title, message); + } else { + this.renderModel('message', title, message); + } + + if (closeCallback !== null && closeCallback !== undefined) { + $(modelId).modal({ show: true }); + $(modelId).on('hidden.bs.modal', () => { + closeCallback.apply(that, closeCallbackData); + $('.modal-backdrop').remove(); + }); + } else { + $(modelId).modal({ + backdrop: 'static', + }); + } + } + + showDomElement(title, element, closeCallback, closeCallbackData, isPlain) { + const that = this; + let modelId = ''; + if (isPlain) { + modelId = '#dataMessageModel'; + } else { + modelId = '#messageModel'; + } + + $(modelId).unbind('hide'); + + if (isPlain) { + this.renderModelFromDom('dataMessage', title, element); + } else { + this.renderModelFromDom('message', title, element); + } + + + if (closeCallback !== null && closeCallback !== undefined) { + $(modelId).modal({ show: true }); + $(modelId).on('hidden.bs.modal', () => { + closeCallback.apply(that, closeCallbackData); + $('.modal-backdrop').remove(); + }); + } else { + $(modelId).modal({ + backdrop: 'static', + }); + } + } + + confirmDelete() { + if (this.deleteParams.id !== undefined || this.deleteParams.id != null) { + this.deleteObj(this.deleteParams.id, []); + } + $('#deleteModel').modal('hide'); + } + + cancelDelete() { + $('#deleteModel').modal('hide'); + this.deleteParams.id = null; + } + + closeMessage() { + $('#messageModel').modal('hide'); + } + + cancelYesno() { + $('#yesnoModel').modal('hide'); + } + + closePlainMessage() { + $('#plainMessageModel').modal('hide'); + $('#dataMessageModel').modal('hide'); + } + + closeDataMessage() { + $('#dataMessageModel').modal('hide'); + } + + + /** + * Create or edit an element + * @method save + * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters + * @param successCallback {Function} this will get called after success response + */ + + save(callGetFunction, successCallback) { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + let params = validator.getFormParameters(); + params = this.forceInjectValuesBeforeSave(params); + const msg = this.doCustomValidation(params); + if (msg == null) { + if (this.csrfRequired) { + params.csrf = $(`#${this.getTableName()}Form`).data('csrf'); + } + const id = $(`#${this.getTableName()}_submit #id`).val(); + if (id != null && id !== undefined && id !== '') { + params.id = id; + } + params = this.makeEmptyDateFieldsNull(params); + this.add(params, [], callGetFunction, successCallback); + } else { + $(`#${this.getTableName()}Form .label`).html(msg); + $(`#${this.getTableName()}Form .label`).show(); + this.scrollToTop(); + } + } + } + + + makeEmptyDateFieldsNull(params) { + const fields = this.getFormFields(); + fields.forEach((field) => { + if ((field[1].type === 'date' || field[1].type === 'datetime') + && (params[field[0]] === '' || params[field[0]] === '0000-00-00' || params[field[0]] === '0000-00-00 00:00:00')) { + if (field[1].validation === 'none') { + params[field[0]] = 'NULL'; + } else { + delete params[field[0]]; + } + } + }); + return params; + } + + /** + * Override this method to inject attitional parameters or modify existing parameters retrived from add/edit form before sending to the server + * @method forceInjectValuesBeforeSave + * @param params {Array} keys and values in form + * @returns {Array} modified parameters + */ + forceInjectValuesBeforeSave(params) { + return params; + } + + /** + * Override this method to do custom validations at client side + * @method doCustomValidation + * @param params {Array} keys and values in form + * @returns {Null or String} return null if validation success, returns error message if unsuccessful + * @example + EmployeeLeaveAdapter.method('doCustomValidation(params) { + try{ + if(params['date_start'] != params['date_end']){ + var ds = new Date(params['date_start']); + var de = new Date(params['date_end']); + if(de < ds){ + return "Start date should be earlier than end date of the leave period"; + } + } + }catch(e){ + + } + return null; +} + */ + // eslint-disable-next-line no-unused-vars + doCustomValidation(params) { + return null; + } + + filterQuery() { + const validator = new FormValidation(`${this.getTableName()}_filter`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const params = validator.getFormParameters(); + if (this.doCustomFilterValidation(params)) { + // remove null params + for (const prop in params) { + if (params.hasOwnProperty(prop)) { + if (params[prop] === 'NULL') { + delete (params[prop]); + } + } + } + + this.setFilter(params); + this.filtersAlreadySet = true; + $(`#${this.getTableName()}_resetFilters`).show(); + this.currentFilterString = this.getFilterString(params); + + this.get([]); + this.closePlainMessage(); + } + } + } + + + getFilterString(filters) { + let str = ''; + let rmf; let source; let values; let select2MVal; let value; let + valueOrig; + + const filterFields = this.getFilters(); + + + if (values == null) { + values = []; + } + + for (const prop in filters) { + if (filters.hasOwnProperty(prop)) { + values = this.getMetaFieldValues(prop, filterFields); + value = ''; + valueOrig = null; + + if ((values.type === 'select' || values.type === 'select2')) { + if (values['remote-source'] !== undefined && values['remote-source'] != null) { + rmf = values['remote-source']; + if (filters[prop] === 'NULL') { + if (values['null-label'] !== undefined && values['null-label'] != null) { + value = values['null-label']; + } else { + value = 'Not Selected'; + } + } else { + value = this.fieldMasterData[`${rmf[0]}_${rmf[1]}_${rmf[2]}`][filters[prop]]; + valueOrig = value; + } + } else { + source = values.source[0]; + if (filters[prop] === 'NULL') { + if (values['null-label'] !== undefined && values['null-label'] != null) { + value = values['null-label']; + } else { + value = 'Not Selected'; + } + } else { + for (let i = 0; i < source.length; i++) { + if (filters[prop] === values.source[i][0]) { + value = values.source[i][1]; + valueOrig = value; + break; + } + } + } + } + } else if (values.type === 'select2multi') { + select2MVal = []; + try { + select2MVal = JSON.parse(filters[prop]); + } catch (e) { + // Do nothing + } + + value = select2MVal.join(','); + if (value !== '') { + valueOrig = value; + } + } else { + value = filters[prop]; + if (value !== '') { + valueOrig = value; + } + } + + if (valueOrig != null) { + if (str !== '') { + str += ' | '; + } + + str += `${values.label} = ${value}`; + } + } + } + + return str; + } + + /** + * Override this method to do custom validations at client side for values selected in filters + * @method doCustomFilterValidation + * @param params {Array} keys and values in form + * @returns {Null or String} return null if validation success, returns error message if unsuccessful + */ + doCustomFilterValidation(params) { + return true; + } + + + /** + * Reset selected filters + * @method resetFilters + */ + + resetFilters() { + this.filter = this.origFilter; + this.filtersAlreadySet = false; + $(`#${this.getTableName()}_resetFilters`).hide(); + this.currentFilterString = ''; + this.get([]); + } + + + showFilters(object) { + let formHtml = this.templates.filterTemplate; + let html = ''; + const fields = this.getFilters(); + + for (let i = 0; i < fields.length; i++) { + const metaField = this.getMetaFieldForRendering(fields[i][0]); + if (metaField === '' || metaField === undefined) { + html += this.renderFormField(fields[i]); + } else { + const metaVal = object[metaField]; + if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { + html += this.renderFormField(JSON.parse(metaVal)); + } else { + html += this.renderFormField(fields[i]); + } + } + } + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_filter`); + formHtml = formHtml.replace(/_fields_/g, html); + + const randomFormId = this.generateRandom(14); + const $tempDomObj = $('
    '); + $tempDomObj.attr('id', randomFormId); + + $tempDomObj.html(formHtml); + + + $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false, + }); + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en', + }); + + $tempDomObj.find('.colorpick').colorpicker(); + tinymce.init({ + selector: `#${$tempDomObj.attr('id')} .tinymce`, + height: '400', + }); + + $tempDomObj.find('.simplemde').each(function () { + const simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + // simplemde.value($(this).val()); + }); + + // $tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function () { + $(this).select2().select2('val', $(this).find('option:eq(0)').val()); + }); + + $tempDomObj.find('.select2Multi').each(function () { + $(this).select2().on('change', function (e) { + const parentRow = $(this).parents('.row'); + const height = parentRow.find('.select2-choices').height(); + parentRow.height(parseInt(height, 10)); + }); + }); + + /* + $tempDomObj.find('.signatureField').each(function() { + $(this).data('signaturePad',new SignaturePad($(this))); + }); + */ + + // var tHtml = $tempDomObj.wrap('
    ').parent().html(); + this.showDomElement('Edit', $tempDomObj, null, null, true); + $('.filterBtn').off(); + $('.filterBtn').on('click', (e) => { + e.preventDefault(); + e.stopPropagation(); + try { + modJs.filterQuery(); + } catch (err) { + // Do Nothing + } + return false; + }); + + if (this.filter !== undefined && this.filter != null && this.filter !== '') { + this.fillForm(this.filter, `#${this.getTableName()}_filter`, this.getFilters()); + } + } + + + /** + * Override this method in your module class to make changes to data fo the form before showing the form + * @method preRenderForm + * @param object {Array} keys value list for populating form + */ + + preRenderForm(object) { + + } + + /** + * Create the form + * @method renderForm + * @param object {Array} keys value list for populating form + */ + + renderForm(object) { + const signatureIds = []; + if (object == null || object === undefined) { + this.currentId = null; + } + + this.preRenderForm(object); + + let formHtml = this.templates.formTemplate; + let html = ''; + const fields = this.getFormFields(); + + for (let i = 0; i < fields.length; i++) { + const metaField = this.getMetaFieldForRendering(fields[i][0]); + if (metaField === '' || metaField === undefined) { + html += this.renderFormField(fields[i]); + } else { + const metaVal = object[metaField]; + if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { + html += this.renderFormField(JSON.parse(metaVal)); + } else { + html += this.renderFormField(fields[i]); + } + } + } + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_submit`); + formHtml = formHtml.replace(/_fields_/g, html); + + + let $tempDomObj; + const randomFormId = this.generateRandom(14); + if (!this.showFormOnPopup) { + $tempDomObj = $(`#${this.getTableName()}Form`); + } else { + $tempDomObj = $('
    '); + $tempDomObj.attr('id', randomFormId); + } + + $tempDomObj.html(formHtml); + + + $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false, + }); + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en', + }); + + $tempDomObj.find('.colorpick').colorpicker(); + + tinymce.init({ + selector: `#${$tempDomObj.attr('id')} .tinymce`, + height: '400', + }); + + $tempDomObj.find('.simplemde').each(function () { + const simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + // simplemde.value($(this).val()); + }); + + // $tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function () { + $(this).select2().select2('val', $(this).find('option:eq(0)').val()); + }); + + $tempDomObj.find('.select2Multi').each(function () { + $(this).select2().on('change', function (e) { + const parentRow = $(this).parents('.row'); + const height = parentRow.find('.select2-choices').height(); + parentRow.height(parseInt(height, 10)); + }); + }); + + + $tempDomObj.find('.signatureField').each(function () { + // $(this).data('signaturePad',new SignaturePad($(this))); + signatureIds.push($(this).attr('id')); + }); + + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'datagroup') { + $tempDomObj.find(`#${fields[i][0]}`).data('field', fields[i]); + } + } + + if (this.showSave === false) { + $tempDomObj.find('.saveBtn').remove(); + } else { + $tempDomObj.find('.saveBtn').off(); + $tempDomObj.find('.saveBtn').data('modJs', this); + $tempDomObj.find('.saveBtn').on('click', function () { + if ($(this).data('modJs').saveSuccessItemCallback != null && $(this).data('modJs').saveSuccessItemCallback !== undefined) { + $(this).data('modJs').save($(this).data('modJs').retriveItemsAfterSave(), $(this).data('modJs').saveSuccessItemCallback); + } else { + $(this).data('modJs').save(); + } + + return false; + }); + } + + if (this.showCancel === false) { + $tempDomObj.find('.cancelBtn').remove(); + } else { + $tempDomObj.find('.cancelBtn').off(); + $tempDomObj.find('.cancelBtn').data('modJs', this); + $tempDomObj.find('.cancelBtn').on('click', function () { + $(this).data('modJs').cancel(); + return false; + }); + } + + // Input mask + $tempDomObj.find('[mask]').each(function () { + $(this).inputmask($(this).attr('mask')); + }); + + $tempDomObj.find('[datemask]').each(function () { + $(this).inputmask({ + mask: 'y-1-2', + placeholder: 'YYYY-MM-DD', + leapday: '-02-29', + separator: '-', + alias: 'yyyy/mm/dd', + }); + }); + + $tempDomObj.find('[datetimemask]').each(function () { + $(this).inputmask('datetime', { + mask: 'y-2-1 h:s:00', + placeholder: 'YYYY-MM-DD hh:mm:ss', + leapday: '-02-29', + separator: '-', + alias: 'yyyy/mm/dd', + }); + }); + + if (!this.showFormOnPopup) { + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object); + } else { + this.setDefaultValues(); + } + + this.scrollToTop(); + } else { + // var tHtml = $tempDomObj.wrap('
    ').parent().html(); + // this.showMessage("Edit",tHtml,null,null,true); + this.showMessage('Edit', '', null, null, true); + + $('#plainMessageModel .modal-body').html(''); + $('#plainMessageModel .modal-body').append($tempDomObj); + + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object, `#${randomFormId}`); + } else { + this.setDefaultValues(`#${randomFormId}`); + } + } + + this.postRenderForm(object, $tempDomObj); + } + + setDefaultValues(formId, fields) { + if (fields == null || fields === undefined) { + fields = this.getFormFields(); + } + + if (formId == null || formId === undefined || formId === '') { + formId = `#${this.getTableName()}Form`; + } + + + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type !== 'text' && fields[i][1].type !== 'textarea') { + continue; + } + + if (fields[i][1].default !== undefined && fields[i][1].default !== null) { + $(`${formId} #${fields[i][0]}`).val(fields[i][1].default); + } + } + } + + retriveItemsAfterSave() { + return true; + } + + /** + * Override this method in your module class to make changes to data fo the form after showing it + * @method postRenderForm + * @param object {Array} keys value list for populating form + * @param $tempDomObj {DOM} a DOM element for the form + * @example + * UserAdapter.method('postRenderForm(object, $tempDomObj) { + if(object == null || object == undefined){ + $tempDomObj.find("#changePasswordBtn").remove(); + } + } + */ + + postRenderForm(object, $tempDomObj) { + + } + + /** + * Convert data group field to HTML + * @method dataGroupToHtml + * @param val {String} value in the field + * @param field {Array} field meta data + */ + + dataGroupToHtml(val, field) { + const data = JSON.parse(val); + + + let t; let sortFunction; let item; let itemHtml; let itemVal; + + const deleteButton = '
  • '; + const editButton = '
  • '; + + const template = field[1].html; + + if (data != null && data !== undefined && field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { + data.sort(field[1]['sort-function']); + } + + + const html = $(`
    `); + + + for (let i = 0; i < data.length; i++) { + item = data[i]; + + if (field[1]['pre-format-function'] !== undefined && field[1]['pre-format-function'] != null) { + item = field[1]['pre-format-function'].apply(this, [item]); + } + + t = template; + t = t.replace('#_delete_#', deleteButton); + t = t.replace('#_edit_#', editButton); + t = t.replace(/#_id_#/g, item.id); + + for (const key in item) { + itemVal = item[key]; + if (itemVal !== undefined && itemVal != null && typeof itemVal === 'string') { + itemVal = itemVal.replace(/(?:\r\n|\r|\n)/g, '
    '); + } + t = t.replace(`#_${key}_#`, itemVal); + } + + if (field[1].render !== undefined && field[1].render != null) { + t = t.replace('#_renderFunction_#', field[1].render(item)); + } + + itemHtml = $(t); + itemHtml.attr('fieldId', `${field[0]}_div`); + html.append(itemHtml); + } + + + return html; + } + + /** + * Reset the DataGroup for a given field + * @method resetDataGroup + * @param field {Array} field meta data + */ + resetDataGroup(field) { + $(`#${field[0]}`).val(''); + $(`#${field[0]}_div`).html(''); + } + + showDataGroup(field, object) { + let formHtml = this.templates.datagroupTemplate; + let html = ''; + const fields = field[1].form; + + if (object !== undefined && object != null && object.id !== undefined) { + this.currentDataGroupItemId = object.id; + } else { + this.currentDataGroupItemId = null; + } + + for (let i = 0; i < fields.length; i++) { + html += this.renderFormField(fields[i]); + } + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_field_${field[0]}`); + formHtml = formHtml.replace(/_fields_/g, html); + + const randomFormId = this.generateRandom(14); + const $tempDomObj = $('
    '); + $tempDomObj.attr('id', randomFormId); + + $tempDomObj.html(formHtml); + + + $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false, + }); + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en', + }); + + $tempDomObj.find('.colorpick').colorpicker(); + + tinymce.init({ + selector: `#${$tempDomObj.attr('id')} .tinymce`, + height: '400', + }); + + $tempDomObj.find('.simplemde').each(function () { + const simplemde = new SimpleMDE({ element: $(this)[0] }); + $(this).data('simplemde', simplemde); + // simplemde.value($(this).val()); + }); + + $tempDomObj.find('.select2Field').each(function () { + $(this).select2().select2('val', $(this).find('option:eq(0)').val()); + }); + + + $tempDomObj.find('.select2Multi').each(function () { + $(this).select2().on('change', function (e) { + const parentRow = $(this).parents('.row'); + const height = parentRow.find('.select2-choices').height(); + parentRow.height(parseInt(height, 10)); + }); + }); + + + this.currentDataGroupField = field; + this.showDomElement(`Add ${field[1].label}`, $tempDomObj, null, null, true); + + if (object !== undefined && object != null) { + this.fillForm(object, `#${this.getTableName()}_field_${field[0]}`, field[1].form); + } else { + this.setDefaultValues(`#${this.getTableName()}_field_${field[0]}`, field[1].form); + } + + + $('.groupAddBtn').off(); + if (object !== undefined && object != null && object.id !== undefined) { + $('.groupAddBtn').on('click', (e) => { + e.preventDefault(); + e.stopPropagation(); + try { + modJs.editDataGroup(); + } catch (err) { + console.log(`Error editing data group: ${err.message}`); + } + return false; + }); + } else { + $('.groupAddBtn').on('click', (e) => { + e.preventDefault(); + e.stopPropagation(); + try { + modJs.addDataGroup(); + } catch (err) { + console.log(`Error adding data group: ${err.message}`); + } + return false; + }); + } + } + + addDataGroup() { + const field = this.currentDataGroupField; let + tempParams; + $(`#${this.getTableName()}_field_${field[0]}_error`).html(''); + $(`#${this.getTableName()}_field_${field[0]}_error`).hide(); + const validator = new FormValidation(`${this.getTableName()}_field_${field[0]}`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + let params = validator.getFormParameters(); + if (field[1]['custom-validate-function'] !== undefined && field[1]['custom-validate-function'] != null) { + tempParams = field[1]['custom-validate-function'].apply(this, [params]); + if (tempParams.valid) { + params = tempParams.params; + } else { + $(`#${this.getTableName()}_field_${field[0]}_error`).html(tempParams.message); + $(`#${this.getTableName()}_field_${field[0]}_error`).show(); + return false; + } + } + + let val = $(`#${field[0]}`).val(); + if (val === '') { + val = '[]'; + } + const data = JSON.parse(val); + + params.id = `${field[0]}_${this.dataGroupGetNextAutoIncrementId(data)}`; + data.push(params); + + + if (field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { + data.sort(field[1]['sort-function']); + } + + val = JSON.stringify(data); + + const html = this.dataGroupToHtml(val, field); + + $(`#${field[0]}_div`).html(''); + $(`#${field[0]}_div`).append(html); + + this.makeDataGroupSortable(field, $(`#${field[0]}_div_inner`)); + + + $(`#${field[0]}`).val(val); + this.orderDataGroup(field); + + this.closeDataMessage(); + + this.showMessage('Item Added', 'This change will be effective only when you save the form'); + } + return true; + } + + nl2br(str, len) { + let t = ''; + try { + const arr = str.split(' '); + let count = 0; + for (let i = 0; i < arr.length; i++) { + count += arr[i].length + 1; + if (count > len) { + t += `${arr[i]}
    `; + count = 0; + } else { + t += `${arr[i]} `; + } + } + } catch (e) { + // Do nothing + } + return t; + } + + makeDataGroupSortable(field, obj) { + obj.data('field', field); + obj.data('firstSort', true); + obj.sortable({ + + create() { + $(this).height($(this).height()); + }, + + 'ui-floating': false, + start(e, uiStart) { + $('#sortable-ul-selector-id').sortable({ + sort(event, ui) { + const $target = $(event.target); + if (!/html|body/i.test($target.offsetParent()[0].tagName)) { + const top = event.pageY - $target.offsetParent().offset().top - (ui.helper.outerHeight(true) / 2); + ui.helper.css({ top: `${top}px` }); + } + }, + }); + }, + revert: true, + stop() { + modJs.orderDataGroup($(this).data('field')); + }, + axis: 'y', + scroll: false, + placeholder: 'sortable-placeholder', + cursor: 'move', + }); + } + + orderDataGroup(field) { + const newArr = []; let + id; + const list = $(`#${field[0]}_div_inner [fieldid='${field[0]}_div']`); + let val = $(`#${field[0]}`).val(); + if (val === '') { + val = '[]'; + } + const data = JSON.parse(val); + list.each(function () { + id = $(this).attr('id'); + for (const index in data) { + if (data[index].id === id) { + newArr.push(data[index]); + break; + } + } + }); + + $(`#${field[0]}`).val(JSON.stringify(newArr)); + } + + + editDataGroup() { + const field = this.currentDataGroupField; + const id = this.currentDataGroupItemId; + const validator = new FormValidation(`${this.getTableName()}_field_${field[0]}`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + let params = validator.getFormParameters(); + + if (field[1]['custom-validate-function'] !== undefined && field[1]['custom-validate-function'] != null) { + const tempParams = field[1]['custom-validate-function'].apply(this, [params]); + if (tempParams.valid) { + params = tempParams.params; + } else { + $(`#${this.getTableName()}_field_${field[0]}_error`).html(tempParams.message); + $(`#${this.getTableName()}_field_${field[0]}_error`).show(); + return false; + } + } + + + if (this.doCustomFilterValidation(params)) { + let val = $(`#${field[0]}`).val(); + if (val === '') { + val = '[]'; + } + const data = JSON.parse(val); + + let editVal = {}; + let editValIndex = -1; + const newVals = []; + for (let i = 0; i < data.length; i++) { + const item = data[i]; + if (item.id === id) { + editVal = item; + editValIndex = i; + } + newVals.push(item); + } + + + params.id = editVal.id; + newVals[editValIndex] = params; + + if (field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { + newVals.sort(field[1]['sort-function']); + } + + val = JSON.stringify(newVals); + $(`#${field[0]}`).val(val); + + const html = this.dataGroupToHtml(val, field); + + this.orderDataGroup(field); + + $(`#${field[0]}_div`).html(''); + $(`#${field[0]}_div`).append(html); + + this.makeDataGroupSortable(field, $(`#${field[0]}_div_inner`)); + + + this.closeDataMessage(); + + this.showMessage('Item Edited', 'This change will be effective only when you save the form'); + } + } + + return true; + } + + editDataGroupItem(id) { + const fieldId = id.substring(0, id.lastIndexOf('_')); + + const val = $(`#${fieldId}`).val(); + const data = JSON.parse(val); + + let editVal = {}; + + for (let i = 0; i < data.length; i++) { + const item = data[i]; + if (item.id === id) { + editVal = item; + } + } + + this.showDataGroup($(`#${fieldId}`).data('field'), editVal); + } + + dataGroupGetNextAutoIncrementId(data) { + let autoId = 1; let + id; + for (let i = 0; i < data.length; i++) { + const item = data[i]; + if (item.id === undefined || item.id == null) { + item.id = 1; + } + id = item.id.substring(item.id.lastIndexOf('_') + 1, item.id.length); + if (id >= autoId) { + autoId = parseInt(id, 10) + 1; + } + } + + return autoId; + } + + + deleteDataGroupItem(id) { + const fieldId = id.substring(0, id.lastIndexOf('_')); + + const val = $(`#${fieldId}`).val(); + const data = JSON.parse(val); + + const newVal = []; + + for (let i = 0; i < data.length; i++) { + const item = data[i]; + if (item.id !== id) { + newVal.push(item); + } + } + + $(`#${fieldId}`).val(JSON.stringify(newVal)); + + $(`#${id}`).remove(); + + this.showMessage('Item Removed', 'Item removed. This change will be effective only when you save the form'); + } + + + /** + * Fill a form with required values after showing it + * @method fillForm + * @param object {Array} form data + * @param formId {String} id of the form + * @param formId {Array} field meta data + */ + + fillForm(object, formId, fields) { + let placeHolderVal; + if (fields == null || fields === undefined) { + fields = this.getFormFields(); + } + + if (formId == null || formId === undefined || formId === '') { + formId = `#${this.getTableName()}Form`; + } + + + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'date') { + if (object[fields[i][0]] !== '0000-00-00' && object[fields[i][0]] !== '' && object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { + $(`${formId} #${fields[i][0]}_date`).datepicker('setValue', object[fields[i][0]]); + } + } else if (fields[i][1].type === 'colorpick') { + if (object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { + $(`${formId} #${fields[i][0]}_colorpick`).colorpicker('setValue', object[fields[i][0]]); + $(`${formId} #${fields[i][0]}`).val(object[fields[i][0]]); + } + } else if (fields[i][1].type === 'datetime' || fields[i][1].type === 'time') { + if (object[fields[i][0]] !== '0000-00-00 00:00:00' && object[fields[i][0]] !== '' && object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { + const tempDate = object[fields[i][0]]; + const arr = tempDate.split(' '); + const dateArr = arr[0].split('-'); + const timeArr = arr[1].split(':'); + $(`${formId} #${fields[i][0]}_datetime`).data('datetimepicker').setLocalDate(new Date(dateArr[0], parseInt(dateArr[1], 10) - 1, dateArr[2], timeArr[0], timeArr[1], timeArr[2])); + } + } else if (fields[i][1].type === 'label') { + $(`${formId} #${fields[i][0]}`).html(object[fields[i][0]]); + } else if (fields[i][1].type === 'placeholder') { + if (fields[i][1]['remote-source'] !== undefined && fields[i][1]['remote-source'] != null) { + const key = `${fields[i][1]['remote-source'][0]}_${fields[i][1]['remote-source'][1]}_${fields[i][1]['remote-source'][2]}`; + placeHolderVal = this.fieldMasterData[key][object[fields[i][0]]]; + } else { + placeHolderVal = object[fields[i][0]]; + } + + if (placeHolderVal === undefined || placeHolderVal == null) { + placeHolderVal = ''; + } else { + try { + placeHolderVal = placeHolderVal.replace(/(?:\r\n|\r|\n)/g, '
    '); + } catch (e) { + // Do nothing + } + } + + if (fields[i][1].formatter !== undefined && fields[i][1].formatter && $.isFunction(fields[i][1].formatter)) { + try { + placeHolderVal = fields[i][1].formatter(placeHolderVal); + } catch (e) { + // Do nothing + } + } + + $(`${formId} #${fields[i][0]}`).html(placeHolderVal); + } else if (fields[i][1].type === 'fileupload') { + if (object[fields[i][0]] != null && object[fields[i][0]] !== undefined && object[fields[i][0]] !== '') { + $(`${formId} #${fields[i][0]}`).html(object[fields[i][0]]); + $(`${formId} #${fields[i][0]}`).attr('val', object[fields[i][0]]); + $(`${formId} #${fields[i][0]}`).show(); + $(`${formId} #${fields[i][0]}_download`).show(); + $(`${formId} #${fields[i][0]}_remove`).show(); + } + if (fields[i][1].readonly === true) { + $(`${formId} #${fields[i][0]}_upload`).remove(); + } + } else if (fields[i][1].type === 'select') { + if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { + object[fields[i][0]] = 'NULL'; + } + $(`${formId} #${fields[i][0]}`).val(object[fields[i][0]]); + } else if (fields[i][1].type === 'select2') { + if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { + object[fields[i][0]] = 'NULL'; + } + $(`${formId} #${fields[i][0]}`).select2('val', object[fields[i][0]]); + } else if (fields[i][1].type === 'select2multi') { + // TODO - SM + if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { + object[fields[i][0]] = 'NULL'; + } + + let msVal = []; + if (object[fields[i][0]] !== undefined && object[fields[i][0]] != null && object[fields[i][0]] !== '') { + try { + msVal = JSON.parse(object[fields[i][0]]); + } catch (e) { + // Do nothing + } + } + + $(`${formId} #${fields[i][0]}`).select2('val', msVal); + const select2Height = $(`${formId} #${fields[i][0]}`).find('.select2-choices').height(); + $(`${formId} #${fields[i][0]}`).find('.controls').css('min-height', `${select2Height}px`); + $(`${formId} #${fields[i][0]}`).css('min-height', `${select2Height}px`); + } else if (fields[i][1].type === 'datagroup') { + try { + const html = this.dataGroupToHtml(object[fields[i][0]], fields[i]); + $(`${formId} #${fields[i][0]}`).val(object[fields[i][0]]); + $(`${formId} #${fields[i][0]}_div`).html(''); + $(`${formId} #${fields[i][0]}_div`).append(html); + + this.makeDataGroupSortable(fields[i], $(`${formId} #${fields[i][0]}_div_inner`)); + } catch (e) { + // Do nothing + } + } else if (fields[i][1].type === 'signature') { + if (object[fields[i][0]] !== '' || object[fields[i][0]] !== undefined + || object[fields[i][0]] != null) { + $(`${formId} #${fields[i][0]}`).data('signaturePad').fromDataURL(object[fields[i][0]]); + } + } else if (fields[i][1].type === 'simplemde') { + $(`${formId} #${fields[i][0]}`).data('simplemde').value(object[fields[i][0]]); + } else { + $(`${formId} #${fields[i][0]}`).val(object[fields[i][0]]); + } + } + } + + /** + * Cancel edit or add new on modules + * @method cancel + */ + + cancel() { + $(`#${this.getTableName()}Form`).hide(); + $(`#${this.getTableName()}`).show(); + } + + renderFormField(field) { + let userId = 0; + if (this.fieldTemplates[field[1].type] === undefined || this.fieldTemplates[field[1].type] == null) { + return ''; + } + let t = this.fieldTemplates[field[1].type]; + field[1].label = this.gt(field[1].label); + if (field[1].validation !== 'none' && field[1].validation !== 'emailOrEmpty' && field[1].validation !== 'numberOrEmpty' && field[1].type !== 'placeholder' && field[1].label.indexOf('*') < 0) { + const tempSelectBoxes = ['select', 'select2']; + if (!(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] === true)) { + field[1].label = `${field[1].label}*`; + } + } + if (field[1].type === 'text' || field[1].type === 'textarea' || field[1].type === 'hidden' || field[1].type === 'label' || field[1].type === 'placeholder') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'select' || field[1].type === 'select2' || field[1].type === 'select2multi') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + if (field[1].source !== undefined && field[1].source != null) { + t = t.replace('_options_', this.renderFormSelectOptions(field[1].source, field)); + } else if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] != null) { + const key = `${field[1]['remote-source'][0]}_${field[1]['remote-source'][1]}_${field[1]['remote-source'][2]}`; + t = t.replace('_options_', this.renderFormSelectOptionsRemote(this.fieldMasterData[key], field)); + } + } else if (field[1].type === 'colorpick') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'date') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'datetime') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'time') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'fileupload') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + const ce = this.getCurrentProfile(); + if (ce != null && ce !== undefined) { + userId = ce.id; + } else { + userId = this.getUser().id * -1; + } + t = t.replace(/_userId_/g, userId); + t = t.replace(/_group_/g, this.tab); + + if (field[1].filetypes !== undefined && field[1].filetypes != null) { + t = t.replace(/_filetypes_/g, field[1].filetypes); + } else { + t = t.replace(/_filetypes_/g, 'all'); + } + + t = t.replace(/_rand_/g, this.generateRandom(14)); + } else if (field[1].type === 'datagroup') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'signature') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } else if (field[1].type === 'tinymce' || field[1].type === 'simplemde') { + t = t.replace(/_id_/g, field[0]); + t = t.replace(/_label_/g, field[1].label); + } + + + if (field[1].validation !== undefined && field[1].validation != null && field[1].validation !== '') { + t = t.replace(/_validation_/g, `validation="${field[1].validation}"`); + } else { + t = t.replace(/_validation_/g, ''); + } + + if (field[1].help !== undefined && field[1].help !== null) { + t = t.replace(/_helpline_/g, field[1].help); + t = t.replace(/_hidden_class_help_/g, ''); + } else { + t = t.replace(/_helpline_/g, ''); + t = t.replace(/_hidden_class_help_/g, 'hide'); + } + + if (field[1].placeholder !== undefined && field[1].placeholder !== null) { + t = t.replace(/_placeholder_/g, `placeholder="${field[1].placeholder}"`); + } else { + t = t.replace(/_placeholder_/g, ''); + } + + if (field[1].mask !== undefined && field[1].mask !== null) { + t = t.replace(/_mask_/g, `mask="${field[1].mask}"`); + } else { + t = t.replace(/_mask_/g, ''); + } + + return t; + } + + renderFormSelectOptions(options, field) { + let html = ''; + + if (field != null && field !== undefined) { + if (field[1]['allow-null'] === true) { + if (field[1]['null-label'] !== undefined && field[1]['null-label'] != null) { + html += ``; + } else { + html += ''; + } + } + } + + + // Sort options + + const tuples = []; + + for (const key in options) { + tuples.push(options[key]); + } + if (field[1].sort === true) { + tuples.sort((a, b) => { + a = a[1]; + b = b[1]; + + // eslint-disable-next-line no-nested-ternary + return a < b ? -1 : (a > b ? 1 : 0); + }); + } + + + for (let i = 0; i < tuples.length; i++) { + const prop = tuples[i][0]; + const value = tuples[i][1]; + let t = ''; + t = t.replace('_id_', prop); + t = t.replace('_val_', this.gt(value)); + html += t; + } + return html; + } + + renderFormSelectOptionsRemote(options, field) { + let html = ''; + if (field[1]['allow-null'] === true) { + if (field[1]['null-label'] !== undefined && field[1]['null-label'] != null) { + html += ``; + } else { + html += ''; + } + } + + // Sort options + + const tuples = []; + + for (const key in options) { + tuples.push([key, options[key]]); + } + if (field[1].sort === 'true') { + tuples.sort((a, b) => { + a = a[1]; + b = b[1]; + + // eslint-disable-next-line no-nested-ternary + return a < b ? -1 : (a > b ? 1 : 0); + }); + } + + for (let i = 0; i < tuples.length; i++) { + const prop = tuples[i][0]; + const value = tuples[i][1]; + + let t = ''; + t = t.replace('_id_', prop); + t = t.replace('_val_', this.gt(value)); + html += t; + } + + + return html; + } + + setCustomTemplates(templates) { + this.customTemplates = templates; + } + + setEmailTemplates(templates) { + this.emailTemplates = templates; + } + + getCustomTemplate(file) { + return this.customTemplates[file]; + } + + setFieldTemplates(templates) { + this.fieldTemplates = templates; + } + + + getMetaFieldForRendering(fieldName) { + return ''; + } + + clearDeleteParams() { + this.deleteParams = {}; + } + + getShowAddNew() { + return this.showAddNew; + } + + /** + * Override this method to change add new button label + * @method getAddNewLabel + */ + + getAddNewLabel() { + return 'Add New'; + } + + /** + * Used to set whether to show the add new button for a module + * @method setShowAddNew + * @param showAddNew {Boolean} value + */ + + setShowAddNew(showAddNew) { + this.showAddNew = showAddNew; + } + + /** + * Used to set whether to show delete button for each entry in module + * @method setShowDelete + * @param val {Boolean} value + */ + setShowDelete(val) { + this.showDelete = val; + } + + + /** + * Used to set whether to show edit button for each entry in module + * @method setShowEdit + * @param val {Boolean} value + */ + + setShowEdit(val) { + this.showEdit = val; + } + + /** + * Used to set whether to show save button in form + * @method setShowSave + * @param val {Boolean} value + */ + + + setShowSave(val) { + this.showSave = val; + } + + + /** + * Used to set whether to show cancel button in form + * @method setShowCancel + * @param val {Boolean} value + */ + + setShowCancel(val) { + this.showCancel = val; + } + + /** + * Datatable option array will be extended with associative array provided here + * @method getCustomTableParams + * @param val {Boolean} value + */ + + + getCustomTableParams() { + return {}; + } + + getActionButtons(obj) { + return modJs.getActionButtonsHtml(obj.aData[0], obj.aData); + } + + + /** + * This return html for action buttons in each row. Override this method if you need to make changes to action buttons. + * @method getActionButtonsHtml + * @param id {int} id of the row + * @param data {Array} data for the row + * @returns {String} html for action buttons + */ + + getActionButtonsHtml(id, data) { + const editButton = ''; + const deleteButton = ''; + const cloneButton = ''; + let html = '
    _edit__delete__clone_
    '; + + if (this.showAddNew) { + html = html.replace('_clone_', cloneButton); + } else { + html = html.replace('_clone_', ''); + } + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + /** + * Generates a random string + * @method generateRandom + * @param length {int} required length of the string + * @returns {String} random string + */ + + generateRandom(length) { + const d = new Date(); + const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + let result = ''; + for (let i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; + return result + d.getTime(); + } + + + checkFileType(elementName, fileTypes) { + const fileElement = document.getElementById(elementName); + let fileExtension = ''; + if (fileElement.value.lastIndexOf('.') > 0) { + fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf('.') + 1, fileElement.value.length); + } + + fileExtension = fileExtension.toLowerCase(); + + const allowed = fileTypes.split(','); + + if (allowed.indexOf(fileExtension) < 0) { + fileElement.value = ''; + this.showMessage('File Type Error', 'Selected file type is not supported'); + this.clearFileElement(elementName); + return false; + } + + return true; + } + + clearFileElement(elementName) { + let control = $(`#${elementName}`); + control.replaceWith(control = control.val('').clone(true)); + } + + + fixJSON(json) { + if (this.noJSONRequests === '1') { + json = window.btoa(json); + } + return json; + } + + + getClientDate(date) { + const offset = this.getClientGMTOffset(); + const tzDate = date.addMinutes(offset * 60); + return tzDate; + } + + getClientGMTOffset() { + const rightNow = new Date(); + const jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); + const temp = jan1.toGMTString(); + const jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); + return (jan1 - jan2) / (1000 * 60 * 60); + } + + /** + * Override this method in a module to provide the help link for the module. Help link of the module on frontend will get updated with this. + * @method getHelpLink + * @returns {String} help link + */ + + getHelpLink() { + return null; + } + + showLoader() { + $('#iceloader').show(); + } + + hideLoader() { + $('#iceloader').hide(); + } + + generateOptions(data) { + const template = ''; + let options = ''; + for (const index in data) { + options += template.replace('__val__', index).replace('__text__', data[index]); + } + + return options; + } + + isModuleInstalled(type, name) { + if (modulesInstalled === undefined || modulesInstalled === null) { + return false; + } + + return (modulesInstalled[`${type}_${name}`] === 1); + } + + + setCustomFields(fields) { + let field; let + parsed; + for (let i = 0; i < fields.length; i++) { + field = fields[i]; + if (field.display !== 'Hidden' && field.data !== '' && field.data !== undefined) { + try { + parsed = JSON.parse(field.data); + if (parsed === undefined || parsed == null) { + continue; + } else if (parsed.length !== 2) { + continue; + } else if (parsed[1].type === undefined || parsed[1].type == null) { + continue; + } + this.customFields.push(parsed); + } catch (e) { + // Do nothing + } + } + } + } + + addCustomFields(fields) { + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + return fields; + } +} + +export default ModuleBase; diff --git a/web/api/Notifications.js b/web/api/Notifications.js deleted file mode 100644 index 34ad6b36..00000000 --- a/web/api/Notifications.js +++ /dev/null @@ -1,138 +0,0 @@ -/* -This file is part of Ice Framework. - -Ice Framework is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Ice Framework is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Ice Framework. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function NotificationManager() { - this.baseUrl = ""; - this.templates = {}; -} - -NotificationManager.method('setBaseUrl' , function(url) { - this.baseUrl = url; -}); - -NotificationManager.method('setTemplates' , function(data) { - this.templates = data; -}); - -NotificationManager.method('setTimeUtils' , function(timeUtils) { - this.timeUtils = timeUtils; -}); - -NotificationManager.method('getNotifications' , function(name, data) { - var that = this; - $.getJSON(this.baseUrl, {'a':'getNotifications'}, function(data) { - if(data.status == "SUCCESS"){ - that.renderNotifications(data.data[1],data.data[0]); - } - }); -}); - -NotificationManager.method('clearPendingNotifications' , function(name, data) { - var that = this; - $.getJSON(this.baseUrl, {'a':'clearNotifications'}, function(data) { - - }); -}); - -NotificationManager.method('renderNotifications' , function(notifications, unreadCount) { - - if(notifications.length == 0){ - return; - } - - var t = this.templates['notifications']; - if(unreadCount > 0){ - t = t.replace('#_count_#',unreadCount); - if(unreadCount > 1){ - t = t.replace('#_header_#',"You have "+unreadCount+" new notifications"); - }else{ - t = t.replace('#_header_#',"You have "+unreadCount+" new notification"); - } - - }else{ - t = t.replace('#_count_#',""); - t = t.replace('#_header_#',"You have no new notifications"); - } - - var notificationStr = ""; - - for (index in notifications){ - notificationStr += this.renderNotification(notifications[index]); - } - - t = t.replace('#_notifications_#',notificationStr); - - $obj = $(t); - - if(unreadCount == 0){ - $obj.find('.label-danger').remove(); - } - - $obj.attr("id","notifications"); - var k = $("#notifications"); - k.replaceWith($obj); - - $(".navbar .menu").slimscroll({ - height: "320px", - alwaysVisible: false, - size: "3px" - }).css("width", "100%"); - - this.timeUtils.convertToRelativeTime($(".notificationTime")); -}); - - -NotificationManager.method('renderNotification' , function(notification) { - var t = this.templates['notification']; - t = t.replace('#_image_#',notification.image); - - try{ - var json = JSON.parse(notification.action); - t = t.replace('#_url_#',this.baseUrl.replace('service.php','?')+json['url']); - }catch(e){ - t = t.replace('#_url_#',""); - } - - t = t.replace('#_time_#',notification.time); - t = t.replace('#_fromName_#',notification.type); - t = t.replace('#_message_#',this.getLineBreakString(notification.message,27)); - return t; -}); - - -NotificationManager.method('getLineBreakString' , function(str, len) { - var t = ""; - try{ - var arr = str.split(" "); - var count = 0; - for(var i=0;i len){ - t += arr[i] + "
    "; - count = 0; - }else{ - t += arr[i] + " "; - } - } - }catch(e){} - return t; -}); \ No newline at end of file diff --git a/web/api/ObjectAdapter.js b/web/api/ObjectAdapter.js new file mode 100644 index 00000000..4fc37df7 --- /dev/null +++ b/web/api/ObjectAdapter.js @@ -0,0 +1,216 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from './AdapterBase'; +/** + * ObjectAdapter + */ + +class ObjectAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.container = null; + this.loadMoreButton = null; + this.start = 0; + this.pageSize = 6; + this.currentPage = 1; + this.hasMoreData = true; + this.searchTerm = ''; + this.searchInput = null; + } + + getObjectHTML(object) { + const template = this.getCustomTemplate(this.getTemplateName()); + let t = template; + for (const index in object) { + t = t.replace(new RegExp(`#_${index}_#`, 'g'), object[index]); + } + return t; + } + + setPageSize(pageSize) { + this.pageSize = pageSize; + } + + addDomEvents(object) { + + } + + getTemplateName() { + return ''; + } + + renderObject(object) { + const objDom = this.getObjectDom(object.id); + + const html = this.getObjectHTML(object); + const domObj = $(html); + + + if (objDom !== undefined && objDom != null) { + objDom.replace(domObj); + } else { + this.container.append(domObj); + } + + this.addDomEvents(domObj); + } + + setContainer(container) { + this.container = container; + } + + setLoadMoreButton(loadMoreButton) { + const that = this; + this.loadMoreButton = loadMoreButton; + this.loadMoreButton.off().on('click', () => { + that.loadMoreButton.attr('disabled', 'disabled'); + that.loadMore([]); + }); + } + + showLoadError(msg) { + $(`#${this.getTableName()}_error`).html(msg); + $(`#${this.getTableName()}_error`).show(); + } + + hideLoadError() { + $(`#${this.getTableName()}_error`).hide(); + } + + setSearchBox(searchInput) { + const that = this; + this.searchInput = searchInput; + this.searchInput.off(); + this.searchInput.keydown(function (event) { + const val = $(this).val(); + if (event.which === 13) { + event.preventDefault(); + that.search([]); + } else if ((event.which === 8 || event.which === 46) && val.length === 1 && that.searchTerm !== '') { + that.search([]); + } + }); + } + + getObjectDom(id) { + const obj = this.container.find(`#obj_${id}`); + if (obj.length) { + return obj; + } + return null; + } + + loadMore(callBackData) { + if (!this.hasMoreData) { + return; + } + this.currentPage++; + this.get(callBackData, true); + } + + get(callBackData, loadMore) { + const that = this; + + this.hideLoadError(); + + if (!loadMore) { + this.currentPage = 1; + if (this.container != null) { + this.container.html(''); + } + this.hasMoreData = true; + this.tableData = []; + } + + this.start = (this.currentPage - 1) * this.pageSize; + + + this.container = $(`#${this.getTableName()}`).find('.objectList'); + + that.showLoader(); + + + let url = `${this.getDataUrl(that.getDataMapping()) + }&iDisplayStart=${this.start}&iDisplayLength=${this.pageSize}&objects=1`; + + if (this.searchTerm !== '' && this.searchTerm !== undefined && this.searchTerm != null) { + url += `&sSearch=${this.searchTerm}`; + } + + $.post(url, (data) => { + that.getSuccessCallBack(callBackData, data); + }, 'json').always(() => { that.hideLoader(); }); + + that.initFieldMasterData(); + + this.trackEvent('get', this.tab, this.table); + } + + search(callBackData) { + const that = this; + this.searchTerm = $(`#${this.getTableName()}_search`).val(); + + this.get(callBackData); + } + + + getSuccessCallBack(callBackData, serverData) { + const data = []; + + if (serverData.length === 0 && this.container.html() === '') { + this.showLoadError('No Results Found !!!'); + return; + } + + if (this.getFilters() == null) { + $(`#${this.getTableName()}_filterBtn`).hide(); + $(`#${this.getTableName()}_resetFilters`).hide(); + } else { + $(`#${this.getTableName()}_filterBtn`).show(); + $(`#${this.getTableName()}_resetFilters`).show(); + if (this.currentFilterString !== '' && this.currentFilterString != null) { + $(`#${this.getTableName()}_resetFilters`).html(`${this.currentFilterString}`); + } else { + $(`#${this.getTableName()}_resetFilters`).html('Reset Filters'); + $(`#${this.getTableName()}_resetFilters`).hide(); + } + } + + $(`#${this.getTableName()}`).find('.search-controls').show(); + if (serverData.length > this.pageSize) { + this.hasMoreData = true; + serverData.pop(); + this.loadMoreButton.removeAttr('disabled'); + this.loadMoreButton.show(); + } else { + this.hasMoreData = false; + this.loadMoreButton.hide(); + } + + this.scrollToElementBottom(this.container); + for (let i = 0; i < serverData.length; i++) { + data.push(this.preProcessTableData(serverData[i])); + } + this.sourceData = serverData; + if (callBackData.callBack !== undefined && callBackData.callBack != null) { + if (callBackData.callBackData === undefined || callBackData.callBackData == null) { + callBackData.callBackData = []; + } + callBackData.callBackData.push(serverData); + callBackData.callBackData.push(data); + this.callFunction(callBackData.callBack, callBackData.callBackData); + } + + this.tableData = data; + + if (!(callBackData.noRender !== undefined && callBackData.noRender != null && callBackData.noRender === true)) { + for (let i = 0; i < data.length; i++) { + this.renderObject(data[i]); + } + } + } +} + +export default ObjectAdapter; diff --git a/web/api/SocialShare.js b/web/api/SocialShare.js index ea7a42b2..df14cd35 100644 --- a/web/api/SocialShare.js +++ b/web/api/SocialShare.js @@ -1,47 +1,49 @@ -function SocialShare(){ -}; +/* eslint-disable no-restricted-globals */ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +const SocialShare = { + facebook: (url) => { + const w = 700; + const h = 500; + const left = (screen.width / 2) - (w / 2); + const top = (screen.height / 2) - (h / 2); -SocialShare.facebook = function(url) { - var w = 700; - var h = 500; - var left = (screen.width/2)-(w/2); - var top = (screen.height/2)-(h/2); - - var url = "https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(url); + url = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`; - window.open(url, "Share on Facebook", "width="+w+",height="+h+",left="+left+",top="+top); + window.open(url, 'Share on Facebook', `width=${w},height=${h},left=${left},top=${top}`); return false; - -}; + }, -SocialShare.google = function(url) { - var w = 500; - var h = 500; - var left = (screen.width/2)-(w/2); - var top = (screen.height/2)-(h/2); - - var url = "https://plus.google.com/share?url="+encodeURIComponent(url); + google: (url) => { + const w = 500; + const h = 500; + const left = (screen.width / 2) - (w / 2); + const top = (screen.height / 2) - (h / 2); - window.open(url, "Share on Google", "width="+w+",height="+h+",left="+left+",top="+top); + url = `https://plus.google.com/share?url=${encodeURIComponent(url)}`; + + window.open(url, 'Share on Google', `width=${w},height=${h},left=${left},top=${top}`); return false; - -}; + }, -SocialShare.linkedin = function(url) { - var w = 500; - var h = 500; - var left = (screen.width/2)-(w/2); - var top = (screen.height/2)-(h/2); - - var url = "https://www.linkedin.com/cws/share?url="+encodeURIComponent(url); + linkedin: (url) => { + const w = 500; + const h = 500; + const left = (screen.width / 2) - (w / 2); + const top = (screen.height / 2) - (h / 2); - window.open(url, "Share on Linked in", "width="+w+",height="+h+",left="+left+",top="+top); + url = `https://www.linkedin.com/cws/share?url=${encodeURIComponent(url)}`; + + window.open(url, 'Share on Linked in', `width=${w},height=${h},left=${left},top=${top}`); return false; - + }, + + twitter(url, msg) { + window.open(`http://twitter.com/share?text=${escape(msg)}&url=${escape(url)}`, 'popup', 'width=550,height=260,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=200,top=200'); + return false; + }, }; -SocialShare.twitter = function(url, msg) { - window.open('http://twitter.com/share?text='+escape(msg) + '&url=' + escape(url),'popup','width=550,height=260,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=200,top=200'); - return false; - -}; \ No newline at end of file +export default SocialShare; diff --git a/web/api/SubAdapterBase.js b/web/api/SubAdapterBase.js new file mode 100644 index 00000000..fefa176f --- /dev/null +++ b/web/api/SubAdapterBase.js @@ -0,0 +1,60 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from './AdapterBase'; +/** + * @class SubAdapterBase + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class SubAdapterBase extends AdapterBase { + deleteRow(id) { + this.deleteParams.id = id; + this.confirmDelete(); + } + + createTable(elementId) { + let item; let itemHtml; let itemDelete; let itemEdit; + const data = this.getTableData(); + + const deleteButton = ``; + const editButton = ``; + + const table = $('
    '); + + // add Header + const header = this.getSubHeader(); + table.append(header); + if (data.length === 0) { + table.append(`${this.getNoDataMessage()}`); + } else { + for (let i = 0; i < data.length; i++) { + item = data[i]; + itemDelete = deleteButton.replace(/_id_/g, item[0]); + itemEdit = editButton.replace(/_id_/g, item[0]); + itemHtml = this.getSubItemHtml(item, itemDelete, itemEdit); + table.append(itemHtml); + } + } + $(`#${elementId}`).html(''); + $(`#${elementId}`).append(table); + $('#plainMessageModel').modal('hide'); + } + + getNoDataMessage() { + return 'No data found'; + } + + getSubHeader() { + const header = $(`

    ${this.getSubHeaderTitle()}

    `); + return header; + } +} + + +export default SubAdapterBase; diff --git a/web/api/TableEditAdapter.js b/web/api/TableEditAdapter.js new file mode 100644 index 00000000..687bda50 --- /dev/null +++ b/web/api/TableEditAdapter.js @@ -0,0 +1,297 @@ +/* global modJs */ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from './AdapterBase'; +/** + * TableEditAdapter + */ + +class TableEditAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.cellDataUpdates = {}; + this.modulePath = ''; + this.rowFieldName = ''; + this.columnFieldName = ''; + this.rowTable = ''; + this.columnTable = ''; + this.valueTable = ''; + this.csvData = []; + this.columnIDMap = {}; + } + + setModulePath(path) { + this.modulePath = path; + } + + setRowFieldName(name) { + this.rowFieldName = name; + } + + setTables(rowTable, columnTable, valueTable) { + this.rowTable = rowTable; + this.columnTable = columnTable; + this.valueTable = valueTable; + } + + setColumnFieldName(name) { + this.columnFieldName = name; + } + + getDataMapping() { + return [ + ]; + } + + + getFormFields() { + return [ + ]; + } + + get() { + this.getAllData(); + } + + getAllData(save) { + let req = {}; + req.rowTable = this.rowTable; + req.columnTable = this.columnTable; + req.valueTable = this.valueTable; + req = this.addAdditionalRequestData('getAllData', req); + req.save = (save === undefined || save == null || save === false) ? 0 : 1; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getAllDataSuccessCallBack'; + callBackData.callBackFail = 'getAllDataFailCallBack'; + + this.customAction('getAllData', this.modulePath, reqJson, callBackData); + } + + getDataItem(row, column, allData) { + const columnData = allData[1]; + const rowData = allData[0]; + const serverData = allData[2]; + + if (column === -1) { + return rowData[row].name; + } + return this.getDataItemByKeyValues(this.rowFieldName, rowData[row].id, this.columnFieldName, columnData[column].id, serverData); + } + + getDataItemByKeyValues(rowKeyName, rowKeyVal, colKeyName, colKeyVal, data) { + for (let i = 0; i < data.length; i++) { + if (data[i][rowKeyName] === rowKeyVal && data[i][colKeyName] === colKeyVal) { + return (data[i].amount !== undefined && data[i].amount != null) ? data[i].amount : ''; + } + } + return ''; + } + + getAllDataSuccessCallBack(allData) { + const serverData = allData[2]; + const columnData = allData[1]; + const rowData = allData[0]; + const data = []; + for (let i = 0; i < rowData.length; i++) { + const row = []; + for (let j = -1; j < columnData.length; j++) { + row[j + 1] = this.getDataItem(i, j, allData); + } + data.push(this.preProcessTableData(row)); + } + this.sourceData = serverData; + + + this.tableData = data; + this.setHeaders(columnData, rowData); + this.createTable(this.getTableName()); + $(`#${this.getTableName()}Form`).hide(); + $(`#${this.getTableName()}`).show(); + + this.csvData = []; + + let tmpRow = []; + for (let i = 0; i < columnData.length; i++) { + tmpRow.push(columnData[i].name); + } + tmpRow = this.modifyCSVHeader(tmpRow); + this.csvData.push(tmpRow); + + for (let i = 0; i < data.length; i++) { + this.csvData.push(data[i]); + } + } + + modifyCSVHeader(header) { + return header; + } + + getAllDataFailCallBack(callBackData, serverData) { + + } + + setHeaders(columns, rows) { + const headers = []; + headers.push({ sTitle: '', sWidth: '180px;' }); + let sclass = ''; + this.columnIDMap = {}; + for (let i = 0; i < columns.length; i++) { + this.columnIDMap[columns[i].id] = i; + if (columns[i].editable === undefined || columns[i].editable == null || columns[i].editable === 'Yes') { + sclass = 'editcell'; + } else { + sclass = ''; + } + headers.push({ + sTitle: columns[i].name, + sClass: sclass, + fnCreatedCell(nTd, sData, oData, iRow, iCol) { + $(nTd).data('colId', columns[iCol - 1].id); + $(nTd).data('rowId', rows[iRow].id); + }, + }); + } + + this.headers = headers; + } + + getHeaders() { + return this.headers; + } + + createTable(elementId) { + const data = this.getTableData(); + const headers = this.getHeaders(); + + if (this.showActionButtons()) { + headers.push({ sTitle: '', sClass: 'center' }); + } + + + if (this.showActionButtons()) { + for (let i = 0; i < data.length; i++) { + data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); + } + } + let html = ''; + html = `${this.getTableTopButtonHtml()}
    `; + + // Find current page + const activePage = $(`#${elementId} .dataTables_paginate .active a`).html(); + let start = 0; + if (activePage !== undefined && activePage != null) { + start = parseInt(activePage, 10) * 15 - 15; + } + + $(`#${elementId}`).html(html); + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + aaData: data, + aoColumns: headers, + bSort: false, + iDisplayLength: 15, + iDisplayStart: start, + }; + + + const customTableParams = this.getCustomTableParams(); + + $.extend(dataTableParams, customTableParams); + + $(`#${elementId} #grid`).dataTable(dataTableParams); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + // $('.tableActionButton').tooltip(); + $(`#${elementId} #grid`).editableTableWidget(); + + $(`#${elementId} #grid .editcell`).on('validate', function (evt, newValue) { + return modJs.validateCellValue($(this), evt, newValue); + }); + + this.afterCreateTable(elementId); + } + + afterCreateTable(elementId) { + + } + + addCellDataUpdate(colId, rowId, data) { + this.cellDataUpdates[`${colId}=${rowId}`] = [colId, rowId, data]; + } + + addAdditionalRequestData(type, req) { + return req; + } + + sendCellDataUpdates() { + let req = this.cellDataUpdates; + req.rowTable = this.rowTable; + req.columnTable = this.columnTable; + req.valueTable = this.valueTable; + req = this.addAdditionalRequestData('updateData', req); + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'updateDataSuccessCallBack'; + callBackData.callBackFail = 'updateDataFailCallBack'; + this.showLoader(); + this.customAction('updateData', this.modulePath, reqJson, callBackData); + } + + updateDataSuccessCallBack(callBackData, serverData) { + this.hideLoader(); + modJs.cellDataUpdates = {}; + modJs.get(); + } + + updateDataFailCallBack(callBackData, serverData) { + this.hideLoader(); + } + + sendAllCellDataUpdates() { + let req = this.cellDataUpdates; + req.rowTable = this.rowTable; + req.columnTable = this.columnTable; + req.valueTable = this.valueTable; + req = this.addAdditionalRequestData('updateAllData', req); + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'updateDataAllSuccessCallBack'; + callBackData.callBackFail = 'updateDataAllFailCallBack'; + this.showLoader(); + this.customAction('updateAllData', this.modulePath, reqJson, callBackData); + } + + updateDataAllSuccessCallBack(callBackData, serverData) { + this.hideLoader(); + modJs.cellDataUpdates = {}; + modJs.getAllData(true); + } + + updateDataAllFailCallBack(callBackData, serverData) { + this.hideLoader(); + } + + showActionButtons() { + return false; + } +} + +export default TableEditAdapter; diff --git a/web/api/TimeUtils.js b/web/api/TimeUtils.js deleted file mode 100644 index 6848378e..00000000 --- a/web/api/TimeUtils.js +++ /dev/null @@ -1,163 +0,0 @@ -/* - This file is part of Ice Framework. - - Ice Framework is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Ice Framework is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Ice Framework. If not, see . - - ------------------------------------------------------------------ - - Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] - Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function TimeUtils() { - -} - -TimeUtils.method('setServerGMToffset' , function(serverGMToffset) { - this.serverGMToffset = serverGMToffset; -}); - -TimeUtils.method('getMySQLFormatDate' , function(date) { - - var format = function(val){ - if(val < 10){return "0"+val;} - return val; - - } - - return date.getUTCFullYear()+"-"+format(date.getUTCMonth()+1)+"-"+format(date.getUTCDate()); -}); - -TimeUtils.method('convertToRelativeTime',function(selector) { - - var that = this; - - var getAmPmTime = function(curHour, curMin) { - var amPm = "am"; - var amPmHour = curHour; - if (amPmHour >= 12) { - amPm = "pm"; - if (amPmHour > 12) { - amPmHour = amPmHour - 12; - } - } - var prefixCurMin = ""; - if (curMin < 10) { - prefixCurMin = "0"; - } - - var prefixCurHour = ""; - if (curHour == 0) { - prefixCurHour = "0"; - } - return " at " + prefixCurHour + amPmHour + ":" + prefixCurMin + curMin + amPm; - }; - - var getBrowserTimeZone = function() { - var current_date = new Date(); - var gmt_offset = current_date.getTimezoneOffset() / 60; - return -gmt_offset; - }; - - var curDate = new Date(); - var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - - - var timezoneDiff = this.serverGMToffset - getBrowserTimeZone(); - var timezoneTimeDiff = timezoneDiff*60*60*1000; - - - selector.each(function () { - try{ - var thisValue = $(this).html(); - // Split value into date and time - var thisValueArray = thisValue.split(" "); - var thisValueDate = thisValueArray[0]; - var thisValueTime = thisValueArray[1]; - - // Split date into components - var thisValueDateArray = thisValueDate.split("-"); - var curYear = thisValueDateArray[0]; - var curMonth = thisValueDateArray[1]-1; - var curDay = thisValueDateArray[2]; - - // Split time into components - var thisValueTimeArray = thisValueTime.split(":"); - var curHour = thisValueTimeArray[0]; - var curMin = thisValueTimeArray[1]; - var curSec = thisValueTimeArray[2]; - - // Create this date - var thisDate = new Date(curYear, curMonth, curDay, curHour, curMin, curSec); - var thisTime = thisDate.getTime(); - var tzDate = new Date(thisTime - timezoneTimeDiff); - //var tzDay = tzDate.getDay();//getDay will return the day of the week not the month - //var tzDay = tzDate.getUTCDate(); //getUTCDate will return the day of the month - var tzDay = tzDate.toString('d'); // - var tzYear = tzDate.getFullYear(); - var tzHour = tzDate.getHours(); - var tzMin = tzDate.getMinutes(); - - // Create the full date - //var fullDate = days[tzDate.getDay()] + ", " + months[tzDate.getMonth()] + " " + tzDay + ", " + tzYear + getAmPmTime(tzHour, tzMin); - var fullDate = days[tzDate.getDay()] + ", " + months[tzDate.getMonth()] + " " + tzDay + ", " + tzYear + getAmPmTime(tzHour, tzMin); - - // Get the time different - var timeDiff = (curDate.getTime() - tzDate.getTime())/1000; - var minDiff = Math.abs(timeDiff/60); - var hourDiff = Math.abs(timeDiff/(60*60)); - var dayDiff = Math.abs(timeDiff/(60*60*24)); - var yearDiff = Math.abs(timeDiff/(60*60*24*365)); - - // If more than a day old, display the month, day and time (and year, if applicable) - var fbDate = ''; - if (dayDiff > 1) { - //fbDate = curDay + " " + months[tzDate.getMonth()].substring(0,3); - fbDate = tzDay + " " + months[tzDate.getMonth()].substring(0,3); - // Add the year, if applicable - if (yearDiff > 1) { - fbDate = fbDate + " "+ curYear; - } - - // Add the time - fbDate = fbDate + getAmPmTime(tzHour, tzMin); - } - // Less than a day old, and more than an hour old - else if (hourDiff >= 1) { - var roundedHour = Math.round(hourDiff); - if (roundedHour == 1) - fbDate = "about an hour ago"; - else - fbDate = roundedHour + " hours ago"; - } - // Less than an hour, and more than a minute - else if (minDiff >= 1) { - var roundedMin = Math.round(minDiff); - if (roundedMin == 1) - fbDate = "about a minute ago"; - else - fbDate = roundedMin + " minutes ago"; - } - // Less than a minute - else if (minDiff < 1) { - fbDate = "less than a minute ago"; - } - - // Update this element - $(this).html(fbDate); - $(this).attr('title', fullDate); - }catch(e){} - }); -}); \ No newline at end of file diff --git a/web/bower_components/flag-icon-css/flags/4x3/ae.svg b/web/bower_components/flag-icon-css/flags/4x3/ae.svg deleted file mode 100644 index a5f82e83..00000000 --- a/web/bower_components/flag-icon-css/flags/4x3/ae.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/web/bower_components/flag-icon-css/flags/4x3/ar-back.svg b/web/bower_components/flag-icon-css/flags/4x3/ar-back.svg new file mode 100644 index 00000000..2bd1a609 --- /dev/null +++ b/web/bower_components/flag-icon-css/flags/4x3/ar-back.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/bower_components/flag-icon-css/flags/4x3/ar.svg b/web/bower_components/flag-icon-css/flags/4x3/ar.svg index 2bd1a609..a5f82e83 100644 --- a/web/bower_components/flag-icon-css/flags/4x3/ar.svg +++ b/web/bower_components/flag-icon-css/flags/4x3/ar.svg @@ -1,31 +1,6 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/web/css/rtl.css b/web/css/rtl.css new file mode 100644 index 00000000..44770a2c --- /dev/null +++ b/web/css/rtl.css @@ -0,0 +1,7 @@ +input, button, select, textarea { + direction: rtl; +} + +table { + direction: rtl; +} diff --git a/web/css/style.css b/web/css/style.css index e0128273..2a2354bc 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -840,4 +840,4 @@ table.dataTable{ .conversation-save-post { padding: 1px 10px; margin-bottom: 15px; -} +} \ No newline at end of file diff --git a/web/dist/common.js b/web/dist/common.js new file mode 100644 index 00000000..7494d8ed --- /dev/null +++ b/web/dist/common.js @@ -0,0 +1,2 @@ +!function(){return function t(r,e,n){function o(a,f){if(!e[a]){if(!r[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var h=e[a]={exports:{}};r[a][0].call(h.exports,function(t){return o(r[a][1][t]||t)},h,h.exports,t,r,e,n)}return e[a].exports}for(var i="function"==typeof require&&require,a=0;a0?n-4:n,c=0;c>16&255,f[u++]=r>>8&255,f[u++]=255&r;2===a&&(r=o[t.charCodeAt(c)]<<2|o[t.charCodeAt(c+1)]>>4,f[u++]=255&r);1===a&&(r=o[t.charCodeAt(c)]<<10|o[t.charCodeAt(c+1)]<<4|o[t.charCodeAt(c+2)]>>2,f[u++]=r>>8&255,f[u++]=255&r);return f},e.fromByteArray=function(t){for(var r,e=t.length,o=e%3,i=[],a=0,f=e-o;af?f:a+16383));1===o?(r=t[e-1],i.push(n[r>>2]+n[r<<4&63]+"==")):2===o&&(r=(t[e-2]<<8)+t[e-1],i.push(n[r>>10]+n[r>>4&63]+n[r<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,u=a.length;f0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function h(t,r,e){for(var o,i,a=[],f=r;f>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return a.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],2:[function(t,r,e){"use strict";var n=t("base64-js"),o=t("ieee754");e.Buffer=f,e.SlowBuffer=function(t){+t!=t&&(t=0);return f.alloc(+t)},e.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=f.prototype,r}function f(t,r,e){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,r,e)}function u(t,r,e){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!f.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var e=0|p(t,r),n=a(e),o=n.write(t,r);o!==e&&(n=n.slice(0,o));return n}(t,r);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(W(t,ArrayBuffer)||t&&W(t.buffer,ArrayBuffer))return function(t,r,e){if(r<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,r){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||W(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var e=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===e)return 0;for(var o=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return j(t).length;default:if(o)return n?-1:D(t).length;r=(""+r).toLowerCase(),o=!0}}function y(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function d(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),F(e=+e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:g(t,r,e,n,o);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):g(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,e,n,o){var i,a=1,f=t.length,u=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a=2,f/=2,u/=2,e/=2}function s(t,r){return 1===a?t[r]:t.readUInt16BE(r*a)}if(o){var h=-1;for(i=e;if&&(e=f-u),i=e;i>=0;i--){for(var c=!0,l=0;lo&&(n=o):n=o;var i=r.length;n>i/2&&(n=i/2);for(var a=0;a>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function S(t,r,e){return 0===r&&e===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(r,e))}function C(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o239?4:s>223?3:s>191?2:1;if(o+c<=e)switch(c){case 1:s<128&&(h=s);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&s)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&s)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],a=t[o+2],f=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&f)&&(u=(15&s)<<18|(63&i)<<12|(63&a)<<6|63&f)>65535&&u<1114112&&(h=u)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=B)return String.fromCharCode.apply(String,t);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,r,e);case"utf8":case"utf-8":return C(this,r,e);case"ascii":return _(this,r,e);case"latin1":case"binary":return U(this,r,e);case"base64":return S(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),""},f.prototype.compare=function(t,r,e,n,o){if(W(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(e>>>=0)-(r>>>=0),u=Math.min(i,a),s=this.slice(n,o),h=t.slice(r,e),c=0;c>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,t,r,e);case"utf8":case"utf-8":return w(this,t,r,e);case"ascii":return b(this,t,r,e);case"latin1":case"binary":return m(this,t,r,e);case"base64":return E(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function _(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;on)&&(e=n);for(var o="",i=r;ie)throw new RangeError("Trying to access beyond buffer length")}function R(t,r,e,n,o,i){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||rt.length)throw new RangeError("Index out of range")}function k(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function I(t,r,e,n,i){return r=+r,e>>>=0,i||k(t,0,e,4),o.write(t,r,e,n,23,4),e+4}function N(t,r,e,n,i){return r=+r,e>>>=0,i||k(t,0,e,8),o.write(t,r,e,n,52,8),e+8}f.prototype.slice=function(t,r){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):t>e&&(t=e),(r=void 0===r?e:~~r)<0?(r+=e)<0&&(r=0):r>e&&(r=e),r>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],o=1,i=0;++i>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},f.prototype.readUInt8=function(t,r){return t>>>=0,r||x(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return t>>>=0,r||x(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t>>>=0,r>>>=0,e||x(t,r,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t>>>=0,r>>>=0,e||x(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},f.prototype.readInt8=function(t,r){return t>>>=0,r||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){t>>>=0,r||x(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return t>>>=0,r||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return t>>>=0,r||x(t,4,this.length),o.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return t>>>=0,r||x(t,8,this.length),o.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r>>>=0,e>>>=0,n)||R(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i>>=0,e>>>=0,n)||R(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,1,255,0),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);R(this,t,r,e,o-1,-o)}var i=0,a=1,f=0;for(this[r]=255&t;++i>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r>>>=0,!n){var o=Math.pow(2,8*e-1);R(this,t,r,e,o-1,-o)}var i=e-1,a=1,f=0;for(this[r+i]=255&t;--i>=0&&(a*=256);)t<0&&0===f&&0!==this[r+i+1]&&(f=1),this[r+i]=(t/a>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r>>>=0,e||R(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},f.prototype.writeFloatLE=function(t,r,e){return I(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return I(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return N(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return N(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r=0;--i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,n),r);return o},f.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function j(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function P(t,r,e,n){for(var o=0;o=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function W(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function F(t){return t!=t}},{"base64-js":1,ieee754:3}],3:[function(t,r,e){e.read=function(t,r,e,n,o){var i,a,f=8*o-n-1,u=(1<>1,h=-7,c=e?o-1:0,l=e?-1:1,p=t[r+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=f;h>0;i=256*i+t[r+c],c+=l,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;h>0;a=256*a+t[r+c],c+=l,h-=8);if(0===i)i=1-s;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=s}return(p?-1:1)*a*Math.pow(2,i-n)},e.write=function(t,r,e,n,o,i){var a,f,u,s=8*i-o-1,h=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,d=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,a=h):(a=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-a))<1&&(a--,u*=2),(r+=a+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(a++,u/=2),a+c>=h?(f=0,a=h):a+c>=1?(f=(r*u-1)*Math.pow(2,o),a+=c):(f=r*Math.pow(2,c-1)*Math.pow(2,o),a=0));o>=8;t[e+p]=255&f,p+=y,f/=256,o-=8);for(a=a<0;t[e+p]=255&a,p+=y,a/=256,s-=8);t[e+p-y]|=128*d}},{}],4:[function(t,r,e){(function(n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var Aes={cipher:function(t,r){for(var e=r.length/4-1,n=[[],[],[],[]],o=0;o<16;o++)n[o%4][Math.floor(o/4)]=t[o];n=Aes.addRoundKey(n,r,0,4);for(var i=1;i6&&i%r==4&&(o=Aes.subWord(o));for(f=0;f<4;f++)n[i][f]=n[i-r][f]^o[f]}return n},subBytes:function(t,r){for(var e=0;e<4;e++)for(var n=0;n>>8*i&255;for(i=0;i<2;i++)f[i+2]=c>>>8*i&255;for(i=0;i<4;i++)f[i+4]=h>>>8*i&255;var l="";for(i=0;i<8;i++)l+=String.fromCharCode(f[i]);for(var p=Aes.keyExpansion(a),y=Math.ceil(t.length/16),d=new Array(y),g=0;g>>8*v&255;for(v=0;v<4;v++)f[15-v-4]=g/4294967296>>>8*v;var w=Aes.cipher(f,p),b=g>>8*y&255;for(y=0;y<4;y++)f[15-y-4]=(l+1)/4294967296-1>>>8*y&255;var d=Aes.cipher(f,s),g=new Array(t[l].length);for(i=0;i0?(e=e.replace("#_count_#",r),e=r>1?e.replace("#_header_#","You have "+r+" new notifications"):e.replace("#_header_#","You have "+r+" new notification")):e=(e=e.replace("#_count_#","")).replace("#_header_#","You have no new notifications");var n="";for(var o in t)n+=this.renderNotification(t[o]);e=e.replace("#_notifications_#",n);var i=$(e);0===r&&i.find(".label-danger").remove(),i.attr("id","notifications"),$("#notifications").replaceWith(i),$(".navbar .menu").slimscroll({height:"320px",alwaysVisible:!1,size:"3px"}).css("width","100%"),this.timeUtils.convertToRelativeTime($(".notificationTime"))}}},{key:"renderNotification",value:function(t){var r=this.templates.notification;r=r.replace("#_image_#",t.image);try{var e=JSON.parse(t.action);r=r.replace("#_url_#",this.baseUrl.replace("service.php","?")+e.url)}catch(t){r=r.replace("#_url_#","")}return r=(r=(r=r.replace("#_time_#",t.time)).replace("#_fromName_#",t.type)).replace("#_message_#",this.getLineBreakString(t.message,27))}},{key:"getLineBreakString",value:function(t,r){var e="";try{for(var n=t.split(" "),o=0,i=0;ir?(e+=n[i]+"
    ",o=0):e+=n[i]+" "}catch(t){}return e}}]),t}();e.default=o},{}],6:[function(t,r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,r){for(var e=0;e0&&localStorage.removeItem(r)}},{key:"getData",value:function(t){var r=void 0;if("undefined"==typeof Storage)return null;var e=localStorage.getItem(t);return void 0!==e&&null!=e&&""!==e?void 0===(r=JSON.parse(e))||null==r?null:void 0!==r.status&&null!=r.status&&"SUCCESS"!==r.status?null:r:null}},{key:"setData",value:function(t,r){if("undefined"==typeof Storage)return null;if(void 0!==r.status&&null!=r.status&&"SUCCESS"!==r.status)return null;var e=JSON.stringify(r);return localStorage.setItem(t,e),e}}]),RequestCache}();e.default=RequestCache},{}],7:[function(t,r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,r){for(var e=0;e=12&&(e="pm",n>12&&(n-=12));var o="";r<10&&(o="0");var i="";return 0===t&&(i="0")," at "+i+n+":"+o+r+e},e=new Date,n=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=60*(this.serverGMToffset- -(new Date).getTimezoneOffset()/60)*60*1e3;t.each(function(){try{var t=$(this).html().split(" "),a=t[0],f=t[1],u=a.split("-"),s=u[0],h=u[1]-1,c=u[2],l=f.split(":"),p=l[0],y=l[1],d=l[2],g=new Date(s,h,c,p,y,d).getTime(),v=new Date(g-i),w=v.toString("d"),b=v.getFullYear(),m=v.getHours(),E=v.getMinutes(),A=o[v.getDay()]+", "+n[v.getMonth()]+" "+w+", "+b+r(m,E),S=(e.getTime()-v.getTime())/1e3,C=Math.abs(S/60),B=Math.abs(S/3600),_=Math.abs(S/86400),U=Math.abs(S/31536e3),T="";if(_>1)T=w+" "+n[v.getMonth()].substring(0,3),U>1&&(T=T+" "+s),T+=r(m,E);else if(B>=1){var M=Math.round(B);T=1===M?"about an hour ago":M+" hours ago"}else if(C>=1){var x=Math.round(C);T=1===x?"about a minute ago":x+" minutes ago"}else C<1&&(T="less than a minute ago");$(this).html(T),$(this).attr("title",A)}catch(t){}})}}]),t}();e.default=o},{}],8:[function(t,r,e){(function(n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var Aes={cipher:function(t,r){for(var e=r.length/4-1,n=[[],[],[],[]],o=0;o<16;o++)n[o%4][Math.floor(o/4)]=t[o];n=Aes.addRoundKey(n,r,0,4);for(var i=1;i6&&i%r==4&&(o=Aes.subWord(o));for(f=0;f<4;f++)n[i][f]=n[i-r][f]^o[f]}return n},subBytes:function(t,r){for(var e=0;e<4;e++)for(var n=0;n>>8*i&255;for(i=0;i<2;i++)f[i+2]=c>>>8*i&255;for(i=0;i<4;i++)f[i+4]=h>>>8*i&255;var l="";for(i=0;i<8;i++)l+=String.fromCharCode(f[i]);for(var p=Aes.keyExpansion(a),y=Math.ceil(t.length/16),d=new Array(y),g=0;g>>8*v&255;for(v=0;v<4;v++)f[15-v-4]=g/4294967296>>>8*v;var w=Aes.cipher(f,p),b=g>>8*y&255;for(y=0;y<4;y++)f[15-y-4]=(l+1)/4294967296-1>>>8*y&255;var d=Aes.cipher(f,s),g=new Array(t[l].length);for(i=0;i.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table-bordered th,.table-bordered td{border:1px solid #ddd!important}}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}img{vertical-align:middle}.img-responsive{display:block;height:auto;max-width:100%}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{margin-top:20px;margin-bottom:10px}h1 small,h2 small,h3 small,h1 .small,h2 .small,h3 .small{font-size:65%}h4,h5,h6{margin-top:10px;margin-bottom:10px}h4 small,h5 small,h6 small,h4 .small,h5 .small,h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:200;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}cite{font-style:normal}.text-muted{color:#999}.text-primary{color:#428bca}.text-primary:hover{color:#3071a9}.text-warning{color:#8a6d3b}.text-warning:hover{color:#66512c}.text-danger{color:#a94442}.text-danger:hover{color:#843534}.text-success{color:#3c763d}.text-success:hover{color:#2b542c}.text-info{color:#31708f}.text-info:hover{color:#245269}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}.list-inline>li:first-child{padding-left:0}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.428571429}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{font-size:17.5px;font-weight:300;line-height:1.25}blockquote p:last-child{margin-bottom:0}blockquote small,blockquote .small{display:block;line-height:1.428571429;color:#999}blockquote small:before,blockquote .small:before{content:'\2014 \00A0'}blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small,blockquote.pull-right .small{text-align:right}blockquote.pull-right small:before,blockquote.pull-right .small:before{content:''}blockquote.pull-right small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}blockquote:before,blockquote:after{content:""}address{margin-bottom:20px;font-style:normal;line-height:1.428571429}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;white-space:nowrap;background-color:#f9f2f4;border-radius:4px}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.428571429;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}@media(min-width:768px){.container{width:750px}}@media(min-width:992px){.container{width:970px}}@media(min-width:1200px){.container{width:1170px}}.row{margin-right:-15px;margin-left:-15px}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666666666666%}.col-xs-10{width:83.33333333333334%}.col-xs-9{width:75%}.col-xs-8{width:66.66666666666666%}.col-xs-7{width:58.333333333333336%}.col-xs-6{width:50%}.col-xs-5{width:41.66666666666667%}.col-xs-4{width:33.33333333333333%}.col-xs-3{width:25%}.col-xs-2{width:16.666666666666664%}.col-xs-1{width:8.333333333333332%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666666666666%}.col-xs-pull-10{right:83.33333333333334%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666666666666%}.col-xs-pull-7{right:58.333333333333336%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666666666667%}.col-xs-pull-4{right:33.33333333333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.666666666666664%}.col-xs-pull-1{right:8.333333333333332%}.col-xs-pull-0{right:0}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666666666666%}.col-xs-push-10{left:83.33333333333334%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666666666666%}.col-xs-push-7{left:58.333333333333336%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666666666667%}.col-xs-push-4{left:33.33333333333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.666666666666664%}.col-xs-push-1{left:8.333333333333332%}.col-xs-push-0{left:0}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666666666666%}.col-xs-offset-10{margin-left:83.33333333333334%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666666666666%}.col-xs-offset-7{margin-left:58.333333333333336%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666666666667%}.col-xs-offset-4{margin-left:33.33333333333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.666666666666664%}.col-xs-offset-1{margin-left:8.333333333333332%}.col-xs-offset-0{margin-left:0}@media(min-width:768px){.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666666666666%}.col-sm-10{width:83.33333333333334%}.col-sm-9{width:75%}.col-sm-8{width:66.66666666666666%}.col-sm-7{width:58.333333333333336%}.col-sm-6{width:50%}.col-sm-5{width:41.66666666666667%}.col-sm-4{width:33.33333333333333%}.col-sm-3{width:25%}.col-sm-2{width:16.666666666666664%}.col-sm-1{width:8.333333333333332%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666666666666%}.col-sm-pull-10{right:83.33333333333334%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666666666666%}.col-sm-pull-7{right:58.333333333333336%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666666666667%}.col-sm-pull-4{right:33.33333333333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.666666666666664%}.col-sm-pull-1{right:8.333333333333332%}.col-sm-pull-0{right:0}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666666666666%}.col-sm-push-10{left:83.33333333333334%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666666666666%}.col-sm-push-7{left:58.333333333333336%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666666666667%}.col-sm-push-4{left:33.33333333333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.666666666666664%}.col-sm-push-1{left:8.333333333333332%}.col-sm-push-0{left:0}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666666666666%}.col-sm-offset-10{margin-left:83.33333333333334%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666666666666%}.col-sm-offset-7{margin-left:58.333333333333336%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666666666667%}.col-sm-offset-4{margin-left:33.33333333333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.666666666666664%}.col-sm-offset-1{margin-left:8.333333333333332%}.col-sm-offset-0{margin-left:0}}@media(min-width:992px){.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666666666666%}.col-md-10{width:83.33333333333334%}.col-md-9{width:75%}.col-md-8{width:66.66666666666666%}.col-md-7{width:58.333333333333336%}.col-md-6{width:50%}.col-md-5{width:41.66666666666667%}.col-md-4{width:33.33333333333333%}.col-md-3{width:25%}.col-md-2{width:16.666666666666664%}.col-md-1{width:8.333333333333332%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666666666666%}.col-md-pull-10{right:83.33333333333334%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666666666666%}.col-md-pull-7{right:58.333333333333336%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666666666667%}.col-md-pull-4{right:33.33333333333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.666666666666664%}.col-md-pull-1{right:8.333333333333332%}.col-md-pull-0{right:0}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666666666666%}.col-md-push-10{left:83.33333333333334%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666666666666%}.col-md-push-7{left:58.333333333333336%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666666666667%}.col-md-push-4{left:33.33333333333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.666666666666664%}.col-md-push-1{left:8.333333333333332%}.col-md-push-0{left:0}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666666666666%}.col-md-offset-10{margin-left:83.33333333333334%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666666666666%}.col-md-offset-7{margin-left:58.333333333333336%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666666666667%}.col-md-offset-4{margin-left:33.33333333333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.666666666666664%}.col-md-offset-1{margin-left:8.333333333333332%}.col-md-offset-0{margin-left:0}}@media(min-width:1200px){.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666666666666%}.col-lg-10{width:83.33333333333334%}.col-lg-9{width:75%}.col-lg-8{width:66.66666666666666%}.col-lg-7{width:58.333333333333336%}.col-lg-6{width:50%}.col-lg-5{width:41.66666666666667%}.col-lg-4{width:33.33333333333333%}.col-lg-3{width:25%}.col-lg-2{width:16.666666666666664%}.col-lg-1{width:8.333333333333332%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666666666666%}.col-lg-pull-10{right:83.33333333333334%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666666666666%}.col-lg-pull-7{right:58.333333333333336%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666666666667%}.col-lg-pull-4{right:33.33333333333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.666666666666664%}.col-lg-pull-1{right:8.333333333333332%}.col-lg-pull-0{right:0}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666666666666%}.col-lg-push-10{left:83.33333333333334%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666666666666%}.col-lg-push-7{left:58.333333333333336%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666666666667%}.col-lg-push-4{left:33.33333333333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.666666666666664%}.col-lg-push-1{left:8.333333333333332%}.col-lg-push-0{left:0}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666666666666%}.col-lg-offset-10{margin-left:83.33333333333334%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666666666666%}.col-lg-offset-7{margin-left:58.333333333333336%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666666666667%}.col-lg-offset-4{margin-left:33.33333333333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.666666666666664%}.col-lg-offset-1{margin-left:8.333333333333332%}.col-lg-offset-0{margin-left:0}}table{max-width:100%;background-color:transparent}th{text-align:left}.table{width:100%;margin-bottom:20px}.table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table>tbody>tr>td,.table>tfoot>tr>td{padding:8px;line-height:1.428571429;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>th,.table>caption+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>td,.table>thead:first-child>tr:first-child>td{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>thead>tr>th,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>tbody>tr>td,.table-condensed>tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-child(odd)>td,.table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#f5f5f5}table col[class*="col-"]{position:static;display:table-column;float:none}table td[class*="col-"],table th[class*="col-"]{display:table-cell;float:none}.table>thead>tr>.active,.table>tbody>tr>.active,.table>tfoot>tr>.active,.table>thead>.active>td,.table>tbody>.active>td,.table>tfoot>.active>td,.table>thead>.active>th,.table>tbody>.active>th,.table>tfoot>.active>th{background-color:#f5f5f5}.table-hover>tbody>tr>.active:hover,.table-hover>tbody>.active:hover>td,.table-hover>tbody>.active:hover>th{background-color:#e8e8e8}.table>thead>tr>.success,.table>tbody>tr>.success,.table>tfoot>tr>.success,.table>thead>.success>td,.table>tbody>.success>td,.table>tfoot>.success>td,.table>thead>.success>th,.table>tbody>.success>th,.table>tfoot>.success>th{background-color:#dff0d8}.table-hover>tbody>tr>.success:hover,.table-hover>tbody>.success:hover>td,.table-hover>tbody>.success:hover>th{background-color:#d0e9c6}.table>thead>tr>.danger,.table>tbody>tr>.danger,.table>tfoot>tr>.danger,.table>thead>.danger>td,.table>tbody>.danger>td,.table>tfoot>.danger>td,.table>thead>.danger>th,.table>tbody>.danger>th,.table>tfoot>.danger>th{background-color:#f2dede}.table-hover>tbody>tr>.danger:hover,.table-hover>tbody>.danger:hover>td,.table-hover>tbody>.danger:hover>th{background-color:#ebcccc}.table>thead>tr>.warning,.table>tbody>tr>.warning,.table>tfoot>tr>.warning,.table>thead>.warning>td,.table>tbody>.warning>td,.table>tfoot>.warning>td,.table>thead>.warning>th,.table>tbody>.warning>th,.table>tfoot>.warning>th{background-color:#fcf8e3}.table-hover>tbody>tr>.warning:hover,.table-hover>tbody>.warning:hover>td,.table-hover>tbody>.warning:hover>th{background-color:#faf2cc}@media(max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-x:scroll;overflow-y:hidden;border:1px solid #ddd;-ms-overflow-style:-ms-autohiding-scrollbar;-webkit-overflow-scrolling:touch}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-family:inherit;font-size:inherit;font-style:inherit}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{height:auto}output{display:block;padding-top:7px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6)}.form-control:-moz-placeholder{color:#999}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{cursor:not-allowed;background-color:#eee}textarea.form-control{height:auto}.form-group{margin-bottom:15px}.radio,.checkbox{display:block;min-height:20px;padding-left:20px;margin-top:10px;margin-bottom:10px;vertical-align:middle}.radio label,.checkbox label{display:inline;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{float:left;margin-left:-20px}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:normal;vertical-align:middle;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],.radio[disabled],.radio-inline[disabled],.checkbox[disabled],.checkbox-inline[disabled],fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"],fieldset[disabled] .radio,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm{height:auto}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-lg{height:46px;line-height:46px}textarea.input-lg{height:auto}.has-warning .help-block,.has-warning .control-label,.has-warning .radio,.has-warning .checkbox,.has-warning .radio-inline,.has-warning .checkbox-inline{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-error .help-block,.has-error .control-label,.has-error .radio,.has-error .checkbox,.has-error .radio-inline,.has-error .checkbox-inline{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-success .help-block,.has-success .control-label,.has-success .radio,.has-success .checkbox,.has-success .radio-inline,.has-success .checkbox-inline{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.form-control-static{margin-bottom:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media(min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block}.form-inline select.form-control{width:auto}.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:none;margin-left:0}}.form-horizontal .control-label,.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .radio,.form-horizontal .checkbox{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-control-static{padding-top:7px}@media(min-width:768px){.form-horizontal .control-label{text-align:right}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{color:#333;background-color:#ebebeb;border-color:#adadad}.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#fff}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{color:#fff;background-color:#3276b1;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-primary .badge{color:#428bca;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{color:#fff;background-color:#ed9c28;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{color:#fff;background-color:#d2322d;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{color:#fff;background-color:#47a447;border-color:#398439}.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{color:#fff;background-color:#39b3d7;border-color:#269abc}.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-link{font-weight:normal;color:#428bca;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#999;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';-webkit-font-smoothing:antialiased;font-style:normal;font-weight:normal;line-height:1;-moz-osx-font-smoothing:grayscale}.glyphicon:empty{width:1em}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px solid;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#428bca;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.428571429;color:#999}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}@media(min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group>.btn:focus,.btn-group-vertical>.btn:focus{outline:0}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar .btn-group{float:left}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group,.btn-toolbar>.btn-group+.btn-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child>.btn:last-child,.btn-group>.btn-group:first-child>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group-xs>.btn{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-bottom-left-radius:4px;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;border-collapse:separate;table-layout:fixed}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}[data-toggle="buttons"]>.btn>input[type="radio"],[data-toggle="buttons"]>.btn>input[type="checkbox"]{display:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*="col-"]{float:none;padding-right:0;padding-left:0}.input-group .form-control{width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;white-space:nowrap}.input-group-btn:first-child>.btn{margin-right:-1px}.input-group-btn:last-child>.btn{margin-left:-1px}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-4px}.input-group-btn>.btn:hover,.input-group-btn>.btn:active{z-index:2}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#999}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#999;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#428bca}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.428571429;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#428bca}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media(min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}@media(min-width:768px){.navbar{border-radius:4px}}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}@media(min-width:768px){.navbar-header{float:left}}.navbar-collapse{max-height:340px;padding-right:15px;padding-left:15px;overflow-x:visible;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse.in{overflow-y:auto}@media(min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse,.navbar-fixed-bottom .navbar-collapse{padding-right:0;padding-left:0}}.container>.navbar-header,.container>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media(min-width:768px){.container>.navbar-header,.container>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media(min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030}@media(min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}@media(min-width:768px){.navbar>.container .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media(min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media(max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media(min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}.navbar-nav.navbar-right:last-child{margin-right:-15px}}@media(min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}@media(min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block}.navbar-form select.form-control{width:auto}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{float:none;margin-left:0}}@media(max-width:767px){.navbar-form .form-group{margin-bottom:5px}}@media(min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}.navbar-form.navbar-right:last-child{margin-right:-15px}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-nav.pull-right>li>.dropdown-menu,.navbar-nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media(min-width:768px){.navbar-text{float:left;margin-right:15px;margin-left:15px}.navbar-text.navbar-right:last-child{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#ccc}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{color:#555;background-color:#e7e7e7}@media(max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#999}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .navbar-nav>li>a{color:#999}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{color:#fff;background-color:#080808}@media(max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#999}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#999}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.428571429;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#eee}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:2;color:#fff;cursor:default;background-color:#428bca;border-color:#428bca}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#999;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.label[href]:hover,.label[href]:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#999}.label-default[href]:hover,.label-default[href]:focus{background-color:#808080}.label-primary{background-color:#428bca}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#3071a9}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#999;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}a.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#428bca;background-color:#fff}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px;margin-bottom:30px;font-size:21px;font-weight:200;line-height:2.1428571435;color:inherit;background-color:#eee}.jumbotron h1,.jumbotron .h1{line-height:1;color:inherit}.jumbotron p{line-height:1.4}.container .jumbotron{border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron{padding-right:60px;padding-left:60px}.jumbotron h1,.jumbotron .h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.thumbnail>img,.thumbnail a>img{display:block;height:auto;max-width:100%;margin-right:auto;margin-left:auto}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active{border-color:#428bca}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable{padding-right:35px}.alert-dismissable .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-size:40px 40px}.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.media,.media-body{overflow:hidden;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,a.list-group-item:focus{text-decoration:none;background-color:#f5f5f5}a.list-group-item.active,a.list-group-item.active:hover,a.list-group-item.active:focus{z-index:2;color:#fff;background-color:#428bca;border-color:#428bca}a.list-group-item.active .list-group-item-heading,a.list-group-item.active:hover .list-group-item-heading,a.list-group-item.active:focus .list-group-item-heading{color:inherit}a.list-group-item.active .list-group-item-text,a.list-group-item.active:hover .list-group-item-text,a.list-group-item.active:focus .list-group-item-text{color:#e1edf7}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel>.list-group{margin-bottom:0}.panel>.list-group .list-group-item{border-width:1px 0}.panel>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel>.list-group .list-group-item:last-child{border-bottom:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive{border-top:1px solid #ddd}.panel>.table>tbody:first-child th,.panel>.table>tbody:first-child td{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.panel>.table-bordered>thead>tr:last-child>th,.panel>.table-responsive>.table-bordered>thead>tr:last-child>th,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th,.panel>.table-bordered>thead>tr:last-child>td,.panel>.table-responsive>.table-bordered>thead>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-group .panel{margin-bottom:0;overflow:hidden;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse .panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse .panel-body{border-top-color:#ddd}.panel-default>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#428bca}.panel-primary>.panel-heading{color:#fff;background-color:#428bca;border-color:#428bca}.panel-primary>.panel-heading+.panel-collapse .panel-body{border-top-color:#428bca}.panel-primary>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#428bca}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse .panel-body{border-top-color:#d6e9c6}.panel-success>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#d6e9c6}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse .panel-body{border-top-color:#faebcc}.panel-warning>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse .panel-body{border-top-color:#ebccd1}.panel-danger>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ebccd1}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse .panel-body{border-top-color:#bce8f1}.panel-info>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#bce8f1}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;display:none;overflow:auto;overflow-y:scroll}.modal.fade .modal-dialog{-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.modal-dialog{position:relative;z-index:1050;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1030;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{min-height:16.428571429px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.428571429}.modal-body{position:relative;padding:20px}.modal-footer{padding:19px 20px 20px;margin-top:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}@media screen and (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}}.tooltip{position:absolute;z-index:1030;display:block;font-size:12px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-left .tooltip-arrow{bottom:0;left:5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-right .tooltip-arrow{right:5px;bottom:0;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-left .tooltip-arrow{top:0;left:5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-right .tooltip-arrow{top:0;right:5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0;content:" "}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0;content:" "}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0;content:" "}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0;content:" "}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;height:auto;max-width:100%;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);opacity:.5;filter:alpha(opacity=50)}.carousel-control.left{background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.5) 0),color-stop(rgba(0,0,0,0.0001) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000',endColorstr='#00000000',GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.0001) 0),color-stop(rgba(0,0,0,0.5) 100%));background-image:linear-gradient(to right,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#80000000',GradientType=1)}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;outline:0;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .glyphicon-chevron-left{left:50%}.carousel-control .icon-next,.carousel-control .glyphicon-chevron-right{right:50%}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;margin-top:-10px;margin-left:-10px;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicons-chevron-left,.carousel-control .glyphicons-chevron-right,.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-15px;margin-left:-15px;font-size:30px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after{display:table;content:" "}.clearfix:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important;visibility:hidden!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,tr.visible-xs,th.visible-xs,td.visible-xs{display:none!important}@media(max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table}tr.visible-xs{display:table-row!important}th.visible-xs,td.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-xs.visible-sm{display:block!important}table.visible-xs.visible-sm{display:table}tr.visible-xs.visible-sm{display:table-row!important}th.visible-xs.visible-sm,td.visible-xs.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-xs.visible-md{display:block!important}table.visible-xs.visible-md{display:table}tr.visible-xs.visible-md{display:table-row!important}th.visible-xs.visible-md,td.visible-xs.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-xs.visible-lg{display:block!important}table.visible-xs.visible-lg{display:table}tr.visible-xs.visible-lg{display:table-row!important}th.visible-xs.visible-lg,td.visible-xs.visible-lg{display:table-cell!important}}.visible-sm,tr.visible-sm,th.visible-sm,td.visible-sm{display:none!important}@media(max-width:767px){.visible-sm.visible-xs{display:block!important}table.visible-sm.visible-xs{display:table}tr.visible-sm.visible-xs{display:table-row!important}th.visible-sm.visible-xs,td.visible-sm.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table}tr.visible-sm{display:table-row!important}th.visible-sm,td.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-sm.visible-md{display:block!important}table.visible-sm.visible-md{display:table}tr.visible-sm.visible-md{display:table-row!important}th.visible-sm.visible-md,td.visible-sm.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-sm.visible-lg{display:block!important}table.visible-sm.visible-lg{display:table}tr.visible-sm.visible-lg{display:table-row!important}th.visible-sm.visible-lg,td.visible-sm.visible-lg{display:table-cell!important}}.visible-md,tr.visible-md,th.visible-md,td.visible-md{display:none!important}@media(max-width:767px){.visible-md.visible-xs{display:block!important}table.visible-md.visible-xs{display:table}tr.visible-md.visible-xs{display:table-row!important}th.visible-md.visible-xs,td.visible-md.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-md.visible-sm{display:block!important}table.visible-md.visible-sm{display:table}tr.visible-md.visible-sm{display:table-row!important}th.visible-md.visible-sm,td.visible-md.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table}tr.visible-md{display:table-row!important}th.visible-md,td.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-md.visible-lg{display:block!important}table.visible-md.visible-lg{display:table}tr.visible-md.visible-lg{display:table-row!important}th.visible-md.visible-lg,td.visible-md.visible-lg{display:table-cell!important}}.visible-lg,tr.visible-lg,th.visible-lg,td.visible-lg{display:none!important}@media(max-width:767px){.visible-lg.visible-xs{display:block!important}table.visible-lg.visible-xs{display:table}tr.visible-lg.visible-xs{display:table-row!important}th.visible-lg.visible-xs,td.visible-lg.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-lg.visible-sm{display:block!important}table.visible-lg.visible-sm{display:table}tr.visible-lg.visible-sm{display:table-row!important}th.visible-lg.visible-sm,td.visible-lg.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-lg.visible-md{display:block!important}table.visible-lg.visible-md{display:table}tr.visible-lg.visible-md{display:table-row!important}th.visible-lg.visible-md,td.visible-lg.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table}tr.visible-lg{display:table-row!important}th.visible-lg,td.visible-lg{display:table-cell!important}}.hidden-xs{display:block!important}table.hidden-xs{display:table}tr.hidden-xs{display:table-row!important}th.hidden-xs,td.hidden-xs{display:table-cell!important}@media(max-width:767px){.hidden-xs,tr.hidden-xs,th.hidden-xs,td.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-xs.hidden-sm,tr.hidden-xs.hidden-sm,th.hidden-xs.hidden-sm,td.hidden-xs.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-xs.hidden-md,tr.hidden-xs.hidden-md,th.hidden-xs.hidden-md,td.hidden-xs.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-xs.hidden-lg,tr.hidden-xs.hidden-lg,th.hidden-xs.hidden-lg,td.hidden-xs.hidden-lg{display:none!important}}.hidden-sm{display:block!important}table.hidden-sm{display:table}tr.hidden-sm{display:table-row!important}th.hidden-sm,td.hidden-sm{display:table-cell!important}@media(max-width:767px){.hidden-sm.hidden-xs,tr.hidden-sm.hidden-xs,th.hidden-sm.hidden-xs,td.hidden-sm.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-sm,tr.hidden-sm,th.hidden-sm,td.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-sm.hidden-md,tr.hidden-sm.hidden-md,th.hidden-sm.hidden-md,td.hidden-sm.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-sm.hidden-lg,tr.hidden-sm.hidden-lg,th.hidden-sm.hidden-lg,td.hidden-sm.hidden-lg{display:none!important}}.hidden-md{display:block!important}table.hidden-md{display:table}tr.hidden-md{display:table-row!important}th.hidden-md,td.hidden-md{display:table-cell!important}@media(max-width:767px){.hidden-md.hidden-xs,tr.hidden-md.hidden-xs,th.hidden-md.hidden-xs,td.hidden-md.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-md.hidden-sm,tr.hidden-md.hidden-sm,th.hidden-md.hidden-sm,td.hidden-md.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-md,tr.hidden-md,th.hidden-md,td.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-md.hidden-lg,tr.hidden-md.hidden-lg,th.hidden-md.hidden-lg,td.hidden-md.hidden-lg{display:none!important}}.hidden-lg{display:block!important}table.hidden-lg{display:table}tr.hidden-lg{display:table-row!important}th.hidden-lg,td.hidden-lg{display:table-cell!important}@media(max-width:767px){.hidden-lg.hidden-xs,tr.hidden-lg.hidden-xs,th.hidden-lg.hidden-xs,td.hidden-lg.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-lg.hidden-sm,tr.hidden-lg.hidden-sm,th.hidden-lg.hidden-sm,td.hidden-lg.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-lg.hidden-md,tr.hidden-lg.hidden-md,th.hidden-lg.hidden-md,td.hidden-lg.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-lg,tr.hidden-lg,th.hidden-lg,td.hidden-lg{display:none!important}}.visible-print,tr.visible-print,th.visible-print,td.visible-print{display:none!important}@media print{.visible-print{display:block!important}table.visible-print{display:table}tr.visible-print{display:table-row!important}th.visible-print,td.visible-print{display:table-cell!important}.hidden-print,tr.hidden-print,th.hidden-print,td.hidden-print{display:none!important}} +/*! + * Font Awesome 4.2.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.2.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"} +/*! + Ionicons, v1.4.0 + Created by Ben Sperry for the Ionic Framework, http://ionicons.com/ + https://twitter.com/helloimben https://twitter.com/ionicframework + MIT License: https://github.com/driftyco/ionicons +*/@font-face{font-family:"Ionicons";src:url("../fonts/ionicons.eot?v=1.4.0");src:url("../fonts/ionicons.eot?v=1.4.0#iefix") format("embedded-opentype"),url("../fonts/ionicons.ttf?v=1.4.0") format("truetype"),url("../fonts/ionicons.woff?v=1.4.0") format("woff"),url("../fonts/ionicons.svg?v=1.4.0#Ionicons") format("svg");font-weight:normal;font-style:normal}.ion,.ion-loading-a,.ion-loading-b,.ion-loading-c,.ion-loading-d,.ion-looping,.ion-refreshing,.ion-ios7-reloading,.ionicons,.ion-alert,.ion-alert-circled,.ion-android-add,.ion-android-add-contact,.ion-android-alarm,.ion-android-archive,.ion-android-arrow-back,.ion-android-arrow-down-left,.ion-android-arrow-down-right,.ion-android-arrow-up-left,.ion-android-arrow-up-right,.ion-android-battery,.ion-android-book,.ion-android-calendar,.ion-android-call,.ion-android-camera,.ion-android-chat,.ion-android-checkmark,.ion-android-clock,.ion-android-close,.ion-android-contact,.ion-android-contacts,.ion-android-data,.ion-android-developer,.ion-android-display,.ion-android-download,.ion-android-dropdown,.ion-android-earth,.ion-android-folder,.ion-android-forums,.ion-android-friends,.ion-android-hand,.ion-android-image,.ion-android-inbox,.ion-android-information,.ion-android-keypad,.ion-android-lightbulb,.ion-android-locate,.ion-android-location,.ion-android-mail,.ion-android-microphone,.ion-android-mixer,.ion-android-more,.ion-android-note,.ion-android-playstore,.ion-android-printer,.ion-android-promotion,.ion-android-reminder,.ion-android-remove,.ion-android-search,.ion-android-send,.ion-android-settings,.ion-android-share,.ion-android-social,.ion-android-social-user,.ion-android-sort,.ion-android-star,.ion-android-stopwatch,.ion-android-storage,.ion-android-system-back,.ion-android-system-home,.ion-android-system-windows,.ion-android-timer,.ion-android-trash,.ion-android-volume,.ion-android-wifi,.ion-archive,.ion-arrow-down-a,.ion-arrow-down-b,.ion-arrow-down-c,.ion-arrow-expand,.ion-arrow-graph-down-left,.ion-arrow-graph-down-right,.ion-arrow-graph-up-left,.ion-arrow-graph-up-right,.ion-arrow-left-a,.ion-arrow-left-b,.ion-arrow-left-c,.ion-arrow-move,.ion-arrow-resize,.ion-arrow-return-left,.ion-arrow-return-right,.ion-arrow-right-a,.ion-arrow-right-b,.ion-arrow-right-c,.ion-arrow-shrink,.ion-arrow-swap,.ion-arrow-up-a,.ion-arrow-up-b,.ion-arrow-up-c,.ion-at,.ion-bag,.ion-battery-charging,.ion-battery-empty,.ion-battery-full,.ion-battery-half,.ion-battery-low,.ion-beaker,.ion-beer,.ion-bluetooth,.ion-bookmark,.ion-briefcase,.ion-bug,.ion-calculator,.ion-calendar,.ion-camera,.ion-card,.ion-chatbox,.ion-chatbox-working,.ion-chatboxes,.ion-chatbubble,.ion-chatbubble-working,.ion-chatbubbles,.ion-checkmark,.ion-checkmark-circled,.ion-checkmark-round,.ion-chevron-down,.ion-chevron-left,.ion-chevron-right,.ion-chevron-up,.ion-clipboard,.ion-clock,.ion-close,.ion-close-circled,.ion-close-round,.ion-cloud,.ion-code,.ion-code-download,.ion-code-working,.ion-coffee,.ion-compass,.ion-compose,.ion-connection-bars,.ion-contrast,.ion-disc,.ion-document,.ion-document-text,.ion-drag,.ion-earth,.ion-edit,.ion-egg,.ion-eject,.ion-email,.ion-eye,.ion-eye-disabled,.ion-female,.ion-filing,.ion-film-marker,.ion-flag,.ion-flash,.ion-flash-off,.ion-flask,.ion-folder,.ion-fork,.ion-fork-repo,.ion-forward,.ion-game-controller-a,.ion-game-controller-b,.ion-gear-a,.ion-gear-b,.ion-grid,.ion-hammer,.ion-headphone,.ion-heart,.ion-help,.ion-help-buoy,.ion-help-circled,.ion-home,.ion-icecream,.ion-icon-social-google-plus,.ion-icon-social-google-plus-outline,.ion-image,.ion-images,.ion-information,.ion-information-circled,.ion-ionic,.ion-ios7-alarm,.ion-ios7-alarm-outline,.ion-ios7-albums,.ion-ios7-albums-outline,.ion-ios7-arrow-back,.ion-ios7-arrow-down,.ion-ios7-arrow-forward,.ion-ios7-arrow-left,.ion-ios7-arrow-right,.ion-ios7-arrow-thin-down,.ion-ios7-arrow-thin-left,.ion-ios7-arrow-thin-right,.ion-ios7-arrow-thin-up,.ion-ios7-arrow-up,.ion-ios7-at,.ion-ios7-at-outline,.ion-ios7-bell,.ion-ios7-bell-outline,.ion-ios7-bolt,.ion-ios7-bolt-outline,.ion-ios7-bookmarks,.ion-ios7-bookmarks-outline,.ion-ios7-box,.ion-ios7-box-outline,.ion-ios7-briefcase,.ion-ios7-briefcase-outline,.ion-ios7-browsers,.ion-ios7-browsers-outline,.ion-ios7-calculator,.ion-ios7-calculator-outline,.ion-ios7-calendar,.ion-ios7-calendar-outline,.ion-ios7-camera,.ion-ios7-camera-outline,.ion-ios7-cart,.ion-ios7-cart-outline,.ion-ios7-chatboxes,.ion-ios7-chatboxes-outline,.ion-ios7-chatbubble,.ion-ios7-chatbubble-outline,.ion-ios7-checkmark,.ion-ios7-checkmark-empty,.ion-ios7-checkmark-outline,.ion-ios7-circle-filled,.ion-ios7-circle-outline,.ion-ios7-clock,.ion-ios7-clock-outline,.ion-ios7-close,.ion-ios7-close-empty,.ion-ios7-close-outline,.ion-ios7-cloud,.ion-ios7-cloud-download,.ion-ios7-cloud-download-outline,.ion-ios7-cloud-outline,.ion-ios7-cloud-upload,.ion-ios7-cloud-upload-outline,.ion-ios7-cloudy,.ion-ios7-cloudy-night,.ion-ios7-cloudy-night-outline,.ion-ios7-cloudy-outline,.ion-ios7-cog,.ion-ios7-cog-outline,.ion-ios7-compose,.ion-ios7-compose-outline,.ion-ios7-contact,.ion-ios7-contact-outline,.ion-ios7-copy,.ion-ios7-copy-outline,.ion-ios7-download,.ion-ios7-download-outline,.ion-ios7-drag,.ion-ios7-email,.ion-ios7-email-outline,.ion-ios7-eye,.ion-ios7-eye-outline,.ion-ios7-fastforward,.ion-ios7-fastforward-outline,.ion-ios7-filing,.ion-ios7-filing-outline,.ion-ios7-film,.ion-ios7-film-outline,.ion-ios7-flag,.ion-ios7-flag-outline,.ion-ios7-folder,.ion-ios7-folder-outline,.ion-ios7-gear,.ion-ios7-gear-outline,.ion-ios7-glasses,.ion-ios7-glasses-outline,.ion-ios7-heart,.ion-ios7-heart-outline,.ion-ios7-help,.ion-ios7-help-empty,.ion-ios7-help-outline,.ion-ios7-infinite,.ion-ios7-infinite-outline,.ion-ios7-information,.ion-ios7-information-empty,.ion-ios7-information-outline,.ion-ios7-ionic-outline,.ion-ios7-keypad,.ion-ios7-keypad-outline,.ion-ios7-lightbulb,.ion-ios7-lightbulb-outline,.ion-ios7-location,.ion-ios7-location-outline,.ion-ios7-locked,.ion-ios7-locked-outline,.ion-ios7-medkit,.ion-ios7-medkit-outline,.ion-ios7-mic,.ion-ios7-mic-off,.ion-ios7-mic-outline,.ion-ios7-minus,.ion-ios7-minus-empty,.ion-ios7-minus-outline,.ion-ios7-monitor,.ion-ios7-monitor-outline,.ion-ios7-moon,.ion-ios7-moon-outline,.ion-ios7-more,.ion-ios7-more-outline,.ion-ios7-musical-note,.ion-ios7-musical-notes,.ion-ios7-navigate,.ion-ios7-navigate-outline,.ion-ios7-paperplane,.ion-ios7-paperplane-outline,.ion-ios7-partlysunny,.ion-ios7-partlysunny-outline,.ion-ios7-pause,.ion-ios7-pause-outline,.ion-ios7-people,.ion-ios7-people-outline,.ion-ios7-person,.ion-ios7-person-outline,.ion-ios7-personadd,.ion-ios7-personadd-outline,.ion-ios7-photos,.ion-ios7-photos-outline,.ion-ios7-pie,.ion-ios7-pie-outline,.ion-ios7-play,.ion-ios7-play-outline,.ion-ios7-plus,.ion-ios7-plus-empty,.ion-ios7-plus-outline,.ion-ios7-pricetag,.ion-ios7-pricetag-outline,.ion-ios7-printer,.ion-ios7-printer-outline,.ion-ios7-rainy,.ion-ios7-rainy-outline,.ion-ios7-recording,.ion-ios7-recording-outline,.ion-ios7-redo,.ion-ios7-redo-outline,.ion-ios7-refresh,.ion-ios7-refresh-empty,.ion-ios7-refresh-outline,.ion-ios7-reload,.ion-ios7-rewind,.ion-ios7-rewind-outline,.ion-ios7-search,.ion-ios7-search-strong,.ion-ios7-skipbackward,.ion-ios7-skipbackward-outline,.ion-ios7-skipforward,.ion-ios7-skipforward-outline,.ion-ios7-snowy,.ion-ios7-speedometer,.ion-ios7-speedometer-outline,.ion-ios7-star,.ion-ios7-star-outline,.ion-ios7-stopwatch,.ion-ios7-stopwatch-outline,.ion-ios7-sunny,.ion-ios7-sunny-outline,.ion-ios7-telephone,.ion-ios7-telephone-outline,.ion-ios7-thunderstorm,.ion-ios7-thunderstorm-outline,.ion-ios7-time,.ion-ios7-time-outline,.ion-ios7-timer,.ion-ios7-timer-outline,.ion-ios7-trash,.ion-ios7-trash-outline,.ion-ios7-undo,.ion-ios7-undo-outline,.ion-ios7-unlocked,.ion-ios7-unlocked-outline,.ion-ios7-upload,.ion-ios7-upload-outline,.ion-ios7-videocam,.ion-ios7-videocam-outline,.ion-ios7-volume-high,.ion-ios7-volume-low,.ion-ios7-wineglass,.ion-ios7-wineglass-outline,.ion-ios7-world,.ion-ios7-world-outline,.ion-ipad,.ion-iphone,.ion-ipod,.ion-jet,.ion-key,.ion-knife,.ion-laptop,.ion-leaf,.ion-levels,.ion-lightbulb,.ion-link,.ion-load-a,.ion-load-b,.ion-load-c,.ion-load-d,.ion-location,.ion-locked,.ion-log-in,.ion-log-out,.ion-loop,.ion-magnet,.ion-male,.ion-man,.ion-map,.ion-medkit,.ion-mic-a,.ion-mic-b,.ion-mic-c,.ion-minus,.ion-minus-circled,.ion-minus-round,.ion-model-s,.ion-monitor,.ion-more,.ion-music-note,.ion-navicon,.ion-navicon-round,.ion-navigate,.ion-no-smoking,.ion-nuclear,.ion-paper-airplane,.ion-paperclip,.ion-pause,.ion-person,.ion-person-add,.ion-person-stalker,.ion-pie-graph,.ion-pin,.ion-pinpoint,.ion-pizza,.ion-plane,.ion-play,.ion-playstation,.ion-plus,.ion-plus-circled,.ion-plus-round,.ion-pound,.ion-power,.ion-pricetag,.ion-pricetags,.ion-printer,.ion-radio-waves,.ion-record,.ion-refresh,.ion-reply,.ion-reply-all,.ion-search,.ion-settings,.ion-share,.ion-shuffle,.ion-skip-backward,.ion-skip-forward,.ion-social-android,.ion-social-android-outline,.ion-social-apple,.ion-social-apple-outline,.ion-social-bitcoin,.ion-social-bitcoin-outline,.ion-social-buffer,.ion-social-buffer-outline,.ion-social-designernews,.ion-social-designernews-outline,.ion-social-dribbble,.ion-social-dribbble-outline,.ion-social-dropbox,.ion-social-dropbox-outline,.ion-social-facebook,.ion-social-facebook-outline,.ion-social-freebsd-devil,.ion-social-github,.ion-social-github-outline,.ion-social-googleplus,.ion-social-googleplus-outline,.ion-social-hackernews,.ion-social-hackernews-outline,.ion-social-linkedin,.ion-social-linkedin-outline,.ion-social-pinterest,.ion-social-pinterest-outline,.ion-social-reddit,.ion-social-reddit-outline,.ion-social-rss,.ion-social-rss-outline,.ion-social-skype,.ion-social-skype-outline,.ion-social-tumblr,.ion-social-tumblr-outline,.ion-social-tux,.ion-social-twitter,.ion-social-twitter-outline,.ion-social-vimeo,.ion-social-vimeo-outline,.ion-social-windows,.ion-social-windows-outline,.ion-social-wordpress,.ion-social-wordpress-outline,.ion-social-yahoo,.ion-social-yahoo-outline,.ion-social-youtube,.ion-social-youtube-outline,.ion-speakerphone,.ion-speedometer,.ion-spoon,.ion-star,.ion-stats-bars,.ion-steam,.ion-stop,.ion-thermometer,.ion-thumbsdown,.ion-thumbsup,.ion-trash-a,.ion-trash-b,.ion-umbrella,.ion-unlocked,.ion-upload,.ion-usb,.ion-videocamera,.ion-volume-high,.ion-volume-low,.ion-volume-medium,.ion-volume-mute,.ion-waterdrop,.ion-wifi,.ion-wineglass,.ion-woman,.ion-wrench,.ion-xbox{display:inline-block;font-family:"Ionicons";speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;text-rendering:auto;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ion-spin,.ion-loading-a,.ion-loading-b,.ion-loading-c,.ion-loading-d,.ion-looping,.ion-refreshing,.ion-ios7-reloading{-webkit-animation:spin 1s infinite linear;-moz-animation:spin 1s infinite linear;-o-animation:spin 1s infinite linear;animation:spin 1s infinite linear}@-moz-keyframes spin{0%{-moz-transform:rotate(0deg)}100%{-moz-transform:rotate(359deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0deg)}100%{-o-transform:rotate(359deg)}}@-ms-keyframes spin{0%{-ms-transform:rotate(0deg)}100%{-ms-transform:rotate(359deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}.ion-loading-a{-webkit-animation-timing-function:steps(8, start);-moz-animation-timing-function:steps(8, start);animation-timing-function:steps(8, start)}.ion-alert:before{content:"\f101"}.ion-alert-circled:before{content:"\f100"}.ion-android-add:before{content:"\f2c7"}.ion-android-add-contact:before{content:"\f2c6"}.ion-android-alarm:before{content:"\f2c8"}.ion-android-archive:before{content:"\f2c9"}.ion-android-arrow-back:before{content:"\f2ca"}.ion-android-arrow-down-left:before{content:"\f2cb"}.ion-android-arrow-down-right:before{content:"\f2cc"}.ion-android-arrow-up-left:before{content:"\f2cd"}.ion-android-arrow-up-right:before{content:"\f2ce"}.ion-android-battery:before{content:"\f2cf"}.ion-android-book:before{content:"\f2d0"}.ion-android-calendar:before{content:"\f2d1"}.ion-android-call:before{content:"\f2d2"}.ion-android-camera:before{content:"\f2d3"}.ion-android-chat:before{content:"\f2d4"}.ion-android-checkmark:before{content:"\f2d5"}.ion-android-clock:before{content:"\f2d6"}.ion-android-close:before{content:"\f2d7"}.ion-android-contact:before{content:"\f2d8"}.ion-android-contacts:before{content:"\f2d9"}.ion-android-data:before{content:"\f2da"}.ion-android-developer:before{content:"\f2db"}.ion-android-display:before{content:"\f2dc"}.ion-android-download:before{content:"\f2dd"}.ion-android-dropdown:before{content:"\f2de"}.ion-android-earth:before{content:"\f2df"}.ion-android-folder:before{content:"\f2e0"}.ion-android-forums:before{content:"\f2e1"}.ion-android-friends:before{content:"\f2e2"}.ion-android-hand:before{content:"\f2e3"}.ion-android-image:before{content:"\f2e4"}.ion-android-inbox:before{content:"\f2e5"}.ion-android-information:before{content:"\f2e6"}.ion-android-keypad:before{content:"\f2e7"}.ion-android-lightbulb:before{content:"\f2e8"}.ion-android-locate:before{content:"\f2e9"}.ion-android-location:before{content:"\f2ea"}.ion-android-mail:before{content:"\f2eb"}.ion-android-microphone:before{content:"\f2ec"}.ion-android-mixer:before{content:"\f2ed"}.ion-android-more:before{content:"\f2ee"}.ion-android-note:before{content:"\f2ef"}.ion-android-playstore:before{content:"\f2f0"}.ion-android-printer:before{content:"\f2f1"}.ion-android-promotion:before{content:"\f2f2"}.ion-android-reminder:before{content:"\f2f3"}.ion-android-remove:before{content:"\f2f4"}.ion-android-search:before{content:"\f2f5"}.ion-android-send:before{content:"\f2f6"}.ion-android-settings:before{content:"\f2f7"}.ion-android-share:before{content:"\f2f8"}.ion-android-social:before{content:"\f2fa"}.ion-android-social-user:before{content:"\f2f9"}.ion-android-sort:before{content:"\f2fb"}.ion-android-star:before{content:"\f2fc"}.ion-android-stopwatch:before{content:"\f2fd"}.ion-android-storage:before{content:"\f2fe"}.ion-android-system-back:before{content:"\f2ff"}.ion-android-system-home:before{content:"\f300"}.ion-android-system-windows:before{content:"\f301"}.ion-android-timer:before{content:"\f302"}.ion-android-trash:before{content:"\f303"}.ion-android-volume:before{content:"\f304"}.ion-android-wifi:before{content:"\f305"}.ion-archive:before{content:"\f102"}.ion-arrow-down-a:before{content:"\f103"}.ion-arrow-down-b:before{content:"\f104"}.ion-arrow-down-c:before{content:"\f105"}.ion-arrow-expand:before{content:"\f25e"}.ion-arrow-graph-down-left:before{content:"\f25f"}.ion-arrow-graph-down-right:before{content:"\f260"}.ion-arrow-graph-up-left:before{content:"\f261"}.ion-arrow-graph-up-right:before{content:"\f262"}.ion-arrow-left-a:before{content:"\f106"}.ion-arrow-left-b:before{content:"\f107"}.ion-arrow-left-c:before{content:"\f108"}.ion-arrow-move:before{content:"\f263"}.ion-arrow-resize:before{content:"\f264"}.ion-arrow-return-left:before{content:"\f265"}.ion-arrow-return-right:before{content:"\f266"}.ion-arrow-right-a:before{content:"\f109"}.ion-arrow-right-b:before{content:"\f10a"}.ion-arrow-right-c:before{content:"\f10b"}.ion-arrow-shrink:before{content:"\f267"}.ion-arrow-swap:before{content:"\f268"}.ion-arrow-up-a:before{content:"\f10c"}.ion-arrow-up-b:before{content:"\f10d"}.ion-arrow-up-c:before{content:"\f10e"}.ion-at:before{content:"\f10f"}.ion-bag:before{content:"\f110"}.ion-battery-charging:before{content:"\f111"}.ion-battery-empty:before{content:"\f112"}.ion-battery-full:before{content:"\f113"}.ion-battery-half:before{content:"\f114"}.ion-battery-low:before{content:"\f115"}.ion-beaker:before{content:"\f269"}.ion-beer:before{content:"\f26a"}.ion-bluetooth:before{content:"\f116"}.ion-bookmark:before{content:"\f26b"}.ion-briefcase:before{content:"\f26c"}.ion-bug:before{content:"\f2be"}.ion-calculator:before{content:"\f26d"}.ion-calendar:before{content:"\f117"}.ion-camera:before{content:"\f118"}.ion-card:before{content:"\f119"}.ion-chatbox:before{content:"\f11b"}.ion-chatbox-working:before{content:"\f11a"}.ion-chatboxes:before{content:"\f11c"}.ion-chatbubble:before{content:"\f11e"}.ion-chatbubble-working:before{content:"\f11d"}.ion-chatbubbles:before{content:"\f11f"}.ion-checkmark:before{content:"\f122"}.ion-checkmark-circled:before{content:"\f120"}.ion-checkmark-round:before{content:"\f121"}.ion-chevron-down:before{content:"\f123"}.ion-chevron-left:before{content:"\f124"}.ion-chevron-right:before{content:"\f125"}.ion-chevron-up:before{content:"\f126"}.ion-clipboard:before{content:"\f127"}.ion-clock:before{content:"\f26e"}.ion-close:before{content:"\f12a"}.ion-close-circled:before{content:"\f128"}.ion-close-round:before{content:"\f129"}.ion-cloud:before{content:"\f12b"}.ion-code:before{content:"\f271"}.ion-code-download:before{content:"\f26f"}.ion-code-working:before{content:"\f270"}.ion-coffee:before{content:"\f272"}.ion-compass:before{content:"\f273"}.ion-compose:before{content:"\f12c"}.ion-connection-bars:before{content:"\f274"}.ion-contrast:before{content:"\f275"}.ion-disc:before{content:"\f12d"}.ion-document:before{content:"\f12f"}.ion-document-text:before{content:"\f12e"}.ion-drag:before{content:"\f130"}.ion-earth:before{content:"\f276"}.ion-edit:before{content:"\f2bf"}.ion-egg:before{content:"\f277"}.ion-eject:before{content:"\f131"}.ion-email:before{content:"\f132"}.ion-eye:before{content:"\f133"}.ion-eye-disabled:before{content:"\f306"}.ion-female:before{content:"\f278"}.ion-filing:before{content:"\f134"}.ion-film-marker:before{content:"\f135"}.ion-flag:before{content:"\f279"}.ion-flash:before{content:"\f137"}.ion-flash-off:before{content:"\f136"}.ion-flask:before{content:"\f138"}.ion-folder:before{content:"\f139"}.ion-fork:before{content:"\f27a"}.ion-fork-repo:before{content:"\f2c0"}.ion-forward:before{content:"\f13a"}.ion-game-controller-a:before{content:"\f13b"}.ion-game-controller-b:before{content:"\f13c"}.ion-gear-a:before{content:"\f13d"}.ion-gear-b:before{content:"\f13e"}.ion-grid:before{content:"\f13f"}.ion-hammer:before{content:"\f27b"}.ion-headphone:before{content:"\f140"}.ion-heart:before{content:"\f141"}.ion-help:before{content:"\f143"}.ion-help-buoy:before{content:"\f27c"}.ion-help-circled:before{content:"\f142"}.ion-home:before{content:"\f144"}.ion-icecream:before{content:"\f27d"}.ion-icon-social-google-plus:before{content:"\f146"}.ion-icon-social-google-plus-outline:before{content:"\f145"}.ion-image:before{content:"\f147"}.ion-images:before{content:"\f148"}.ion-information:before{content:"\f14a"}.ion-information-circled:before{content:"\f149"}.ion-ionic:before{content:"\f14b"}.ion-ios7-alarm:before{content:"\f14d"}.ion-ios7-alarm-outline:before{content:"\f14c"}.ion-ios7-albums:before{content:"\f14f"}.ion-ios7-albums-outline:before{content:"\f14e"}.ion-ios7-arrow-back:before{content:"\f150"}.ion-ios7-arrow-down:before{content:"\f151"}.ion-ios7-arrow-forward:before{content:"\f152"}.ion-ios7-arrow-left:before{content:"\f153"}.ion-ios7-arrow-right:before{content:"\f154"}.ion-ios7-arrow-thin-down:before{content:"\f27e"}.ion-ios7-arrow-thin-left:before{content:"\f27f"}.ion-ios7-arrow-thin-right:before{content:"\f280"}.ion-ios7-arrow-thin-up:before{content:"\f281"}.ion-ios7-arrow-up:before{content:"\f155"}.ion-ios7-at:before{content:"\f157"}.ion-ios7-at-outline:before{content:"\f156"}.ion-ios7-bell:before{content:"\f159"}.ion-ios7-bell-outline:before{content:"\f158"}.ion-ios7-bolt:before{content:"\f15b"}.ion-ios7-bolt-outline:before{content:"\f15a"}.ion-ios7-bookmarks:before{content:"\f15d"}.ion-ios7-bookmarks-outline:before{content:"\f15c"}.ion-ios7-box:before{content:"\f15f"}.ion-ios7-box-outline:before{content:"\f15e"}.ion-ios7-briefcase:before{content:"\f283"}.ion-ios7-briefcase-outline:before{content:"\f282"}.ion-ios7-browsers:before{content:"\f161"}.ion-ios7-browsers-outline:before{content:"\f160"}.ion-ios7-calculator:before{content:"\f285"}.ion-ios7-calculator-outline:before{content:"\f284"}.ion-ios7-calendar:before{content:"\f163"}.ion-ios7-calendar-outline:before{content:"\f162"}.ion-ios7-camera:before{content:"\f165"}.ion-ios7-camera-outline:before{content:"\f164"}.ion-ios7-cart:before{content:"\f167"}.ion-ios7-cart-outline:before{content:"\f166"}.ion-ios7-chatboxes:before{content:"\f169"}.ion-ios7-chatboxes-outline:before{content:"\f168"}.ion-ios7-chatbubble:before{content:"\f16b"}.ion-ios7-chatbubble-outline:before{content:"\f16a"}.ion-ios7-checkmark:before{content:"\f16e"}.ion-ios7-checkmark-empty:before{content:"\f16c"}.ion-ios7-checkmark-outline:before{content:"\f16d"}.ion-ios7-circle-filled:before{content:"\f16f"}.ion-ios7-circle-outline:before{content:"\f170"}.ion-ios7-clock:before{content:"\f172"}.ion-ios7-clock-outline:before{content:"\f171"}.ion-ios7-close:before{content:"\f2bc"}.ion-ios7-close-empty:before{content:"\f2bd"}.ion-ios7-close-outline:before{content:"\f2bb"}.ion-ios7-cloud:before{content:"\f178"}.ion-ios7-cloud-download:before{content:"\f174"}.ion-ios7-cloud-download-outline:before{content:"\f173"}.ion-ios7-cloud-outline:before{content:"\f175"}.ion-ios7-cloud-upload:before{content:"\f177"}.ion-ios7-cloud-upload-outline:before{content:"\f176"}.ion-ios7-cloudy:before{content:"\f17a"}.ion-ios7-cloudy-night:before{content:"\f308"}.ion-ios7-cloudy-night-outline:before{content:"\f307"}.ion-ios7-cloudy-outline:before{content:"\f179"}.ion-ios7-cog:before{content:"\f17c"}.ion-ios7-cog-outline:before{content:"\f17b"}.ion-ios7-compose:before{content:"\f17e"}.ion-ios7-compose-outline:before{content:"\f17d"}.ion-ios7-contact:before{content:"\f180"}.ion-ios7-contact-outline:before{content:"\f17f"}.ion-ios7-copy:before{content:"\f182"}.ion-ios7-copy-outline:before{content:"\f181"}.ion-ios7-download:before{content:"\f184"}.ion-ios7-download-outline:before{content:"\f183"}.ion-ios7-drag:before{content:"\f185"}.ion-ios7-email:before{content:"\f187"}.ion-ios7-email-outline:before{content:"\f186"}.ion-ios7-eye:before{content:"\f189"}.ion-ios7-eye-outline:before{content:"\f188"}.ion-ios7-fastforward:before{content:"\f18b"}.ion-ios7-fastforward-outline:before{content:"\f18a"}.ion-ios7-filing:before{content:"\f18d"}.ion-ios7-filing-outline:before{content:"\f18c"}.ion-ios7-film:before{content:"\f18f"}.ion-ios7-film-outline:before{content:"\f18e"}.ion-ios7-flag:before{content:"\f191"}.ion-ios7-flag-outline:before{content:"\f190"}.ion-ios7-folder:before{content:"\f193"}.ion-ios7-folder-outline:before{content:"\f192"}.ion-ios7-gear:before{content:"\f195"}.ion-ios7-gear-outline:before{content:"\f194"}.ion-ios7-glasses:before{content:"\f197"}.ion-ios7-glasses-outline:before{content:"\f196"}.ion-ios7-heart:before{content:"\f199"}.ion-ios7-heart-outline:before{content:"\f198"}.ion-ios7-help:before{content:"\f19c"}.ion-ios7-help-empty:before{content:"\f19a"}.ion-ios7-help-outline:before{content:"\f19b"}.ion-ios7-infinite:before{content:"\f19e"}.ion-ios7-infinite-outline:before{content:"\f19d"}.ion-ios7-information:before{content:"\f1a1"}.ion-ios7-information-empty:before{content:"\f19f"}.ion-ios7-information-outline:before{content:"\f1a0"}.ion-ios7-ionic-outline:before{content:"\f1a2"}.ion-ios7-keypad:before{content:"\f1a4"}.ion-ios7-keypad-outline:before{content:"\f1a3"}.ion-ios7-lightbulb:before{content:"\f287"}.ion-ios7-lightbulb-outline:before{content:"\f286"}.ion-ios7-location:before{content:"\f1a6"}.ion-ios7-location-outline:before{content:"\f1a5"}.ion-ios7-locked:before{content:"\f1a8"}.ion-ios7-locked-outline:before{content:"\f1a7"}.ion-ios7-medkit:before{content:"\f289"}.ion-ios7-medkit-outline:before{content:"\f288"}.ion-ios7-mic:before{content:"\f1ab"}.ion-ios7-mic-off:before{content:"\f1a9"}.ion-ios7-mic-outline:before{content:"\f1aa"}.ion-ios7-minus:before{content:"\f1ae"}.ion-ios7-minus-empty:before{content:"\f1ac"}.ion-ios7-minus-outline:before{content:"\f1ad"}.ion-ios7-monitor:before{content:"\f1b0"}.ion-ios7-monitor-outline:before{content:"\f1af"}.ion-ios7-moon:before{content:"\f1b2"}.ion-ios7-moon-outline:before{content:"\f1b1"}.ion-ios7-more:before{content:"\f1b4"}.ion-ios7-more-outline:before{content:"\f1b3"}.ion-ios7-musical-note:before{content:"\f1b5"}.ion-ios7-musical-notes:before{content:"\f1b6"}.ion-ios7-navigate:before{content:"\f1b8"}.ion-ios7-navigate-outline:before{content:"\f1b7"}.ion-ios7-paperplane:before{content:"\f1ba"}.ion-ios7-paperplane-outline:before{content:"\f1b9"}.ion-ios7-partlysunny:before{content:"\f1bc"}.ion-ios7-partlysunny-outline:before{content:"\f1bb"}.ion-ios7-pause:before{content:"\f1be"}.ion-ios7-pause-outline:before{content:"\f1bd"}.ion-ios7-people:before{content:"\f1c0"}.ion-ios7-people-outline:before{content:"\f1bf"}.ion-ios7-person:before{content:"\f1c2"}.ion-ios7-person-outline:before{content:"\f1c1"}.ion-ios7-personadd:before{content:"\f1c4"}.ion-ios7-personadd-outline:before{content:"\f1c3"}.ion-ios7-photos:before{content:"\f1c6"}.ion-ios7-photos-outline:before{content:"\f1c5"}.ion-ios7-pie:before{content:"\f28b"}.ion-ios7-pie-outline:before{content:"\f28a"}.ion-ios7-play:before{content:"\f1c8"}.ion-ios7-play-outline:before{content:"\f1c7"}.ion-ios7-plus:before{content:"\f1cb"}.ion-ios7-plus-empty:before{content:"\f1c9"}.ion-ios7-plus-outline:before{content:"\f1ca"}.ion-ios7-pricetag:before{content:"\f28d"}.ion-ios7-pricetag-outline:before{content:"\f28c"}.ion-ios7-printer:before{content:"\f1cd"}.ion-ios7-printer-outline:before{content:"\f1cc"}.ion-ios7-rainy:before{content:"\f1cf"}.ion-ios7-rainy-outline:before{content:"\f1ce"}.ion-ios7-recording:before{content:"\f1d1"}.ion-ios7-recording-outline:before{content:"\f1d0"}.ion-ios7-redo:before{content:"\f1d3"}.ion-ios7-redo-outline:before{content:"\f1d2"}.ion-ios7-refresh:before{content:"\f1d6"}.ion-ios7-refresh-empty:before{content:"\f1d4"}.ion-ios7-refresh-outline:before{content:"\f1d5"}.ion-ios7-reload:before,.ion-ios7-reloading:before{content:"\f28e"}.ion-ios7-rewind:before{content:"\f1d8"}.ion-ios7-rewind-outline:before{content:"\f1d7"}.ion-ios7-search:before{content:"\f1da"}.ion-ios7-search-strong:before{content:"\f1d9"}.ion-ios7-skipbackward:before{content:"\f1dc"}.ion-ios7-skipbackward-outline:before{content:"\f1db"}.ion-ios7-skipforward:before{content:"\f1de"}.ion-ios7-skipforward-outline:before{content:"\f1dd"}.ion-ios7-snowy:before{content:"\f309"}.ion-ios7-speedometer:before{content:"\f290"}.ion-ios7-speedometer-outline:before{content:"\f28f"}.ion-ios7-star:before{content:"\f1e0"}.ion-ios7-star-outline:before{content:"\f1df"}.ion-ios7-stopwatch:before{content:"\f1e2"}.ion-ios7-stopwatch-outline:before{content:"\f1e1"}.ion-ios7-sunny:before{content:"\f1e4"}.ion-ios7-sunny-outline:before{content:"\f1e3"}.ion-ios7-telephone:before{content:"\f1e6"}.ion-ios7-telephone-outline:before{content:"\f1e5"}.ion-ios7-thunderstorm:before{content:"\f1e8"}.ion-ios7-thunderstorm-outline:before{content:"\f1e7"}.ion-ios7-time:before{content:"\f292"}.ion-ios7-time-outline:before{content:"\f291"}.ion-ios7-timer:before{content:"\f1ea"}.ion-ios7-timer-outline:before{content:"\f1e9"}.ion-ios7-trash:before{content:"\f1ec"}.ion-ios7-trash-outline:before{content:"\f1eb"}.ion-ios7-undo:before{content:"\f1ee"}.ion-ios7-undo-outline:before{content:"\f1ed"}.ion-ios7-unlocked:before{content:"\f1f0"}.ion-ios7-unlocked-outline:before{content:"\f1ef"}.ion-ios7-upload:before{content:"\f1f2"}.ion-ios7-upload-outline:before{content:"\f1f1"}.ion-ios7-videocam:before{content:"\f1f4"}.ion-ios7-videocam-outline:before{content:"\f1f3"}.ion-ios7-volume-high:before{content:"\f1f5"}.ion-ios7-volume-low:before{content:"\f1f6"}.ion-ios7-wineglass:before{content:"\f294"}.ion-ios7-wineglass-outline:before{content:"\f293"}.ion-ios7-world:before{content:"\f1f8"}.ion-ios7-world-outline:before{content:"\f1f7"}.ion-ipad:before{content:"\f1f9"}.ion-iphone:before{content:"\f1fa"}.ion-ipod:before{content:"\f1fb"}.ion-jet:before{content:"\f295"}.ion-key:before{content:"\f296"}.ion-knife:before{content:"\f297"}.ion-laptop:before{content:"\f1fc"}.ion-leaf:before{content:"\f1fd"}.ion-levels:before{content:"\f298"}.ion-lightbulb:before{content:"\f299"}.ion-link:before{content:"\f1fe"}.ion-load-a:before,.ion-loading-a:before{content:"\f29a"}.ion-load-b:before,.ion-loading-b:before{content:"\f29b"}.ion-load-c:before,.ion-loading-c:before{content:"\f29c"}.ion-load-d:before,.ion-loading-d:before{content:"\f29d"}.ion-location:before{content:"\f1ff"}.ion-locked:before{content:"\f200"}.ion-log-in:before{content:"\f29e"}.ion-log-out:before{content:"\f29f"}.ion-loop:before,.ion-looping:before{content:"\f201"}.ion-magnet:before{content:"\f2a0"}.ion-male:before{content:"\f2a1"}.ion-man:before{content:"\f202"}.ion-map:before{content:"\f203"}.ion-medkit:before{content:"\f2a2"}.ion-mic-a:before{content:"\f204"}.ion-mic-b:before{content:"\f205"}.ion-mic-c:before{content:"\f206"}.ion-minus:before{content:"\f209"}.ion-minus-circled:before{content:"\f207"}.ion-minus-round:before{content:"\f208"}.ion-model-s:before{content:"\f2c1"}.ion-monitor:before{content:"\f20a"}.ion-more:before{content:"\f20b"}.ion-music-note:before{content:"\f20c"}.ion-navicon:before{content:"\f20e"}.ion-navicon-round:before{content:"\f20d"}.ion-navigate:before{content:"\f2a3"}.ion-no-smoking:before{content:"\f2c2"}.ion-nuclear:before{content:"\f2a4"}.ion-paper-airplane:before{content:"\f2c3"}.ion-paperclip:before{content:"\f20f"}.ion-pause:before{content:"\f210"}.ion-person:before{content:"\f213"}.ion-person-add:before{content:"\f211"}.ion-person-stalker:before{content:"\f212"}.ion-pie-graph:before{content:"\f2a5"}.ion-pin:before{content:"\f2a6"}.ion-pinpoint:before{content:"\f2a7"}.ion-pizza:before{content:"\f2a8"}.ion-plane:before{content:"\f214"}.ion-play:before{content:"\f215"}.ion-playstation:before{content:"\f30a"}.ion-plus:before{content:"\f218"}.ion-plus-circled:before{content:"\f216"}.ion-plus-round:before{content:"\f217"}.ion-pound:before{content:"\f219"}.ion-power:before{content:"\f2a9"}.ion-pricetag:before{content:"\f2aa"}.ion-pricetags:before{content:"\f2ab"}.ion-printer:before{content:"\f21a"}.ion-radio-waves:before{content:"\f2ac"}.ion-record:before{content:"\f21b"}.ion-refresh:before,.ion-refreshing:before{content:"\f21c"}.ion-reply:before{content:"\f21e"}.ion-reply-all:before{content:"\f21d"}.ion-search:before{content:"\f21f"}.ion-settings:before{content:"\f2ad"}.ion-share:before{content:"\f220"}.ion-shuffle:before{content:"\f221"}.ion-skip-backward:before{content:"\f222"}.ion-skip-forward:before{content:"\f223"}.ion-social-android:before{content:"\f225"}.ion-social-android-outline:before{content:"\f224"}.ion-social-apple:before{content:"\f227"}.ion-social-apple-outline:before{content:"\f226"}.ion-social-bitcoin:before{content:"\f2af"}.ion-social-bitcoin-outline:before{content:"\f2ae"}.ion-social-buffer:before{content:"\f229"}.ion-social-buffer-outline:before{content:"\f228"}.ion-social-designernews:before{content:"\f22b"}.ion-social-designernews-outline:before{content:"\f22a"}.ion-social-dribbble:before{content:"\f22d"}.ion-social-dribbble-outline:before{content:"\f22c"}.ion-social-dropbox:before{content:"\f22f"}.ion-social-dropbox-outline:before{content:"\f22e"}.ion-social-facebook:before{content:"\f231"}.ion-social-facebook-outline:before{content:"\f230"}.ion-social-freebsd-devil:before{content:"\f2c4"}.ion-social-github:before{content:"\f233"}.ion-social-github-outline:before{content:"\f232"}.ion-social-googleplus:before{content:"\f235"}.ion-social-googleplus-outline:before{content:"\f234"}.ion-social-hackernews:before{content:"\f237"}.ion-social-hackernews-outline:before{content:"\f236"}.ion-social-linkedin:before{content:"\f239"}.ion-social-linkedin-outline:before{content:"\f238"}.ion-social-pinterest:before{content:"\f2b1"}.ion-social-pinterest-outline:before{content:"\f2b0"}.ion-social-reddit:before{content:"\f23b"}.ion-social-reddit-outline:before{content:"\f23a"}.ion-social-rss:before{content:"\f23d"}.ion-social-rss-outline:before{content:"\f23c"}.ion-social-skype:before{content:"\f23f"}.ion-social-skype-outline:before{content:"\f23e"}.ion-social-tumblr:before{content:"\f241"}.ion-social-tumblr-outline:before{content:"\f240"}.ion-social-tux:before{content:"\f2c5"}.ion-social-twitter:before{content:"\f243"}.ion-social-twitter-outline:before{content:"\f242"}.ion-social-vimeo:before{content:"\f245"}.ion-social-vimeo-outline:before{content:"\f244"}.ion-social-windows:before{content:"\f247"}.ion-social-windows-outline:before{content:"\f246"}.ion-social-wordpress:before{content:"\f249"}.ion-social-wordpress-outline:before{content:"\f248"}.ion-social-yahoo:before{content:"\f24b"}.ion-social-yahoo-outline:before{content:"\f24a"}.ion-social-youtube:before{content:"\f24d"}.ion-social-youtube-outline:before{content:"\f24c"}.ion-speakerphone:before{content:"\f2b2"}.ion-speedometer:before{content:"\f2b3"}.ion-spoon:before{content:"\f2b4"}.ion-star:before{content:"\f24e"}.ion-stats-bars:before{content:"\f2b5"}.ion-steam:before{content:"\f30b"}.ion-stop:before{content:"\f24f"}.ion-thermometer:before{content:"\f2b6"}.ion-thumbsdown:before{content:"\f250"}.ion-thumbsup:before{content:"\f251"}.ion-trash-a:before{content:"\f252"}.ion-trash-b:before{content:"\f253"}.ion-umbrella:before{content:"\f2b7"}.ion-unlocked:before{content:"\f254"}.ion-upload:before{content:"\f255"}.ion-usb:before{content:"\f2b8"}.ion-videocamera:before{content:"\f256"}.ion-volume-high:before{content:"\f257"}.ion-volume-low:before{content:"\f258"}.ion-volume-medium:before{content:"\f259"}.ion-volume-mute:before{content:"\f25a"}.ion-waterdrop:before{content:"\f25b"}.ion-wifi:before{content:"\f25c"}.ion-wineglass:before{content:"\f2b9"}.ion-woman:before{content:"\f25d"}.ion-wrench:before{content:"\f2ba"}.ion-xbox:before{content:"\f30c"} + +@font-face { + font-family: 'Material Icons'; + font-style: normal; + font-weight: 400; + src: url(MaterialIcons-Regular.eot); /* For IE6-8 */ + src: local('Material Icons'), + local('MaterialIcons-Regular'), + url(MaterialIcons-Regular.woff2) format('woff2'), + url(MaterialIcons-Regular.woff) format('woff'), + url(MaterialIcons-Regular.ttf) format('truetype'); +} + +.material-icons { + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + + /* Support for all WebKit browsers. */ + -webkit-font-smoothing: antialiased; + /* Support for Safari and Chrome. */ + text-rendering: optimizeLegibility; + + /* Support for Firefox. */ + -moz-osx-font-smoothing: grayscale; + + /* Support for IE. */ + font-feature-settings: 'liga'; +} + +/*! + * FullCalendar v2.4.0 Stylesheet + * Docs & License: http://fullcalendar.io/ + * (c) 2015 Adam Shaw + */ + + +.fc { + direction: ltr; + text-align: left; +} + +.fc-rtl { + text-align: right; +} + +body .fc { /* extra precedence to overcome jqui */ + font-size: 1em; +} + + +/* Colors +--------------------------------------------------------------------------------------------------*/ + +.fc-unthemed th, +.fc-unthemed td, +.fc-unthemed thead, +.fc-unthemed tbody, +.fc-unthemed .fc-divider, +.fc-unthemed .fc-row, +.fc-unthemed .fc-popover { + border-color: #ddd; +} + +.fc-unthemed .fc-popover { + background-color: #fff; +} + +.fc-unthemed .fc-divider, +.fc-unthemed .fc-popover .fc-header { + background: #eee; +} + +.fc-unthemed .fc-popover .fc-header .fc-close { + color: #666; +} + +.fc-unthemed .fc-today { + background: #fcf8e3; +} + +.fc-highlight { /* when user is selecting cells */ + background: #bce8f1; + opacity: .3; + filter: alpha(opacity=30); /* for IE */ +} + +.fc-bgevent { /* default look for background events */ + background: rgb(143, 223, 130); + opacity: .3; + filter: alpha(opacity=30); /* for IE */ +} + +.fc-nonbusiness { /* default look for non-business-hours areas */ + /* will inherit .fc-bgevent's styles */ + background: #d7d7d7; +} + + +/* Icons (inline elements with styled text that mock arrow icons) +--------------------------------------------------------------------------------------------------*/ + +.fc-icon { + display: inline-block; + width: 1em; + height: 1em; + line-height: 1em; + font-size: 1em; + text-align: center; + overflow: hidden; + font-family: "Courier New", Courier, monospace; + + /* don't allow browser text-selection */ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + +/* +Acceptable font-family overrides for individual icons: + "Arial", sans-serif + "Times New Roman", serif + +NOTE: use percentage font sizes or else old IE chokes +*/ + +.fc-icon:after { + position: relative; + margin: 0 -1em; /* ensures character will be centered, regardless of width */ +} + +.fc-icon-left-single-arrow:after { + content: "\02039"; + font-weight: bold; + font-size: 200%; + top: -7%; + left: 3%; +} + +.fc-icon-right-single-arrow:after { + content: "\0203A"; + font-weight: bold; + font-size: 200%; + top: -7%; + left: -3%; +} + +.fc-icon-left-double-arrow:after { + content: "\000AB"; + font-size: 160%; + top: -7%; +} + +.fc-icon-right-double-arrow:after { + content: "\000BB"; + font-size: 160%; + top: -7%; +} + +.fc-icon-left-triangle:after { + content: "\25C4"; + font-size: 125%; + top: 3%; + left: -2%; +} + +.fc-icon-right-triangle:after { + content: "\25BA"; + font-size: 125%; + top: 3%; + left: 2%; +} + +.fc-icon-down-triangle:after { + content: "\25BC"; + font-size: 125%; + top: 2%; +} + +.fc-icon-x:after { + content: "\000D7"; + font-size: 200%; + top: 6%; +} + + +/* Buttons (styled
    "},postRender:function(){var e=this,t;return e.items().exec("postRender"),e._super(),e._layout.postRender(e),e.state.set("rendered",!0),e.settings.style&&e.$el.css(e.settings.style),e.settings.border&&(t=e.borderBox,e.$el.css({"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left})),e.parent()||(e.keyboardNav=new i({root:e})),e},initLayoutRect:function(){var e=this,t=e._super();return e._layout.recalc(e),t},recalc:function(){var e=this,t=e._layoutRect,n=e._lastRect;if(!n||n.w!=t.w||n.h!=t.h)return e._layout.recalc(e),t=e.layoutRect(),e._lastRect={x:t.x,y:t.y,w:t.w,h:t.h},!0},reflow:function(){var t;if(l.remove(this),this.visible()){for(e.repaintControls=[],e.repaintControls.map={},this.recalc(),t=e.repaintControls.length;t--;)e.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),e.repaintControls=[]}return this}})}),r(_e,[g],function(e){function t(e){var t,n,r,i,o,a,s,l,u=Math.max;return t=e.documentElement,n=e.body,r=u(t.scrollWidth,n.scrollWidth),i=u(t.clientWidth,n.clientWidth),o=u(t.offsetWidth,n.offsetWidth),a=u(t.scrollHeight,n.scrollHeight),s=u(t.clientHeight,n.clientHeight),l=u(t.offsetHeight,n.offsetHeight),{width:r
    ").css({position:"absolute",top:0,left:0,width:u.width,height:u.height,zIndex:2147483647,opacity:1e-4,cursor:m}).appendTo(s.body),e(s).on("mousemove touchmove",d).on("mouseup touchend",c),i.start(r)},d=function(e){return n(e),e.button!==l?c(e):(e.deltaX=e.screenX-f,e.deltaY=e.screenY-p,e.preventDefault(),void i.drag(e))},c=function(t){n(t),e(s).off("mousemove touchmove",d).off("mouseup touchend",c),a.remove(),i.stop&&i.stop(t)},this.destroy=function(){e(o()).off()},e(o()).on("mousedown touchstart",u)}}),r(Se,[g,_e],function(e,t){return{init:function(){var e=this;e.on("repaint",e.renderScroll)},renderScroll:function(){function n(){function t(t,a,s,l,u,c){var d,f,p,h,m,g,v,y,b;if(f=i.getEl("scroll"+t)){if(y=a.toLowerCase(),b=s.toLowerCase(),e(i.getEl("absend")).css(y,i.layoutRect()[l]-1),!u)return void e(f).css("display","none");e(f).css("display","block"),d=i.getEl("body"),p=i.getEl("scroll"+t+"t"),h=d["client"+s]-2*o,h-=n&&r?f["client"+c]:0,m=d["scroll"+s],g=h/m,v={},v[y]=d["offset"+a]+o,v[b]=h,e(f).css(v),v={},v[y]=d["scroll"+a]*g,v[b]=h*g,e(p).css(v)}}var n,r,a;a=i.getEl("body"),n=a.scrollWidth>a.clientWidth,r=a.scrollHeight>a.clientHeight,t("h","Left","Width","contentW",n,"Height"),t("v","Top","Height","contentH",r,"Width")}function r(){function n(n,r,a,s,l){var u,c=i._id+"-scroll"+n,d=i.classPrefix;e(i.getEl()).append('
    '),i.draghelper=new t(c+"t",{start:function(){u=i.getEl("body")["scroll"+r],e("#"+c).addClass(d+"active")},drag:function(e){var t,c,d,f,p=i.layoutRect();c=p.contentW>p.innerW,d=p.contentH>p.innerH,f=i.getEl("body")["client"+a]-2*o,f-=c&&d?i.getEl("scroll"+n)["client"+l]:0,t=f/i.getEl("body")["scroll"+a],i.getEl("body")["scroll"+r]=u+e["delta"+s]/t},stop:function(){e("#"+c).removeClass(d+"active")}})}i.classes.add("scroll"),n("v","Top","Height","Y","Width"),n("h","Left","Width","X","Height")}var i=this,o=2;i.settings.autoScroll&&(i._hasScroll||(i._hasScroll=!0,r(),i.on("wheel",function(e){var t=i.getEl("body");t.scrollLeft+=10*(e.deltaX||0),t.scrollTop+=10*e.deltaY,n()}),e(i.getEl("body")).on("scroll",n)),n())}}}),r(ke,[Ne,Se],function(e,t){return e.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[t],renderHtml:function(){var e=this,t=e._layout,n=e.settings.html;return e.preRender(),t.preRender(e),"undefined"==typeof n?n='
    '+t.renderHtml(e)+"
    ":("function"==typeof n&&(n=n.call(e)),e._hasBody=!1),'
    '+(e._preBodyHtml||"")+n+"
    "}})}),r(Te,[ve],function(e){function t(t,n,r){var i,o,a,s,l,u,c,d,f,p;return f=e.getViewPort(),o=e.getPos(n),a=o.x,s=o.y,t.state.get("fixed")&&"static"==e.getRuntimeStyle(document.body,"position")&&(a-=f.x,s-=f.y),i=t.getEl(),p=e.getSize(i),l=p.width,u=p.height,p=e.getSize(n),c=p.width,d=p.height,r=(r||"").split(""),"b"===r[0]&&(s+=d),"r"===r[1]&&(a+=c),"c"===r[0]&&(s+=Math.round(d/2)),"c"===r[1]&&(a+=Math.round(c/2)),"b"===r[3]&&(s-=u),"r"===r[4]&&(a-=l),"c"===r[3]&&(s-=Math.round(u/2)),"c"===r[4]&&(a-=Math.round(l/2)),{x:a,y:s,w:l,h:u}}return{testMoveRel:function(n,r){for(var i=e.getViewPort(),o=0;o0&&a.x+a.w0&&a.y+a.hi.x&&a.x+a.wi.y&&a.y+a.ht?(e=t-n,e<0?0:e):e}var i=this;if(i.settings.constrainToViewport){var o=e.getViewPort(window),a=i.layoutRect();t=r(t,o.w+o.x,a.w),n=r(n,o.h+o.y,a.h)}return i.state.get("rendered")?i.layoutRect({x:t,y:n}).repaint():(i.settings.x=t,i.settings.y=n),i.fire("move",{x:t,y:n}),i}}}),r(Re,[ve],function(e){return{resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(t,n){if(t<=1||n<=1){var r=e.getWindowSize();t=t<=1?t*r.w:t,n=n<=1?n*r.h:n}return this._layoutRect.autoResize=!1,this.layoutRect({minW:t,minH:n,w:t,h:n}).reflow()},resizeBy:function(e,t){var n=this,r=n.layoutRect();return n.resizeTo(r.w+e,r.h+t)}}}),r(Ae,[ke,Te,Re,ve,g,c],function(e,t,n,r,i,o){function a(e,t){for(;e;){if(e==t)return!0;e=e.parent()}}function s(e){for(var t=v.length;t--;){var n=v[t],r=n.getParentCtrl(e.target);if(n.settings.autohide){if(r&&(a(r,n)||n.parent()===r))continue;e=n.fire("autohide",{target:e.target}),e.isDefaultPrevented()||n.hide()}}}function l(){h||(h=function(e){2!=e.button&&s(e)},i(document).on("click touchstart",h))}function u(){m||(m=function(){var e;for(e=v.length;e--;)d(v[e])},i(window).on("scroll",m))}function c(){if(!g){var e=document.documentElement,t=e.clientWidth,n=e.clientHeight;g=function(){document.all&&t==e.clientWidth&&n==e.clientHeight||(t=e.clientWidth,n=e.clientHeight,C.hideAll())},i(window).on("resize",g)}}function d(e){function t(t,n){for(var r,i=0;in&&(e.fixed(!1).layoutRect({y:e._autoFixY}).repaint(),t(!1,e._autoFixY-n)):(e._autoFixY=e.layoutRect().y,e._autoFixY').appendTo(t.getContainerElm())),o.setTimeout(function(){n.addClass(r+"in"),i(t.getEl()).addClass(r+"in")}),b=!0),f(!0,t)}}),t.on("show",function(){t.parents().each(function(e){if(e.state.get("fixed"))return t.fixed(!0),!1})}),e.popover&&(t._preBodyHtml='
    ',t.classes.add("popover").add("bottom").add(t.isRtl()?"end":"start")),t.aria("label",e.ariaLabel),t.aria("labelledby",t._id),t.aria("describedby",t.describedBy||t._id+"-none")},fixed:function(e){var t=this;if(t.state.get("fixed")!=e){if(t.state.get("rendered")){var n=r.getViewPort();e?t.layoutRect().y-=n.y:t.layoutRect().y+=n.y}t.classes.toggle("fixed",e),t.state.set("fixed",e)}return t},show:function(){var e=this,t,n=e._super();for(t=v.length;t--&&v[t]!==e;);return t===-1&&v.push(e),n},hide:function(){return p(this),f(!1,this),this._super()},hideAll:function(){C.hideAll()},close:function(){var e=this;return e.fire("close").isDefaultPrevented()||(e.remove(),f(!1,e)),e},remove:function(){p(this),this._super()},postRender:function(){var e=this;return e.settings.bodyRole&&this.getEl("body").setAttribute("role",e.settings.bodyRole),e._super()}});return C.hideAll=function(){for(var e=v.length;e--;){var t=v[e];t&&t.settings.autohide&&(t.hide(),v.splice(e,1))}},C}),r(Be,[Ae,ke,ve,g,_e,ye,d,c],function(e,t,n,r,i,o,a,s){function l(e){var t="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0",n=r("meta[name=viewport]")[0],i;a.overrideViewPort!==!1&&(n||(n=document.createElement("meta"),n.setAttribute("name","viewport"),document.getElementsByTagName("head")[0].appendChild(n)),i=n.getAttribute("content"),i&&"undefined"!=typeof p&&(p=i),n.setAttribute("content",e?t:p))}function u(e,t){c()&&t===!1&&r([document.documentElement,document.body]).removeClass(e+"fullscreen")}function c(){for(var e=0;er.w&&(o=r.x-Math.max(0,i/2),e.layoutRect({w:i,x:o}),a=!0)),t&&(t.layoutRect({w:e.layoutRect().innerW}).recalc(),i=t.layoutRect().minW+r.deltaW,i>r.w&&(o=r.x-Math.max(0,i-r.w),e.layoutRect({w:i,x:o}),a=!0)),a&&e.recalc()},initLayoutRect:function(){var e=this,t=e._super(),r=0,i;if(e.settings.title&&!e._fullscreen){i=e.getEl("head");var o=n.getSize(i);t.headerW=o.width,t.headerH=o.height,r+=t.headerH}e.statusbar&&(r+=e.statusbar.layoutRect().h),t.deltaH+=r,t.minH+=r,t.h+=r;var a=n.getWindowSize();return t.x=e.settings.x||Math.max(0,a.w/2-t.w/2),t.y=e.settings.y||Math.max(0,a.h/2-t.h/2),t},renderHtml:function(){var e=this,t=e._layout,n=e._id,r=e.classPrefix,i=e.settings,o="",a="",s=i.html;return e.preRender(),t.preRender(e),i.title&&(o='
    '+e.encode(i.title)+'
    '),i.url&&(s=''),"undefined"==typeof s&&(s=t.renderHtml(e)),e.statusbar&&(a=e.statusbar.renderHtml()),'
    '+o+'
    '+s+"
    "+a+"
    "},fullscreen:function(e){var t=this,i=document.documentElement,a,l=t.classPrefix,u;if(e!=t._fullscreen)if(r(window).on("resize",function(){var e;if(t._fullscreen)if(a)t._timer||(t._timer=s.setTimeout(function(){var e=n.getWindowSize();t.moveTo(0,0).resizeTo(e.w,e.h),t._timer=0},50));else{e=(new Date).getTime();var r=n.getWindowSize();t.moveTo(0,0).resizeTo(r.w,r.h),(new Date).getTime()-e>50&&(a=!0)}}),u=t.layoutRect(),t._fullscreen=e,e){t._initial={x:u.x,y:u.y,w:u.w,h:u.h},t.borderBox=o.parseBox("0"),t.getEl("head").style.display="none",u.deltaH-=u.headerH+2,r([i,document.body]).addClass(l+"fullscreen"),t.classes.add("fullscreen");var c=n.getWindowSize();t.moveTo(0,0).resizeTo(c.w,c.h)}else t.borderBox=o.parseBox(t.settings.border),t.getEl("head").style.display="",u.deltaH+=u.headerH,r([i,document.body]).removeClass(l+"fullscreen"),t.classes.remove("fullscreen"),t.moveTo(t._initial.x,t._initial.y).resizeTo(t._initial.w,t._initial.h);return t.reflow()},postRender:function(){var e=this,t;setTimeout(function(){e.classes.add("in"),e.fire("open")},0),e._super(),e.statusbar&&e.statusbar.postRender(),e.focus(),this.dragHelper=new i(e._id+"-dragh",{start:function(){t={x:e.layoutRect().x,y:e.layoutRect().y}},drag:function(n){e.moveTo(t.x+n.deltaX,t.y+n.deltaY)}}),e.on("submit",function(t){t.isDefaultPrevented()||e.close()}),f.push(e),l(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var e=this,t;for(e.dragHelper.destroy(),e._super(),e.statusbar&&this.statusbar.remove(),u(e.classPrefix,!1),t=f.length;t--;)f[t]===e&&f.splice(t,1);l(f.length>0)},getContentWindow:function(){var e=this.getEl().getElementsByTagName("iframe")[0];return e?e.contentWindow:null}});return d(),h}),r(De,[Be],function(e){var t=e.extend({init:function(e){e={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}},this._super(e)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(n){function r(e,t,n){return{type:"button",text:e,subtype:n?"primary":"",onClick:function(e){e.control.parents()[1].close(),o(t)}}}var i,o=n.callback||function(){};switch(n.buttons){ +case t.OK_CANCEL:i=[r("Ok",!0,!0),r("Cancel",!1)];break;case t.YES_NO:case t.YES_NO_CANCEL:i=[r("Yes",1,!0),r("No",0)],n.buttons==t.YES_NO_CANCEL&&i.push(r("Cancel",-1));break;default:i=[r("Ok",!0,!0)]}return new e({padding:20,x:n.x,y:n.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:i,title:n.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:n.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:n.onClose,onCancel:function(){o(!1)}}).renderTo(document.body).reflow()},alert:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,t.msgBox(e)},confirm:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,e.buttons=t.OK_CANCEL,t.msgBox(e)}}});return t}),r(Le,[Be,De],function(e,t){return function(n){function r(){if(s.length)return s[s.length-1]}function i(e){n.fire("OpenWindow",{win:e})}function o(e){n.fire("CloseWindow",{win:e})}var a=this,s=[];a.windows=s,n.on("remove",function(){for(var e=s.length;e--;)s[e].close()}),a.open=function(t,r){var a;return n.editorManager.setActive(n),t.title=t.title||" ",t.url=t.url||t.file,t.url&&(t.width=parseInt(t.width||320,10),t.height=parseInt(t.height||240,10)),t.body&&(t.items={defaults:t.defaults,type:t.bodyType||"form",items:t.body,data:t.data,callbacks:t.commands}),t.url||t.buttons||(t.buttons=[{text:"Ok",subtype:"primary",onclick:function(){a.find("form")[0].submit()}},{text:"Cancel",onclick:function(){a.close()}}]),a=new e(t),s.push(a),a.on("close",function(){for(var e=s.length;e--;)s[e]===a&&s.splice(e,1);s.length||n.focus(),o(a)}),t.data&&a.on("postRender",function(){this.find("*").each(function(e){var n=e.name();n in t.data&&e.value(t.data[n])})}),a.features=t||{},a.params=r||{},1===s.length&&n.nodeChanged(),a=a.renderTo().reflow(),i(a),a},a.alert=function(e,r,a){var s;s=t.alert(e,function(){r?r.call(a||this):n.focus()}),s.on("close",function(){o(s)}),i(s)},a.confirm=function(e,n,r){var a;a=t.confirm(e,function(e){n.call(r||this,e)}),a.on("close",function(){o(a)}),i(a)},a.close=function(){r()&&r().close()},a.getParams=function(){return r()?r().params:null},a.setParams=function(e){r()&&(r().params=e)},a.getWindows=function(){return s}}}),r(Me,[xe,Te],function(e,t){return e.extend({Mixins:[t],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var e=this,t=e.classPrefix;return'"},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl().lastChild.innerHTML=e.encode(t.value)}),e._super()},repaint:function(){var e=this,t,n;t=e.getEl().style,n=e._layoutRect,t.left=n.x+"px",t.top=n.y+"px",t.zIndex=131070}})}),r(Pe,[xe,Me],function(e,t){var n,r=e.extend({init:function(e){var t=this;t._super(e),e=t.settings,t.canFocus=!0,e.tooltip&&r.tooltips!==!1&&(t.on("mouseenter",function(n){var r=t.tooltip().moveTo(-65535);if(n.control==t){var i=r.text(e.tooltip).show().testMoveRel(t.getEl(),["bc-tc","bc-tl","bc-tr"]);r.classes.toggle("tooltip-n","bc-tc"==i),r.classes.toggle("tooltip-nw","bc-tl"==i),r.classes.toggle("tooltip-ne","bc-tr"==i),r.moveRel(t.getEl(),i)}else r.hide()}),t.on("mouseleave mousedown click",function(){t.tooltip().hide()})),t.aria("label",e.ariaLabel||e.tooltip)},tooltip:function(){return n||(n=new t({type:"tooltip"}),n.renderTo()),n},postRender:function(){var e=this,t=e.settings;e._super(),e.parent()||!t.width&&!t.height||(e.initLayoutRect(),e.repaint()),t.autofocus&&e.focus()},bindStates:function(){function e(e){n.aria("disabled",e),n.classes.toggle("disabled",e)}function t(e){n.aria("pressed",e),n.classes.toggle("active",e)}var n=this;return n.state.on("change:disabled",function(t){e(t.value)}),n.state.on("change:active",function(e){t(e.value)}),n.state.get("disabled")&&e(!0),n.state.get("active")&&t(!0),n._super()},remove:function(){this._super(),n&&(n.remove(),n=null)}});return r}),r(Oe,[Pe],function(e){return e.extend({Defaults:{value:0},init:function(e){var t=this;t._super(e),t.classes.add("progress"),t.settings.filter||(t.settings.filter=function(e){return Math.round(e)})},renderHtml:function(){var e=this,t=e._id,n=this.classPrefix;return'
    0%
    '},postRender:function(){var e=this;return e._super(),e.value(e.settings.value),e},bindStates:function(){function e(e){e=t.settings.filter(e),t.getEl().lastChild.innerHTML=e+"%",t.getEl().firstChild.firstChild.style.width=e+"%"}var t=this;return t.state.on("change:value",function(t){e(t.value)}),e(t.state.get("value")),t._super()}})}),r(He,[xe,Te,Oe,c],function(e,t,n,r){return e.extend({Mixins:[t],Defaults:{classes:"widget notification"},init:function(e){var t=this;t._super(e),e.text&&t.text(e.text),e.icon&&(t.icon=e.icon),e.color&&(t.color=e.color),e.type&&t.classes.add("notification-"+e.type),e.timeout&&(e.timeout<0||e.timeout>0)&&!e.closeButton?t.closeButton=!1:(t.classes.add("has-close"),t.closeButton=!0),e.progressBar&&(t.progressBar=new n),t.on("click",function(e){e.target.className.indexOf(t.classPrefix+"close")!=-1&&t.close()})},renderHtml:function(){var e=this,t=e.classPrefix,n="",r="",i="",o="";return e.icon&&(n=''),e.color&&(o=' style="background-color: '+e.color+'"'),e.closeButton&&(r=''),e.progressBar&&(i=e.progressBar.renderHtml()),'"},postRender:function(){var e=this;return r.setTimeout(function(){e.$el.addClass(e.classPrefix+"in")}),e._super()},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl().childNodes[1].innerHTML=t.value}),e.progressBar&&e.progressBar.bindStates(),e._super()},close:function(){var e=this;return e.fire("close").isDefaultPrevented()||e.remove(),e},repaint:function(){var e=this,t,n;t=e.getEl().style,n=e._layoutRect,t.left=n.x+"px",t.top=n.y+"px",t.zIndex=65534}})}),r(Ie,[He,c,m],function(e,t,n){return function(r){function i(){if(f.length)return f[f.length-1]}function o(){t.requestAnimationFrame(function(){a(),s()})}function a(){for(var e=0;e0){var e=f.slice(0,1)[0],t=r.inline?r.getElement():r.getContentAreaContainer();if(e.moveRel(t,"tc-tc"),f.length>1)for(var n=1;n0&&(n.timer=setTimeout(function(){n.close()},t.timeout)),n.on("close",function(){var e=f.length;for(n.timer&&r.getWin().clearTimeout(n.timer);e--;)f[e]===n&&f.splice(e,1);s()}),n.renderTo(),s()):n=i,n}},d.close=function(){i()&&i().close()},d.getNotifications=function(){return f},r.on("SkinLoaded",function(){var e=r.settings.service_message;e&&r.notificationManager.open({text:e,type:"warning",timeout:0,icon:""})})}}),r(Fe,[w],function(e){function t(t,n,r){for(var i=[];n&&n!=t;n=n.parentNode)i.push(e.nodeIndex(n,r));return i}function n(e,t){var n,r,i;for(r=e,n=t.length-1;n>=0;n--){if(i=r.childNodes,t[n]>i.length-1)return null;r=i[t[n]]}return r}return{create:t,resolve:n}}),r(ze,[I,T,y,Fe,A,C,d,m,c,k,$,oe],function(e,t,n,r,i,o,a,s,l,u,c,d){return function(f){function p(e,t){try{f.getDoc().execCommand(e,!1,t)}catch(n){}}function h(){var e=f.getDoc().documentMode;return e?e:6}function m(e){return e.isDefaultPrevented()}function g(e){var t,n;e.dataTransfer&&(f.selection.isCollapsed()&&"IMG"==e.target.tagName&&re.select(e.target),t=f.selection.getContent(),t.length>0&&(n=ce+escape(f.id)+","+escape(t),e.dataTransfer.setData(de,n)))}function v(e){var t;return e.dataTransfer&&(t=e.dataTransfer.getData(de),t&&t.indexOf(ce)>=0)?(t=t.substr(ce.length).split(","),{id:unescape(t[0]),html:unescape(t[1])}):null}function y(e){f.queryCommandSupported("mceInsertClipboardContent")?f.execCommand("mceInsertClipboardContent",!1,{content:e}):f.execCommand("mceInsertContent",!1,e)}function b(){function i(e){var t=x.schema.getBlockElements(),n=f.getBody();if("BR"!=e.nodeName)return!1;for(;e!=n&&!t[e.nodeName];e=e.parentNode)if(e.nextSibling)return!1;return!0}function o(e,t){var n;for(n=e.nextSibling;n&&n!=t;n=n.nextSibling)if((3!=n.nodeType||0!==Z.trim(n.data).length)&&n!==t)return!1;return n===t}function a(e,t,r){var o,a,s;if(x.isChildOf(e,f.getBody()))for(s=x.schema.getNonEmptyElements(),o=new n(r||e,e);a=o[t?"next":"prev"]();){if(s[a.nodeName]&&!i(a))return a;if(3==a.nodeType&&a.data.length>0)return a}}function u(e){var n,r,i,o,s;if(!e.collapsed&&(n=x.getParent(t.getNode(e.startContainer,e.startOffset),x.isBlock),r=x.getParent(t.getNode(e.endContainer,e.endOffset),x.isBlock),s=f.schema.getTextBlockElements(),n!=r&&s[n.nodeName]&&s[r.nodeName]&&"false"!==x.getContentEditable(n)&&"false"!==x.getContentEditable(r)))return e.deleteContents(),i=a(n,!1),o=a(r,!0),x.isEmpty(r)||Z(n).append(r.childNodes),Z(r).remove(),i?1==i.nodeType?"BR"==i.nodeName?(e.setStartBefore(i),e.setEndBefore(i)):(e.setStartAfter(i),e.setEndAfter(i)):(e.setStart(i,i.data.length),e.setEnd(i,i.data.length)):o&&(1==o.nodeType?(e.setStartBefore(o),e.setEndBefore(o)):(e.setStart(o,0),e.setEnd(o,0))),w.setRng(e),!0}function c(e,n){var r,i,s,l,u,c;if(!e.collapsed)return e;if(u=e.startContainer,c=e.startOffset,3==u.nodeType)if(n){if(c0)return e;r=t.getNode(u,c),s=x.getParent(r,x.isBlock),i=a(f.getBody(),n,r),l=x.getParent(i,x.isBlock);var d=1===u.nodeType&&c>u.childNodes.length-1;if(!r||!i)return e;if(l&&s!=l)if(n){if(!o(s,l))return e;1==r.nodeType?"BR"==r.nodeName?e.setStartBefore(r):e.setStartAfter(r):e.setStart(r,r.data.length),1==i.nodeType?e.setEnd(i,0):e.setEndBefore(i)}else{if(!o(l,s))return e;1==i.nodeType?"BR"==i.nodeName?e.setStartBefore(i):e.setStartAfter(i):e.setStart(i,i.data.length),1==r.nodeType&&d?e.setEndAfter(r):e.setEndBefore(r)}return e}function d(e){var t=w.getRng();if(t=c(t,e),u(t))return!0}function p(e,t){function n(e,n){return m=Z(n).parents().filter(function(e,t){return!!f.schema.getTextInlineElements()[t.nodeName]}),l=e.cloneNode(!1),m=s.map(m,function(e){return e=e.cloneNode(!1),l.hasChildNodes()?(e.appendChild(l.firstChild),l.appendChild(e)):l.appendChild(e),l.appendChild(e),e}),m.length?(h=x.create("br"),m[0].appendChild(h),x.replace(l,e),t.setStartBefore(h),t.setEndBefore(h),f.selection.setRng(t),h):null}function i(e){return e&&f.schema.getTextBlockElements()[e.tagName]}var o,a,l,u,c,d,p,h,m;if(t.collapsed&&(d=t.startContainer,p=t.startOffset,a=x.getParent(d,x.isBlock),i(a)))if(1==d.nodeType){if(d=d.childNodes[p],d&&"BR"!=d.tagName)return;if(c=e?a.nextSibling:a.previousSibling,x.isEmpty(a)&&i(c)&&x.isEmpty(c)&&n(a,d))return x.remove(c),!0}else if(3==d.nodeType){if(o=r.create(a,d),u=a.cloneNode(!0),d=r.resolve(u,o),e){if(p>=d.data.length)return;d.deleteData(p,1)}else{if(p<=0)return;d.deleteData(p-1,1)}if(x.isEmpty(u))return n(a,d)}}function h(e){var t,n,r;d(e)||(s.each(f.getBody().getElementsByTagName("*"),function(e){"SPAN"==e.tagName&&e.setAttribute("mce-data-marked",1),!e.hasAttribute("data-mce-style")&&e.hasAttribute("style")&&f.dom.setAttrib(e,"style",f.dom.getAttrib(e,"style"))}),t=new E(function(){}),t.observe(f.getDoc(),{childList:!0,attributes:!0,subtree:!0,attributeFilter:["style"]}),f.getDoc().execCommand(e?"ForwardDelete":"Delete",!1,null),n=f.selection.getRng(),r=n.startContainer.parentNode,s.each(t.takeRecords(),function(e){if(x.isChildOf(e.target,f.getBody())){if("style"==e.attributeName){var t=e.target.getAttribute("data-mce-style");t?e.target.setAttribute("style",t):e.target.removeAttribute("style")}s.each(e.addedNodes,function(e){if("SPAN"==e.nodeName&&!e.getAttribute("mce-data-marked")){var t,i;e==r&&(t=n.startOffset,i=e.firstChild),x.remove(e,!0),i&&(n.setStart(i,t),n.setEnd(i,t),f.selection.setRng(n))}})}}),t.disconnect(),s.each(f.dom.select("span[mce-data-marked]"),function(e){e.removeAttribute("mce-data-marked")}))}function b(e){f.undoManager.transact(function(){h(e)})}var C=f.getDoc(),x=f.dom,w=f.selection,E=window.MutationObserver,N,_;E||(N=!0,E=function(){function e(e){var t=e.relatedNode||e.target;n.push({target:t,addedNodes:[t]})}function t(e){var t=e.relatedNode||e.target;n.push({target:t,attributeName:e.attrName})}var n=[],r;this.observe=function(n){r=n,r.addEventListener("DOMSubtreeModified",e,!1),r.addEventListener("DOMNodeInsertedIntoDocument",e,!1),r.addEventListener("DOMNodeInserted",e,!1),r.addEventListener("DOMAttrModified",t,!1)},this.disconnect=function(){r.removeEventListener("DOMSubtreeModified",e,!1),r.removeEventListener("DOMNodeInsertedIntoDocument",e,!1),r.removeEventListener("DOMNodeInserted",e,!1),r.removeEventListener("DOMAttrModified",t,!1)},this.takeRecords=function(){return n}}),f.on("keydown",function(e){var t=e.keyCode==te,n=e.ctrlKey||e.metaKey;if(!m(e)&&(t||e.keyCode==ee)){var r=f.selection.getRng(),i=r.startContainer,o=r.startOffset;if(t&&e.shiftKey)return;if(p(t,r))return void e.preventDefault();if(!n&&r.collapsed&&3==i.nodeType&&(t?o0))return;e.preventDefault(),n&&f.selection.getSel().modify("extend",t?"forward":"backward",e.metaKey?"lineboundary":"word"),h(t)}}),f.on("keypress",function(t){if(!m(t)&&!w.isCollapsed()&&t.charCode>31&&!e.metaKeyPressed(t)){var n,r,i,o,a,s;n=f.selection.getRng(),s=String.fromCharCode(t.charCode),t.preventDefault(),r=Z(n.startContainer).parents().filter(function(e,t){return!!f.schema.getTextInlineElements()[t.nodeName]}),h(!0),r=r.filter(function(e,t){return!Z.contains(f.getBody(),t)}),r.length?(i=x.createFragment(),r.each(function(e,t){t=t.cloneNode(!1),i.hasChildNodes()?(t.appendChild(i.firstChild),i.appendChild(t)):(a=t,i.appendChild(t)),i.appendChild(t)}),a.appendChild(f.getDoc().createTextNode(s)),o=x.getParent(n.startContainer,x.isBlock),x.isEmpty(o)?Z(o).empty().append(i):n.insertNode(i),n.setStart(a.firstChild,1),n.setEnd(a.firstChild,1),f.selection.setRng(n)):f.selection.setContent(s)}}),f.addCommand("Delete",function(){h()}),f.addCommand("ForwardDelete",function(){h(!0)}),N||(f.on("dragstart",function(e){_=w.getRng(),g(e)}),f.on("drop",function(e){if(!m(e)){var n=v(e);n&&(e.preventDefault(),l.setEditorTimeout(f,function(){var r=t.getCaretRangeFromPoint(e.x,e.y,C);_&&(w.setRng(_),_=null,b()),w.setRng(r),y(n.html)}))}}),f.on("cut",function(e){m(e)||!e.clipboardData||f.selection.isCollapsed()||(e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/html",f.selection.getContent()),e.clipboardData.setData("text/plain",f.selection.getContent({format:"text"})),l.setEditorTimeout(f,function(){b(!0)}))}))}function C(){function e(e){var t=ne.create("body"),n=e.cloneContents();return t.appendChild(n),re.serializer.serialize(t,{format:"html"})}function n(n){if(!n.setStart){if(n.item)return!1;var r=n.duplicate();return r.moveToElementText(f.getBody()),t.compareRanges(n,r)}var i=e(n),o=ne.createRng();o.selectNode(f.getBody());var a=e(o);return i===a}f.on("keydown",function(e){var t=e.keyCode,r,i;if(!m(e)&&(t==te||t==ee)){if(r=f.selection.isCollapsed(),i=f.getBody(),r&&!ne.isEmpty(i))return;if(!r&&!n(f.selection.getRng()))return;e.preventDefault(),f.setContent(""),i.firstChild&&ne.isBlock(i.firstChild)?f.selection.setCursorLocation(i.firstChild,0):f.selection.setCursorLocation(i,0),f.nodeChanged()}})}function x(){f.shortcuts.add("meta+a",null,"SelectAll")}function w(){f.settings.content_editable||ne.bind(f.getDoc(),"mousedown mouseup",function(e){var t;if(e.target==f.getDoc().documentElement)if(t=re.getRng(),f.getBody().focus(),"mousedown"==e.type){if(u.isCaretContainer(t.startContainer))return;re.placeCaretAt(e.clientX,e.clientY)}else re.setRng(t)})}function E(){f.on("keydown",function(e){if(!m(e)&&e.keyCode===ee){if(!f.getBody().getElementsByTagName("hr").length)return;if(re.isCollapsed()&&0===re.getRng(!0).startOffset){var t=re.getNode(),n=t.previousSibling;if("HR"==t.nodeName)return ne.remove(t),void e.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(ne.remove(n),e.preventDefault())}}})}function N(){window.Range.prototype.getClientRects||f.on("mousedown",function(e){if(!m(e)&&"HTML"===e.target.nodeName){var t=f.getBody();t.blur(),l.setEditorTimeout(f,function(){t.focus()})}})}function _(){f.on("click",function(e){var t=e.target;/^(IMG|HR)$/.test(t.nodeName)&&"false"!==ne.getContentEditableParent(t)&&(e.preventDefault(),re.select(t),f.nodeChanged()),"A"==t.nodeName&&ne.hasClass(t,"mce-item-anchor")&&(e.preventDefault(),re.select(t))})}function S(){function e(){var e=ne.getAttribs(re.getStart().cloneNode(!1));return function(){var t=re.getStart();t!==f.getBody()&&(ne.setAttrib(t,"style",null),Q(e,function(e){t.setAttributeNode(e.cloneNode(!0))}))}}function t(){return!re.isCollapsed()&&ne.getParent(re.getStart(),ne.isBlock)!=ne.getParent(re.getEnd(),ne.isBlock)}f.on("keypress",function(n){var r;if(!m(n)&&(8==n.keyCode||46==n.keyCode)&&t())return r=e(),f.getDoc().execCommand("delete",!1,null),r(),n.preventDefault(),!1}),ne.bind(f.getDoc(),"cut",function(n){var r;!m(n)&&t()&&(r=e(),l.setEditorTimeout(f,function(){r()}))})}function k(){document.body.setAttribute("role","application")}function T(){f.on("keydown",function(e){if(!m(e)&&e.keyCode===ee&&re.isCollapsed()&&0===re.getRng(!0).startOffset){var t=re.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}})}function R(){h()>7||(p("RespectVisibilityInDesign",!0),f.contentStyles.push(".mceHideBrInPre pre br {display: none}"),ne.addClass(f.getBody(),"mceHideBrInPre"),oe.addNodeFilter("pre",function(e){for(var t=e.length,n,r,o,a;t--;)for(n=e[t].getAll("br"),r=n.length;r--;)o=n[r],a=o.prev,a&&3===a.type&&"\n"!=a.value.charAt(a.value-1)?a.value+="\n":o.parent.insert(new i("#text",3),o,!0).value="\n"}),ae.addNodeFilter("pre",function(e){for(var t=e.length,n,r,i,o;t--;)for(n=e[t].getAll("br"),r=n.length;r--;)i=n[r],o=i.prev,o&&3==o.type&&(o.value=o.value.replace(/\r?\n$/,""))}))}function A(){ne.bind(f.getBody(),"mouseup",function(){var e,t=re.getNode();"IMG"==t.nodeName&&((e=ne.getStyle(t,"width"))&&(ne.setAttrib(t,"width",e.replace(/[^0-9%]+/g,"")),ne.setStyle(t,"width","")),(e=ne.getStyle(t,"height"))&&(ne.setAttrib(t,"height",e.replace(/[^0-9%]+/g,"")),ne.setStyle(t,"height","")))})}function B(){f.on("keydown",function(t){var n,r,i,o,a;if(!m(t)&&t.keyCode==e.BACKSPACE&&(n=re.getRng(),r=n.startContainer,i=n.startOffset,o=ne.getRoot(),a=r,n.collapsed&&0===i)){for(;a&&a.parentNode&&a.parentNode.firstChild==a&&a.parentNode!=o;)a=a.parentNode;"BLOCKQUOTE"===a.tagName&&(f.formatter.toggle("blockquote",null,a),n=ne.createRng(),n.setStart(r,0),n.setEnd(r,0),re.setRng(n))}})}function D(){function e(){K(),p("StyleWithCSS",!1),p("enableInlineTableEditing",!1),ie.object_resizing||p("enableObjectResizing",!1)}ie.readonly||f.on("BeforeExecCommand MouseDown",e)}function L(){function e(){Q(ne.select("a"),function(e){var t=e.parentNode,n=ne.getRoot();if(t.lastChild===e){for(;t&&!ne.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}ne.add(t,"br",{"data-mce-bogus":1})}})}f.on("SetContent ExecCommand",function(t){"setcontent"!=t.type&&"mceInsertLink"!==t.command||e()})}function M(){ie.forced_root_block&&f.on("init",function(){p("DefaultParagraphSeparator",ie.forced_root_block)})}function P(){f.on("keydown",function(e){var t;m(e)||e.keyCode!=ee||(t=f.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),f.undoManager.beforeChange(),ne.remove(t.item(0)),f.undoManager.add()))})}function O(){var e;h()>=10&&(e="",Q("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),f.contentStyles.push(e+"{padding-right: 1px !important}"))}function H(){h()<9&&(oe.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),ae.addNodeFilter("noscript",function(e){for(var t=e.length,n,r,a;t--;)n=e[t],r=e[t].firstChild,r?r.value=o.decode(r.value):(a=n.attributes.map["data-mce-innertext"],a&&(n.attr("data-mce-innertext",null),r=new i("#text",3),r.value=a,r.raw=!0,n.append(r)))}))}function I(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),ne.unbind(r,"mouseup",n),ne.unbind(r,"mousemove",t),a=o=0}var r=ne.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,ne.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(ne.bind(r,"mouseup",n),ne.bind(r,"mousemove",t),ne.getRoot().focus(),a.select())}})}function F(){f.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||re.normalize()},!0)}function z(){f.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function U(){f.inline||f.on("keydown",function(){document.activeElement==document.body&&f.getWin().focus()})}function W(){f.inline||(f.contentStyles.push("body {min-height: 150px}"),f.on("click",function(e){var t;if("HTML"==e.target.nodeName){if(a.ie>11)return void f.getBody().focus();t=f.selection.getRng(),f.getBody().focus(),f.selection.setRng(t),f.selection.normalize(),f.nodeChanged()}}))}function V(){a.mac&&f.on("keydown",function(t){!e.metaKeyPressed(t)||t.shiftKey||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),f.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","lineboundary"))})}function $(){p("AutoUrlDetect",!1)}function q(){f.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),f.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function j(){f.on("init",function(){f.dom.bind(f.getBody(),"submit",function(e){e.preventDefault()})})}function Y(){oe.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}function X(){f.on("dragstart",function(e){g(e)}),f.on("drop",function(e){if(!m(e)){var n=v(e);if(n&&n.id!=f.id){e.preventDefault();var r=t.getCaretRangeFromPoint(e.x,e.y,f.getDoc());re.setRng(r),y(n.html)}}})}function K(){}function G(){var e;return se?(e=f.selection.getSel(),!e||!e.rangeCount||0===e.rangeCount):0}function J(){function t(e){var t=new d(e.getBody()),n=e.selection.getRng(),r=c.fromRangeStart(n),i=c.fromRangeEnd(n),o=t.prev(r),a=t.next(i);return!e.selection.isCollapsed()&&(!o||o.isAtStart()&&r.isEqual(o))&&(!a||a.isAtEnd()&&r.isEqual(a))}f.on("keypress",function(n){!m(n)&&!re.isCollapsed()&&n.charCode>31&&!e.metaKeyPressed(n)&&t(f)&&(n.preventDefault(),f.setContent(String.fromCharCode(n.charCode)),f.selection.select(f.getBody(),!0),f.selection.collapse(!1),f.nodeChanged())}),f.on("keydown",function(e){var n=e.keyCode;m(e)||n!=te&&n!=ee||t(f)&&(e.preventDefault(),f.setContent(""),f.nodeChanged())})}var Q=s.each,Z=f.$,ee=e.BACKSPACE,te=e.DELETE,ne=f.dom,re=f.selection,ie=f.settings,oe=f.parser,ae=f.serializer,se=a.gecko,le=a.ie,ue=a.webkit,ce="data:text/mce-internal,",de=le?"Text":"URL";return B(),C(),a.windowsPhone||F(),ue&&(J(),b(),w(),_(),M(),j(),T(),Y(),a.iOS?(U(),W(),q()):x()),le&&a.ie<11&&(E(),k(),R(),A(),P(),O(),H(),I()),a.ie>=11&&(W(),T()),a.ie&&(x(),$(),X()),se&&(J(),E(),N(),S(),D(),L(),z(),V(),T()),{refreshContentEditable:K,isHidden:G}}}),r(Ue,[pe,w,m],function(e,t,n){function r(e,t){return"selectionchange"==t?e.getDoc():!e.inline&&/^mouse|touch|click|contextmenu|drop|dragover|dragend/.test(t)?e.getDoc().documentElement:e.settings.event_root?(e.eventRoot||(e.eventRoot=o.select(e.settings.event_root)[0]),e.eventRoot):e.getBody()}function i(e,t){function n(e){return!e.hidden&&!e.readonly}var i=r(e,t),s;if(e.delegates||(e.delegates={}),!e.delegates[t])if(e.settings.event_root){if(a||(a={},e.editorManager.on("removeEditor",function(){var t;if(!e.editorManager.activeEditor&&a){for(t in a)e.dom.unbind(r(e,t));a=null}})),a[t])return;s=function(r){for(var i=r.target,a=e.editorManager.editors,s=a.length;s--;){var l=a[s].getBody();(l===i||o.isChildOf(i,l))&&n(a[s])&&a[s].fire(t,r)}},a[t]=s,o.bind(i,t,s)}else s=function(r){n(e)&&e.fire(t,r)},o.bind(i,t,s),e.delegates[t]=s}var o=t.DOM,a,s={bindPendingEventDelegates:function(){var e=this;n.each(e._pendingNativeEvents,function(t){i(e,t)})},toggleNativeEvent:function(e,t){var n=this;"focus"!=e&&"blur"!=e&&(t?n.initialized?i(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&(n.dom.unbind(r(n,e),e,n.delegates[e]),delete n.delegates[e]))},unbindAllNativeEvents:function(){var e=this,t;if(e.delegates){for(t in e.delegates)e.dom.unbind(r(e,t),t,e.delegates[t]);delete e.delegates}e.inline||(e.getBody().onload=null,e.dom.unbind(e.getWin()),e.dom.unbind(e.getDoc())),e.dom.unbind(e.getBody()),e.dom.unbind(e.getContainer())}};return s=n.extend({},e,s)}),r(We,[],function(){function e(e,t,n){try{e.getDoc().execCommand(t,!1,n)}catch(r){}}function t(e){var t,n;return t=e.getBody(),n=function(t){e.dom.getParents(t.target,"a").length>0&&t.preventDefault()},e.dom.bind(t,"click",n),{unbind:function(){e.dom.unbind(t,"click",n)}}}function n(n,r){n._clickBlocker&&(n._clickBlocker.unbind(),n._clickBlocker=null),r?(n._clickBlocker=t(n),n.selection.controlSelection.hideResizeRect(),n.readonly=!0,n.getBody().contentEditable=!1):(n.readonly=!1,n.getBody().contentEditable=!0,e(n,"StyleWithCSS",!1),e(n,"enableInlineTableEditing",!1),e(n,"enableObjectResizing",!1),n.focus(),n.nodeChanged())}function r(e,t){var r=e.readonly?"readonly":"design";t!=r&&(e.initialized?n(e,"readonly"==t):e.on("init",function(){n(e,"readonly"==t)}),e.fire("SwitchMode",{mode:t}))}return{setMode:r}}),r(Ve,[m,d],function(e,t){var n=e.each,r=e.explode,i={f9:120,f10:121,f11:122},o=e.makeMap("alt,ctrl,shift,meta,access");return function(a){function s(e){var a,s,l={};n(r(e,"+"),function(e){e in o?l[e]=!0:/^[0-9]{2,}$/.test(e)?l.keyCode=parseInt(e,10):(l.charCode=e.charCodeAt(0),l.keyCode=i[e]||e.toUpperCase().charCodeAt(0))}),a=[l.keyCode];for(s in o)l[s]?a.push(s):l[s]=!1;return l.id=a.join(","),l.access&&(l.alt=!0,t.mac?l.ctrl=!0:l.shift=!0),l.meta&&(t.mac?l.meta=!0:(l.ctrl=!0,l.meta=!1)),l}function l(t,n,i,o){var l;return l=e.map(r(t,">"),s),l[l.length-1]=e.extend(l[l.length-1],{func:i,scope:o||a}),e.extend(l[0],{desc:a.translate(n),subpatterns:l.slice(1)})}function u(e){return e.altKey||e.ctrlKey||e.metaKey}function c(e){return"keydown"===e.type&&e.keyCode>=112&&e.keyCode<=123}function d(e,t){return!!t&&(t.ctrl==e.ctrlKey&&t.meta==e.metaKey&&(t.alt==e.altKey&&t.shift==e.shiftKey&&(!!(e.keyCode==t.keyCode||e.charCode&&e.charCode==t.charCode)&&(e.preventDefault(),!0))))}function f(e){return e.func?e.func.call(e.scope):null}var p=this,h={},m=[];a.on("keyup keypress keydown",function(e){!u(e)&&!c(e)||e.isDefaultPrevented()||(n(h,function(t){if(d(e,t))return m=t.subpatterns.slice(0),"keydown"==e.type&&f(t),!0}),d(e,m[0])&&(1===m.length&&"keydown"==e.type&&f(m[0]),m.shift()))}),p.add=function(t,i,o,s){var u;return u=o,"string"==typeof o?o=function(){a.execCommand(u,!1,null)}:e.isArray(u)&&(o=function(){a.execCommand(u[0],u[1],u[2])}),n(r(e.trim(t.toLowerCase())),function(e){var t=l(e,i,o,s);h[t.id]=t}),!0},p.remove=function(e){var t=l(e);return!!h[t.id]&&(delete h[t.id],!0)}}}),r($e,[u,m,z],function(e,t,n){return function(r,i){function o(e){var t,n;return n={"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png"},t=n[e.blob().type.toLowerCase()]||"dat",e.filename()+"."+t}function a(e,t){return e?e.replace(/\/$/,"")+"/"+t.replace(/^\//,""):t}function s(e){return{id:e.id,blob:e.blob,base64:e.base64,filename:n.constant(o(e))}}function l(e,t,n,r){var o,s;o=new XMLHttpRequest,o.open("POST",i.url),o.withCredentials=i.credentials,o.upload.onprogress=function(e){r(e.loaded/e.total*100)},o.onerror=function(){n("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var e;return 200!=o.status?void n("HTTP Error: "+o.status):(e=JSON.parse(o.responseText),e&&"string"==typeof e.location?void t(a(i.basePath,e.location)):void n("Invalid JSON: "+o.responseText))},s=new FormData,s.append("file",e.blob(),e.filename()),o.send(s)}function u(){return new e(function(e){e([])})}function c(e,t){return{url:t,blobInfo:e,status:!0}}function d(e,t){return{url:"",blobInfo:e,status:!1,error:t}}function f(e,n){t.each(y[e],function(e){e(n)}),delete y[e]}function p(t,n,i){return r.markPending(t.blobUri()),new e(function(e){var o,a,l=function(){};try{var u=function(){o&&(o.close(),a=l)},p=function(n){u(),r.markUploaded(t.blobUri(),n),f(t.blobUri(),c(t,n)),e(c(t,n))},h=function(n){u(),r.removeFailed(t.blobUri()),f(t.blobUri(),d(t,n)),e(d(t,n))};a=function(e){e<0||e>100||(o||(o=i()),o.progressBar.value(e))},n(s(t),p,h,a)}catch(m){e(d(t,m.message))}})}function h(e){return e===l}function m(t){var n=t.blobUri();return new e(function(e){y[n]=y[n]||[],y[n].push(e)})}function g(n,o){return n=t.grep(n,function(e){return!r.isUploaded(e.blobUri())}),e.all(t.map(n,function(e){return r.isPending(e.blobUri())?m(e):p(e,i.handler,o)}))}function v(e,t){return!i.url&&h(i.handler)?u():g(e,t)}var y={};return i=t.extend({credentials:!1,handler:l},i),{upload:v}}}),r(qe,[u],function(e){function t(t){return new e(function(e){var n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="blob",n.onload=function(){200==this.status&&e(this.response)},n.send()})}function n(e){var t,n;return e=decodeURIComponent(e).split(","),n=/data:([^;]+)/.exec(e[0]),n&&(t=n[1]),{type:t,data:e[1]}}function r(t){return new e(function(e){var r,i,o;t=n(t);try{r=atob(t.data)}catch(a){return void e(new Blob([]))}for(i=new Uint8Array(r.length),o=0;o0&&(n&&(l*=-1),r.left+=l,r.right+=l),r}function l(){var n,r,o,a,s;for(n=i("*[contentEditable=false]",t),a=0;a').css(l).appendTo(t),o&&m.addClass("mce-visual-caret-before"),d(),u=a.ownerDocument.createRange(),u.setStart(g,0),u.setEnd(g,0),u):(g=e.insertInline(a,o),u=a.ownerDocument.createRange(),s(g.nextSibling)?(u.setStart(g,0),u.setEnd(g,0)):(u.setStart(g,1),u.setEnd(g,1)),u)}function c(){l(),g&&(e.remove(g),g=null),m&&(m.remove(),m=null),clearInterval(h)}function d(){h=a.setInterval(function(){i("div.mce-visual-caret",t).toggleClass("mce-visual-caret-hidden")},500)}function f(){a.clearInterval(h)}function p(){return".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}"}var h,m,g;return{show:u,hide:c,getCss:p,destroy:f}}}),r(Qe,[h,_,W],function(e,t,n){function r(i){function o(t){return e.map(t,function(e){return e=n.clone(e),e.node=i,e})}if(e.isArray(i))return e.reduce(i,function(e,t){return e.concat(r(t))},[]);if(t.isElement(i))return o(i.getClientRects());if(t.isText(i)){var a=i.ownerDocument.createRange();return a.setStart(i,0),a.setEnd(i,i.data.length),o(a.getClientRects())}}return{getClientRects:r}}),r(Ze,[z,h,Qe,U,ie,oe,$,W],function(e,t,n,r,i,o,a,s){function l(e,t,n,o){for(;o=i.findNode(o,e,r.isEditableCaretCandidate,t);)if(n(o))return}function u(e,r,i,o,a,s){function u(o){var s,l,u;for(u=n.getClientRects(o),e==-1&&(u=u.reverse()),s=0;s0&&r(l,t.last(f))&&c++,l.line=c,a(l))return!0;f.push(l)}}var c=0,d,f=[],p;return(p=t.last(s.getClientRects()))?(d=s.getNode(),u(d),l(e,o,u,d),f):f}function c(e,t){return t.line>e}function d(e,t){return t.line===e}function f(e,n,r,i){function l(n){return 1==e?t.last(n.getClientRects()):t.last(n.getClientRects())}var u=new o(n),c,d,f,p,h=[],m=0,g,v;1==e?(c=u.next,d=s.isBelow,f=s.isAbove,p=a.after(i)):(c=u.prev,d=s.isAbove,f=s.isBelow,p=a.before(i)),v=l(p);do if(p.isVisible()&&(g=l(p),!f(g,v))){if(h.length>0&&d(g,t.last(h))&&m++,g=s.clone(g),g.position=p,g.line=m,r(g))return h;h.push(g)}while(p=c(p));return h}var p=e.curry,h=p(u,-1,s.isAbove,s.isBelow),m=p(u,1,s.isBelow,s.isAbove);return{upUntil:h,downUntil:m,positionsUntil:f,isAboveLine:p(c),isLine:p(d)}}),r(et,[z,h,_,Qe,W,ie,U],function(e,t,n,r,i,o,a){function s(e,t){return Math.abs(e.left-t)}function l(e,t){return Math.abs(e.right-t)}function u(e,n){function r(e,t){return e>=t.left&&e<=t.right}return t.reduce(e,function(e,t){var i,o;return i=Math.min(s(e,n),l(e,n)),o=Math.min(s(t,n),l(t,n)),r(n,t)?t:r(n,e)?e:o==i&&m(t.node)?t:o=e.top&&i<=e.bottom}),a=u(o,n),a&&(a=u(d(e,a),n),a&&m(a.node))?p(a,n):null}var m=n.isContentEditableFalse,g=o.findNode,v=e.curry;return{findClosestClientRect:u,findLineNodeRects:d,closestCaret:h}}),r(tt,[],function(){var e=function(e){var t,n,r,i;return i=e.getBoundingClientRect(),t=e.ownerDocument,n=t.documentElement,r=t.defaultView,{top:i.top+r.pageYOffset-n.clientTop,left:i.left+r.pageXOffset-n.clientLeft}},t=function(t){return t.inline?e(t.getBody()):{left:0,top:0}},n=function(e){var t=e.getBody();return e.inline?{left:t.scrollLeft,top:t.scrollTop}:{left:0,top:0}},r=function(e){var t=e.getBody(),n=e.getDoc().documentElement,r={left:t.scrollLeft,top:t.scrollTop},i={left:t.scrollLeft||n.scrollLeft,top:t.scrollTop||n.scrollTop};return e.inline?r:i},i=function(t,n){if(n.target.ownerDocument!==t.getDoc()){var i=e(t.getContentAreaContainer()),o=r(t);return{left:n.pageX-i.left+o.left,top:n.pageY-i.top+o.top}}return{left:n.pageX,top:n.pageY}},o=function(e,t,n){return{pageX:n.left-e.left+t.left,pageY:n.top-e.top+t.top}},a=function(e,r){return o(t(e),n(e),i(e,r))};return{calc:a}}),r(nt,[_,h,z,c,w,tt],function(e,t,n,r,i,o){var a=e.isContentEditableFalse,s=e.isContentEditableTrue,l=function(e,t){return a(t)&&t!==e},u=function(e,t,n){return t!==n&&!e.dom.isChildOf(t,n)&&!a(t)},c=function(e){var t=e.cloneNode(!0);return t.removeAttribute("data-mce-selected"),t},d=function(e,t,n,r){var i=t.cloneNode(!0);e.dom.setStyles(i,{width:n,height:r}),e.dom.setAttrib(i,"data-mce-selected",null);var o=e.dom.create("div",{"class":"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return e.dom.setStyles(o,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:n,height:r}),e.dom.setStyles(i,{margin:0,boxSizing:"border-box"}),o.appendChild(i),o},f=function(e,t){e.parentNode!==t&&t.appendChild(e)},p=function(e,t,n,r,i,o){var a=0,s=0;e.style.left=t.pageX+"px",e.style.top=t.pageY+"px",t.pageX+n>i&&(a=t.pageX+n-i),t.pageY+r>o&&(s=t.pageY+r-o),e.style.width=n-a+"px",e.style.height=r-s+"px"},h=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},m=function(e){return 0===e.button},g=function(e){return e.element},v=function(e,t){return{pageX:t.pageX-e.relX,pageY:t.pageY+5}},y=function(e,r){return function(i){if(m(i)){var o=t.find(r.dom.getParents(i.target),n.or(a,s));if(l(r.getBody(),o)){var u=r.dom.getPos(o),c=r.getBody(),f=r.getDoc().documentElement;e.element=o,e.screenX=i.screenX,e.screenY=i.screenY,e.maxX=(r.inline?c.scrollWidth:f.offsetWidth)-2,e.maxY=(r.inline?c.scrollHeight:f.offsetHeight)-2,e.relX=i.pageX-u.x,e.relY=i.pageY-u.y,e.width=o.offsetWidth,e.height=o.offsetHeight,e.ghost=d(r,o,e.width,e.height)}}}},b=function(e,t){var n=r.throttle(function(e,n){t._selectionOverrides.hideFakeCaret(),t.selection.placeCaretAt(e,n)},0);return function(r){var i=Math.max(Math.abs(r.screenX-e.screenX),Math.abs(r.screenY-e.screenY));if(g(e)&&!e.dragging&&i>10){var a=t.fire("dragstart",{target:e.element});if(a.isDefaultPrevented())return;e.dragging=!0,t.focus()}if(e.dragging){var s=v(e,o.calc(t,r));f(e.ghost,t.getBody()),p(e.ghost,s,e.width,e.height,e.maxX,e.maxY),n(r.clientX,r.clientY)}}},C=function(e){var t=e.getSel().getRangeAt(0),n=t.startContainer;return 3===n.nodeType?n.parentNode:n},x=function(e,t){return function(n){if(e.dragging&&u(t,C(t.selection),e.element)){var r=c(e.element),i=t.fire("drop",{targetClone:r,clientX:n.clientX,clientY:n.clientY});i.isDefaultPrevented()||(r=i.targetClone,t.undoManager.transact(function(){h(e.element),t.insertContent(t.dom.getOuterHTML(r)),t._selectionOverrides.hideFakeCaret()}))}E(e)}},w=function(e,t){return function(){E(e),e.dragging&&t.fire("dragend")}},E=function(e){e.dragging=!1,e.element=null,h(e.ghost)},N=function(e){var t={},n,r,o,a,s,l;n=i.DOM,l=document,r=y(t,e),o=b(t,e),a=x(t,e),s=w(t,e),e.on("mousedown",r),e.on("mousemove",o),e.on("mouseup",a),n.bind(l,"mousemove",o),n.bind(l,"mouseup",s),e.on("remove",function(){n.unbind(l,"mousemove",o),n.unbind(l,"mouseup",s)})},_=function(e){e.on("drop",function(t){var n="undefined"!=typeof t.clientX?e.getDoc().elementFromPoint(t.clientX,t.clientY):null;(a(n)||a(e.dom.getContentEditableParent(n)))&&t.preventDefault()})},S=function(e){N(e),_(e)};return{init:S}}),r(rt,[d,oe,$,k,ie,Je,Ze,et,_,T,W,I,z,h,c,nt],function(e,t,n,r,i,o,a,s,l,u,c,d,f,p,h,m){function g(e,t){for(;t=e(t);)if(t.isVisible())return t;return t}function v(u){function v(e){return u.dom.hasClass(e,"mce-offscreen-selection")}function _(){var e=u.dom.get(le);return e?e.getElementsByTagName("*")[0]:e}function S(e){return u.dom.isBlock(e)}function k(e){e&&u.selection.setRng(e)}function T(){return u.selection.getRng()}function R(e,t){u.selection.scrollIntoView(e,t)}function A(e,t,n){var r;return r=u.fire("ShowCaret",{target:t,direction:e,before:n}),r.isDefaultPrevented()?null:(R(t,e===-1),se.show(n,t))}function B(e){var t;return t=u.fire("BeforeObjectSelected",{target:e}),t.isDefaultPrevented()?null:D(e)}function D(e){var t=e.ownerDocument.createRange();return t.selectNode(e),t}function L(e,t){var n=i.isInSameBlock(e,t);return!(n||!l.isBr(e.getNode()))||n}function M(e,t){return t=i.normalizeRange(e,re,t),e==-1?n.fromRangeStart(t):n.fromRangeEnd(t)}function P(e){return r.isCaretContainerBlock(e.startContainer)}function O(e,t,n,r){var i,o,a,s;return!r.collapsed&&(i=N(r),C(i))?A(e,i,e==-1):(s=P(r),o=M(e,r),n(o)?B(o.getNode(e==-1)):(o=t(o))?n(o)?A(e,o.getNode(e==-1),1==e):(a=t(o),n(a)&&L(o,a)?A(e,a.getNode(e==-1),1==e):s?$(o.toRange()):null):s?r:null)}function H(e,t,n){var r,i,o,l,u,c,d,f,h;if(h=N(n),r=M(e,n),i=t(re,a.isAboveLine(1),r),o=p.filter(i,a.isLine(1)),u=p.last(r.getClientRects()),E(r)&&(h=r.getNode()),w(r)&&(h=r.getNode(!0)),!u)return null;if(c=u.left,l=s.findClosestClientRect(o,c),l&&C(l.node))return d=Math.abs(c-l.left),f=Math.abs(c-l.right),A(e,l.node,d=11)&&(t.innerHTML='
    '),t}var o,a,s;if(r.collapsed&&u.settings.forced_root_block){if(o=u.dom.getParent(r.startContainer,"PRE"),!o)return;a=1==t?oe(n.fromRangeStart(r)):ae(n.fromRangeStart(r)),a||(s=i(),1==t?u.$(o).after(s):u.$(o).before(s),u.selection.select(s,!0),u.selection.collapse())}}function F(e,t,n,r){var i;return(i=O(e,t,n,r))?i:(i=I(e,r),i?i:null)}function z(e,t,n){var r;return(r=H(e,t,n))?r:(r=I(e,n),r?r:null)}function U(){return ce("*[data-mce-caret]")[0]}function W(e){e.hasAttribute("data-mce-caret")&&(r.showCaretContainerBlock(e),k(T()),R(e[0]))}function V(e){var t,r;return e=i.normalizeRange(1,re,e),t=n.fromRangeStart(e),C(t.getNode())?A(1,t.getNode(),!t.isAtEnd()):C(t.getNode(!0))?A(1,t.getNode(!0),!1):(r=u.dom.getParent(t.getNode(),f.or(C,b)),C(r)?A(1,r,!1):null)}function $(e){var t;return e&&e.collapsed?(t=V(e),t?t:e):e}function q(e){var t,i,o,a;return C(e)?(C(e.previousSibling)&&(o=e.previousSibling),i=ae(n.before(e)),i||(t=oe(n.after(e))),t&&x(t.getNode())&&(a=t.getNode()),r.remove(e.previousSibling),r.remove(e.nextSibling),u.dom.remove(e),u.dom.isEmpty(u.getBody())?(u.setContent(""),void u.focus()):o?n.after(o).toRange():a?n.before(a).toRange():i?i.toRange():t?t.toRange():null):null}function j(e){var t=u.schema.getTextBlockElements();return e.nodeName in t}function Y(e){return u.dom.isEmpty(e)}function X(e,t,r){var i=u.dom,o,a,s,l;if(o=i.getParent(t.getNode(),i.isBlock),a=i.getParent(r.getNode(),i.isBlock),e===-1){if(l=r.getNode(!0),w(r)&&S(l))return j(o)?(Y(o)&&i.remove(o),n.after(l).toRange()):q(r.getNode(!0))}else if(l=t.getNode(),E(t)&&S(l))return j(a)?(Y(a)&&i.remove(a),n.before(l).toRange()):q(t.getNode());if(o===a||!j(o)||!j(a))return null;for(;s=o.firstChild;)a.appendChild(s);return u.dom.remove(o),r.toRange()}function K(e,t,n,i){var o,a,s,l;return!i.collapsed&&(o=N(i),C(o))?$(q(o)):(a=M(e,i),n(a)&&r.isCaretContainerBlock(i.startContainer)?(l=e==-1?ie.prev(a):ie.next(a),l?$(l.toRange()):i):t(a)?$(q(a.getNode(e==-1))):(s=e==-1?ie.prev(a):ie.next(a),t(s)?e===-1?X(e,a,s):X(e,s,a):void 0))}function G(){function i(e,t){var n=t(T());n&&!e.isDefaultPrevented()&&(e.preventDefault(),k(n))}function o(e){for(var t=u.getBody();e&&e!=t;){if(b(e)||C(e))return e;e=e.parentNode}return null}function l(e,t,n){return!n.collapsed&&p.reduce(n.getClientRects(),function(n,r){return n||c.containsXY(r,e,t)},!1)}function f(e){var t=!1;e.on("touchstart",function(){t=!1}),e.on("touchmove",function(){t=!0}),e.on("touchend",function(e){var n=o(e.target);C(n)&&(t||(e.preventDefault(),Z(B(n))))})}function g(){var e,t=o(u.selection.getNode());b(t)&&S(t)&&u.dom.isEmpty(t)&&(e=u.dom.create("br",{"data-mce-bogus":"1"}),u.$(t).empty().append(e),u.selection.setRng(n.before(e).toRange()))}function x(e){var t=U();if(t)return"compositionstart"==e.type?(e.preventDefault(),e.stopPropagation(),void W(t)):void(r.hasContent(t)&&W(t))}function N(e){var t;switch(e.keyCode){case d.DELETE:t=g();break;case d.BACKSPACE:t=g()}t&&e.preventDefault()}var R=y(F,1,oe,E),D=y(F,-1,ae,w),L=y(K,1,E,w),M=y(K,-1,w,E),P=y(z,-1,a.upUntil),O=y(z,1,a.downUntil);u.on("mouseup",function(){var e=T();e.collapsed&&k(V(e))}),u.on("click",function(e){var t;t=o(e.target),t&&(C(t)&&(e.preventDefault(),u.focus()),b(t)&&u.dom.isChildOf(t,u.selection.getNode())&&ee())}),u.on("blur NewBlock",function(){ee(),ne()});var H=function(e){var r=new t(e);if(!e.firstChild)return!1;var i=n.before(e.firstChild),o=r.next(i);return o&&!E(o)&&!w(o)},I=function(e,t){var n=u.dom.getParent(e,u.dom.isBlock),r=u.dom.getParent(t,u.dom.isBlock);return n===r},j=function(e){return!(e.keyCode>=112&&e.keyCode<=123)},Y=function(e,t){var n=u.dom.getParent(e,u.dom.isBlock),r=u.dom.getParent(t,u.dom.isBlock);return n&&!I(n,r)&&H(n)};f(u),u.on("mousedown",function(e){var t;if(t=o(e.target))C(t)?(e.preventDefault(),Z(B(t))):l(e.clientX,e.clientY,u.selection.getRng())||u.selection.placeCaretAt(e.clientX,e.clientY);else{ee(),ne();var n=s.closestCaret(re,e.clientX,e.clientY);n&&(Y(e.target,n.node)||(e.preventDefault(),u.getBody().focus(),k(A(1,n.node,n.before))))}}),u.on("keydown",function(e){if(!d.modifierPressed(e))switch(e.keyCode){case d.RIGHT:i(e,R);break;case d.DOWN:i(e,O);break;case d.LEFT:i(e,D);break;case d.UP:i(e,P);break;case d.DELETE:i(e,L);break;case d.BACKSPACE:i(e,M);break;default:C(u.selection.getNode())&&j(e)&&e.preventDefault()}}),u.on("keyup compositionstart",function(e){x(e),N(e)},!0),u.on("cut",function(){var e=u.selection.getNode();C(e)&&h.setEditorTimeout(u,function(){k($(q(e)))})}),u.on("getSelectionRange",function(e){var t=e.range;if(ue){if(!ue.parentNode)return void(ue=null);t=t.cloneRange(),t.selectNode(ue),e.range=t}}),u.on("setSelectionRange",function(e){var t;t=Z(e.range),t&&(e.range=t)}),u.on("AfterSetSelectionRange",function(e){var t=e.range;Q(t)||ne(),v(t.startContainer.parentNode)||ee()}),u.on("focus",function(){h.setEditorTimeout(u,function(){u.selection.setRng($(u.selection.getRng()))},0)}),u.on("copy",function(t){var n=t.clipboardData;if(!t.isDefaultPrevented()&&t.clipboardData&&!e.ie){var r=_();r&&(t.preventDefault(),n.clearData(),n.setData("text/html",r.outerHTML),n.setData("text/plain",r.outerText))}}),m.init(u)}function J(){var e=u.contentStyles,t=".mce-content-body";e.push(se.getCss()),e.push(t+" .mce-offscreen-selection {position: absolute;left: -9999999999px;max-width: 1000000px;}"+t+" *[contentEditable=false] {cursor: default;}"+t+" *[contentEditable=true] {cursor: text;}")}function Q(e){return r.isCaretContainer(e.startContainer)||r.isCaretContainer(e.endContainer)}function Z(t){var n,r=u.$,i=u.dom,o,a,s,l,c,d,f,p,h;if(!t)return null;if(t.collapsed){if(!Q(t)){if(f=M(1,t),C(f.getNode()))return A(1,f.getNode(),!f.isAtEnd());if(C(f.getNode(!0)))return A(1,f.getNode(!0),!1)}return null}return s=t.startContainer,l=t.startOffset,c=t.endOffset,3==s.nodeType&&0==l&&C(s.parentNode)&&(s=s.parentNode,l=i.nodeIndex(s),s=s.parentNode),1!=s.nodeType?null:(c==l+1&&(n=s.childNodes[l]),C(n)?(p=h=n.cloneNode(!0),d=u.fire("ObjectSelected",{target:n,targetClone:p}),d.isDefaultPrevented()?null:(p=d.targetClone,o=r("#"+le),0===o.length&&(o=r('
    ').attr("id",le),o.appendTo(u.getBody())),t=u.dom.createRng(),p===h&&e.ie?(o.empty().append('

    \xa0

    ').append(p),t.setStartAfter(o[0].firstChild.firstChild),t.setEndAfter(p)):(o.empty().append("\xa0").append(p).append("\xa0"),t.setStart(o[0].firstChild,1),t.setEnd(o[0].lastChild,0)),o.css({top:i.getPos(n,u.getBody()).y}),o[0].focus(),a=u.selection.getSel(),a.removeAllRanges(),a.addRange(t),u.$("*[data-mce-selected]").removeAttr("data-mce-selected"),n.setAttribute("data-mce-selected",1),ue=n,ne(),t)):null)}function ee(){ue&&(ue.removeAttribute("data-mce-selected"),u.$("#"+le).remove(),ue=null)}function te(){se.destroy(),ue=null}function ne(){se.hide()}var re=u.getBody(),ie=new t(re),oe=y(g,ie.next),ae=y(g,ie.prev),se=new o(u.getBody(),S),le="sel-"+u.dom.uniqueId(),ue,ce=u.$;return e.ceFalse&&(G(),J()),{showBlockCaretContainer:W,hideFakeCaret:ne,destroy:te}}var y=f.curry,b=l.isContentEditableTrue,C=l.isContentEditableFalse,x=l.isElement,w=i.isAfterContentEditableFalse,E=i.isBeforeContentEditableFalse,N=u.getSelectedNode;return v}),r(it,[],function(){var e=0,t=function(){var e=function(){return Math.round(4294967295*Math.random()).toString(36)},t=(new Date).getTime();return"s"+t.toString(36)+e()+e()+e()},n=function(n){return n+e++ +t()};return{uuid:n}}),r(ot,[],function(){var e=function(e,t,n){var r=e.sidebars?e.sidebars:[];r.push({name:t,settings:n}),e.sidebars=r};return{add:e}}),r(at,[w,g,N,R,A,O,P,Y,J,te,ne,re,le,ue,E,f,Le,Ie,B,L,ze,d,m,c,Ue,We,Ve,Ge,rt,it,ot,Ke],function(e,n,r,i,o,a,s,l,u,c,d,f,p,h,m,g,v,y,b,C,x,w,E,N,_,S,k,T,R,A,B,D){function L(e,t,i){var o=this,a,s,l;a=o.documentBaseUrl=i.documentBaseURL,s=i.baseURI,l=i.defaultSettings,t=H({id:e,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:a,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",validate:!0,entity_encoding:"named",url_converter:o.convertURL,url_converter_scope:o,ie7_compat:!0},l,t),l&&l.external_plugins&&t.external_plugins&&(t.external_plugins=H({},l.external_plugins,t.external_plugins)),o.settings=t,r.language=t.language||"en",r.languageLoad=t.language_load,r.baseURL=i.baseURL,o.id=t.id=e,o.setDirty(!1),o.plugins={},o.documentBaseURI=new h(t.document_base_url||a,{base_uri:s}),o.baseURI=s,o.contentCSS=[],o.contentStyles=[],o.shortcuts=new k(o),o.loadedCSS={},o.editorCommands=new p(o),o.suffix=i.suffix,o.editorManager=i,o.inline=t.inline,o.settings.content_editable=o.inline,t.cache_suffix&&(w.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),t.override_viewport===!1&&(w.overrideViewPort=!1),i.fire("SetupEditor",o),o.execCallback("setup",o),o.$=n.overrideDefaults(function(){return{context:o.inline?o.getBody():o.getDoc(),element:o.getBody()}})}var M=e.DOM,P=r.ThemeManager,O=r.PluginManager,H=E.extend,I=E.each,F=E.explode,z=E.inArray,U=E.trim,W=E.resolve,V=g.Event,$=w.gecko,q=w.ie;return L.prototype={render:function(){function e(){M.unbind(window,"ready",e),n.render()}function t(){var e=m.ScriptLoader;if(r.language&&"en"!=r.language&&!r.language_url&&(r.language_url=n.editorManager.baseURL+"/langs/"+r.language+".js"),r.language_url&&e.add(r.language_url),r.theme&&"function"!=typeof r.theme&&"-"!=r.theme.charAt(0)&&!P.urls[r.theme]){var t=r.theme_url;t=t?n.documentBaseURI.toAbsolute(t):"themes/"+r.theme+"/theme"+o+".js",P.load(r.theme,t)}E.isArray(r.plugins)&&(r.plugins=r.plugins.join(" ")),I(r.external_plugins,function(e,t){O.load(t,e),r.plugins+=" "+t}),I(r.plugins.split(/[ ,]/),function(e){if(e=U(e),e&&!O.urls[e])if("-"==e.charAt(0)){e=e.substr(1,e.length);var t=O.dependencies(e);I(t,function(e){var t={prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"};e=O.createUrl(t,e),O.load(e.resource,e)})}else O.load(e,{prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"})}),e.loadQueue(function(){n.removed||n.init()},n,function(e){D.pluginLoadError(n,e[0]),n.removed||n.init()})}var n=this,r=n.settings,i=n.id,o=n.suffix;if(!V.domLoaded)return void M.bind(window,"ready",e);if(n.getElement()&&w.contentEditable){r.inline?n.inline=!0:(n.orgVisibility=n.getElement().style.visibility,n.getElement().style.visibility="hidden");var a=n.getElement().form||M.getParent(i,"form");a&&(n.formElement=a,r.hidden_input&&!/TEXTAREA|INPUT/i.test(n.getElement().nodeName)&&(M.insertAfter(M.create("input",{type:"hidden",name:i}),i),n.hasHiddenInput=!0),n.formEventDelegate=function(e){n.fire(e.type,e)},M.bind(a,"submit reset",n.formEventDelegate),n.on("reset",function(){n.setContent(n.startContent,{format:"raw"})}),!r.submit_patch||a.submit.nodeType||a.submit.length||a._mceOldSubmit||(a._mceOldSubmit=a.submit,a.submit=function(){return n.editorManager.triggerSave(),n.setDirty(!1),a._mceOldSubmit(a)})),n.windowManager=new v(n),n.notificationManager=new y(n),"xml"==r.encoding&&n.on("GetContent",function(e){e.save&&(e.content=M.encode(e.content))}),r.add_form_submit_trigger&&n.on("submit",function(){n.initialized&&n.save()}),r.add_unload_trigger&&(n._beforeUnload=function(){!n.initialized||n.destroyed||n.isHidden()||n.save({format:"raw",no_events:!0,set_dirty:!1})},n.editorManager.on("BeforeUnload",n._beforeUnload)),n.editorManager.add(n),t()}},init:function(){function e(n){var r=O.get(n),i,o;if(i=O.urls[n]||t.documentBaseUrl.replace(/\/$/,""),n=U(n),r&&z(m,n)===-1){if(I(O.dependencies(n),function(t){e(t)}),t.plugins[n])return;o=new r(t,i,t.$),t.plugins[n]=o,o.init&&(o.init(t,i),m.push(n))}}var t=this,n=t.settings,r=t.getElement(),i,o,a,s,l,u,c,d,f,p,h,m=[];if(t.rtl=n.rtl_ui||t.editorManager.i18n.rtl,t.editorManager.i18n.setCode(n.language),n.aria_label=n.aria_label||M.getAttrib(r,"aria-label",t.getLang("aria.rich_text_area")),t.fire("ScriptsLoaded"),n.theme&&("function"!=typeof n.theme?(n.theme=n.theme.replace(/-/,""),u=P.get(n.theme),t.theme=new u(t,P.urls[n.theme]),t.theme.init&&t.theme.init(t,P.urls[n.theme]||t.documentBaseUrl.replace(/\/$/,""),t.$)):t.theme=n.theme),I(n.plugins.replace(/\-/g,"").split(/[ ,]/),e),n.render_ui&&t.theme&&(t.orgDisplay=r.style.display,"function"!=typeof n.theme?(i=n.width||r.style.width||r.offsetWidth,o=n.height||r.style.height||r.offsetHeight,a=n.min_height||100,p=/^[0-9\.]+(|px)$/i,p.test(""+i)&&(i=Math.max(parseInt(i,10),100)),p.test(""+o)&&(o=Math.max(parseInt(o,10),a)),l=t.theme.renderUI({targetNode:r,width:i,height:o,deltaWidth:n.delta_width,deltaHeight:n.delta_height}),n.content_editable||(o=(l.iframeHeight||o)+("number"==typeof o?l.deltaHeight||0:""),o",n.document_base_url!=t.documentBaseUrl&&(t.iframeHTML+=''),!w.caretAfter&&n.ie7_compat&&(t.iframeHTML+=''),t.iframeHTML+='',!/#$/.test(document.location.href))for(h=0;h',t.loadedCSS[g]=!0}d=n.body_id||"tinymce",d.indexOf("=")!=-1&&(d=t.getParam("body_id","","hash"),d=d[t.id]||d),f=n.body_class||"",f.indexOf("=")!=-1&&(f=t.getParam("body_class","","hash"),f=f[t.id]||""),n.content_security_policy&&(t.iframeHTML+=''),t.iframeHTML+='
    ';var v='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody(true);})()';document.domain!=location.hostname&&w.ie&&w.ie<12&&(c=v);var y=M.create("iframe",{id:t.id+"_ifr",frameBorder:"0",allowTransparency:"true",title:t.editorManager.translate("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),style:{width:"100%",height:o,display:"block"}});if(y.onload=function(){y.onload=null,t.fire("load")},M.setAttrib(y,"src",c||'javascript:""'),t.contentAreaContainer=l.iframeContainer,t.iframeElement=y,s=M.add(l.iframeContainer,y),q)try{t.getDoc()}catch(b){s.src=c=v}l.editorContainer&&(M.get(l.editorContainer).style.display=t.orgDisplay,t.hidden=M.isHidden(l.editorContainer)),t.getElement().style.display="none",M.setAttrib(t.id,"aria-hidden",!0),c||t.initContentBody(),r=s=l=null},initContentBody:function(t){var n=this,r=n.settings,s=n.getElement(),p=n.getDoc(),h,m;r.inline||(n.getElement().style.visibility=n.orgVisibility),t||r.content_editable||(p.open(),p.write(n.iframeHTML),p.close()),r.content_editable&&(n.on("remove",function(){var e=this.getBody();M.removeClass(e,"mce-content-body"),M.removeClass(e,"mce-edit-focus"),M.setAttrib(e,"contentEditable",null)}),M.addClass(s,"mce-content-body"),n.contentDocument=p=r.content_document||document,n.contentWindow=r.content_window||window,n.bodyElement=s,r.content_document=r.content_window=null,r.root_name=s.nodeName.toLowerCase()),h=n.getBody(),h.disabled=!0,n.readonly=r.readonly,n.readonly||(n.inline&&"static"==M.getStyle(h,"position",!0)&&(h.style.position="relative"),h.contentEditable=n.getParam("content_editable_state",!0)),h.disabled=!1,n.editorUpload=new T(n),n.schema=new b(r),n.dom=new e(p,{keep_values:!0,url_converter:n.convertURL,url_converter_scope:n,hex_colors:r.force_hex_style_colors,class_filter:r.class_filter,update_styles:!0,root_element:n.inline?n.getBody():null,collect:r.content_editable,schema:n.schema,onSetAttrib:function(e){n.fire("SetAttrib",e)}}),n.parser=new C(r,n.schema),n.parser.addAttributeFilter("src,href,style,tabindex",function(e,t){for(var r=e.length,i,o=n.dom,a,s;r--;)if(i=e[r],a=i.attr(t),s="data-mce-"+t,!i.attributes.map[s]){if(0===a.indexOf("data:")||0===a.indexOf("blob:"))continue;"style"===t?(a=o.serializeStyle(o.parseStyle(a),i.name),a.length||(a=null),i.attr(s,a),i.attr(t,a)):"tabindex"===t?(i.attr(s,a),i.attr(t,null)):i.attr(s,n.convertURL(a,t,i.name))}}),n.parser.addNodeFilter("script",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.attr("type")||"no/type", +0!==r.indexOf("mce-")&&n.attr("type","mce-"+r)}),n.parser.addNodeFilter("#cdata",function(e){for(var t=e.length,n;t--;)n=e[t],n.type=8,n.name="#comment",n.value="[CDATA["+n.value+"]]"}),n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(e){for(var t=e.length,r,i=n.schema.getNonEmptyElements();t--;)r=e[t],r.isEmpty(i)&&0===r.getAll("br").length&&(r.append(new o("br",1)).shortEnded=!0)}),n.serializer=new a(r,n),n.selection=new l(n.dom,n.getWin(),n.serializer,n),n.formatter=new u(n),n.undoManager=new c(n),n.forceBlocks=new f(n),n.enterKey=new d(n),n._nodeChangeDispatcher=new i(n),n._selectionOverrides=new R(n),n.fire("PreInit"),r.browser_spellcheck||r.gecko_spellcheck||(p.body.spellcheck=!1,M.setAttrib(h,"spellcheck","false")),n.quirks=new x(n),n.fire("PostRender"),r.directionality&&(h.dir=r.directionality),r.nowrap&&(h.style.whiteSpace="nowrap"),r.protect&&n.on("BeforeSetContent",function(e){I(r.protect,function(t){e.content=e.content.replace(t,function(e){return""})})}),n.on("SetContent",function(){n.addVisual(n.getBody())}),r.padd_empty_editor&&n.on("PostProcess",function(e){e.content=e.content.replace(/^(]*>( | |\s|\u00a0|
    |)<\/p>[\r\n]*|
    [\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.on("compositionstart compositionend",function(e){n.composing="compositionstart"===e.type}),n.contentStyles.length>0&&(m="",I(n.contentStyles,function(e){m+=e+"\r\n"}),n.dom.addStyle(m)),I(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&N.setEditorTimeout(n,function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.destroyed||e.focus()},100),s=p=h=null},focus:function(e){function t(e){return n.dom.getParent(e,function(e){return"true"===n.dom.getContentEditable(e)})}var n=this,r=n.selection,i=n.settings.content_editable,o,a,s=n.getDoc(),l=n.getBody(),u;if(!e){if(o=r.getRng(),o.item&&(a=o.item(0)),n.quirks.refreshContentEditable(),u=t(r.getNode()),n.$.contains(l,u))return u.focus(),r.normalize(),void n.editorManager.setActive(n);if(i||(w.opera||n.getBody().focus(),n.getWin().focus()),$||i){if(l.setActive)try{l.setActive()}catch(c){l.focus()}else l.focus();i&&r.normalize()}a&&a.ownerDocument==s&&(o=s.body.createControlRange(),o.addElement(a),o.select())}n.editorManager.setActive(n)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?W(r):0,n=W(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?(e=n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}),this.editorManager.translate(e)):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?I(r.indexOf("=")>0?r.split(/[;,](?![^=;,]*(?:[;,]|$))/):r.split(","),function(e){e=e.split("="),e.length>1?i[U(e[0])]=U(e[1]):i[U(e[0])]=U(e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addSidebar:function(e,t){return B.add(this,e,t)},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addContextToolbar:function(e,t){var n=this,r;n.contextToolbars=n.contextToolbars||[],"string"==typeof e&&(r=e,e=function(e){return n.dom.is(e,r)}),n.contextToolbars.push({id:A.uuid("mcet"),predicate:e,items:t})},addCommand:function(e,t,n){this.editorCommands.addCommand(e,t,n)},addQueryStateHandler:function(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)},addQueryValueHandler:function(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){return this.editorCommands.execCommand(e,t,n,r)},queryCommandState:function(e){return this.editorCommands.queryCommandState(e)},queryCommandValue:function(e){return this.editorCommands.queryCommandValue(e)},queryCommandSupported:function(e){return this.editorCommands.queryCommandSupported(e)},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(M.show(e.getContainer()),M.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(q&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(M.hide(e.getContainer()),M.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;if(r)return e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),"raw"==e.format&&t.fire("RawSaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=M.getParent(t.id,"form"))&&I(i.elements,function(e){if(e.name==t.id)return e.value=r,!1})),e.element=n=null,e.set_dirty!==!1&&t.setDirty(!1),r},setContent:function(e,t){var n=this,r=n.getBody(),i,o;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(o=q&&q<11?"":'
    ',"TABLE"==r.nodeName?e=""+o+"":/^(UL|OL)$/.test(r.nodeName)&&(e="
  • "+o+"
  • "),i=n.settings.forced_root_block,i&&n.schema.isValidChild(r.nodeName.toLowerCase(),i.toLowerCase())?(e=o,e=n.dom.createHTML(i,n.settings.forced_root_block_attrs,e)):q||e||(e='
    '),n.dom.setHTML(r,e),n.fire("SetContent",t)):("raw"!==t.format&&(e=new s({validate:n.validate},n.schema).serialize(n.parser.parse(e,{isRootContent:!0}))),t.content=U(e),n.dom.setHTML(r,t.content),t.no_events||n.fire("SetContent",t)),t.content},getContent:function(e){var t=this,n,r=t.getBody();return e=e||{},e.format=e.format||"html",e.get=!0,e.getInner=!0,e.no_events||t.fire("BeforeGetContent",e),n="raw"==e.format?E.trim(t.serializer.getTrimmedContent()):"text"==e.format?r.innerText||r.textContent:t.serializer.serialize(r,e),"text"!=e.format?e.content=U(n):e.content=n,e.no_events||t.fire("GetContent",e),e.content},insertContent:function(e,t){t&&(e=H({content:e},t)),this.execCommand("mceInsertContent",!1,e)},isDirty:function(){return!this.isNotDirty},setDirty:function(e){var t=!this.isNotDirty;this.isNotDirty=!e,e&&e!=t&&this.fire("dirty")},setMode:function(e){S.setMode(this,e)},getContainer:function(){var e=this;return e.container||(e.container=M.get(e.editorContainer||e.id+"_parent")),e.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=M.get(this.id)),this.targetElm},getWin:function(){var e=this,t;return e.contentWindow||(t=e.iframeElement,t&&(e.contentWindow=t.contentWindow)),e.contentWindow},getDoc:function(){var e=this,t;return e.contentDocument||(t=e.getWin(),t&&(e.contentDocument=t.document)),e.contentDocument},getBody:function(){var e=this.getDoc();return this.bodyElement||(e?e.body:null)},convertURL:function(e,t,n){var r=this,i=r.settings;return i.urlconverter_callback?r.execCallback("urlconverter_callback",e,n,!0,t):!i.convert_urls||n&&"LINK"==n.nodeName||0===e.indexOf("file:")||0===e.length?e:i.relative_urls?r.documentBaseURI.toRelative(e):e=r.documentBaseURI.toAbsolute(e,i.remove_script_host)},addVisual:function(e){var n=this,r=n.settings,i=n.dom,o;e=e||n.getBody(),n.hasVisual===t&&(n.hasVisual=r.visual),I(i.select("table,a",e),function(e){var t;switch(e.nodeName){case"TABLE":return o=r.visual_table_class||"mce-item-table",t=i.getAttrib(e,"border"),void(t&&"0"!=t||!n.hasVisual?i.removeClass(e,o):i.addClass(e,o));case"A":return void(i.getAttrib(e,"href",!1)||(t=i.getAttrib(e,"name")||e.id,o=r.visual_anchor_class||"mce-item-anchor",t&&n.hasVisual?i.addClass(e,o):i.removeClass(e,o)))}}),n.fire("VisualAid",{element:e,hasVisual:n.hasVisual})},remove:function(){var e=this;e.removed||(e.save(),e.removed=1,e.unbindAllNativeEvents(),e.hasHiddenInput&&M.remove(e.getElement().nextSibling),e.inline||(q&&q<10&&e.getDoc().execCommand("SelectAll",!1,null),M.setStyle(e.id,"display",e.orgDisplay),e.getBody().onload=null),e.fire("remove"),e.editorManager.remove(e),M.remove(e.getContainer()),e._selectionOverrides.destroy(),e.editorUpload.destroy(),e.destroy())},destroy:function(e){var t=this,n;if(!t.destroyed){if(!e&&!t.removed)return void t.remove();e||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),t.selection.destroy(),t.dom.destroy()),n=t.formElement,n&&(n._mceOldSubmit&&(n.submit=n._mceOldSubmit,n._mceOldSubmit=null),M.unbind(n,"submit reset",t.formEventDelegate)),t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null,t.selection&&(t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null),t.destroyed=1}},uploadImages:function(e){return this.editorUpload.uploadImages(e)},_scanForImages:function(){return this.editorUpload.scanForImages()}},H(L.prototype,_),L}),r(st,[m],function(e){var t={},n="en";return{setCode:function(e){e&&(n=e,this.rtl=!!this.data[e]&&"rtl"===this.data[e]._dir)},getCode:function(){return n},rtl:!1,add:function(e,n){var r=t[e];r||(t[e]=r={});for(var i in n)r[i]=n[i];this.setCode(e)},translate:function(r){function i(t){return e.is(t,"function")?Object.prototype.toString.call(t):o(t)?"":""+t}function o(t){return""===t||null===t||e.is(t,"undefined")}function a(t){return t=i(t),e.hasOwn(s,t)?i(s[t]):t}var s=t[n]||{};if(o(r))return"";if(e.is(r,"object")&&e.hasOwn(r,"raw"))return i(r.raw);if(e.is(r,"array")){var l=r.slice(1);r=a(r[0]).replace(/\{([0-9]+)\}/g,function(t,n){return e.hasOwn(l,n)?i(l[n]):t})}return a(r).replace(/{context:\w+}$/,"")},data:t}}),r(lt,[w,c,d],function(e,t,n){function r(e){function r(){try{return document.activeElement}catch(e){return document.body}}function u(e,t){if(t&&t.startContainer){if(!e.isChildOf(t.startContainer,e.getRoot())||!e.isChildOf(t.endContainer,e.getRoot()))return;return{startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}}return t}function c(e,t){var n;return t.startContainer?(n=e.getDoc().createRange(),n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset)):n=t,n}function d(d){var f=d.editor;f.on("init",function(){(f.inline||n.ie)&&("onbeforedeactivate"in document&&n.ie<9?f.dom.bind(f.getBody(),"beforedeactivate",function(e){if(e.target==f.getBody())try{f.lastRng=f.selection.getRng()}catch(t){}}):f.on("nodechange mouseup keyup",function(e){var t=r();"nodechange"==e.type&&e.selectionChange||(t&&t.id==f.id+"_ifr"&&(t=f.getBody()),f.dom.isChildOf(t,f.getBody())&&(f.lastRng=f.selection.getRng()))}),n.webkit&&!i&&(i=function(){var t=e.activeEditor;if(t&&t.selection){var n=t.selection.getRng();n&&!n.collapsed&&(f.lastRng=n)}},s.bind(document,"selectionchange",i)))}),f.on("setcontent",function(){f.lastRng=null}),f.on("mousedown",function(){f.selection.lastFocusBookmark=null}),f.on("focusin",function(){var t=e.focusedEditor,n;f.selection.lastFocusBookmark&&(n=c(f,f.selection.lastFocusBookmark),f.selection.lastFocusBookmark=null,f.selection.setRng(n)),t!=f&&(t&&t.fire("blur",{focusedEditor:f}),e.setActive(f),e.focusedEditor=f,f.fire("focus",{blurredEditor:t}),f.focus(!0)),f.lastRng=null}),f.on("focusout",function(){t.setEditorTimeout(f,function(){var t=e.focusedEditor;l(f,r())||t!=f||(f.fire("blur",{focusedEditor:null}),e.focusedEditor=null,f.selection&&(f.selection.lastFocusBookmark=null))})}),o||(o=function(t){var n=e.activeEditor,r;r=t.target,n&&r.ownerDocument==document&&(n.selection&&r!=n.getBody()&&(n.selection.lastFocusBookmark=u(n.dom,n.lastRng)),r==document.body||l(n,r)||e.focusedEditor!=n||(n.fire("blur",{focusedEditor:null}),e.focusedEditor=null))},s.bind(document,"focusin",o)),f.inline&&!a&&(a=function(t){var n=e.activeEditor,r=n.dom;if(n.inline&&r&&!r.isChildOf(t.target,n.getBody())){var i=n.selection.getRng();i.collapsed||(n.lastRng=i)}},s.bind(document,"mouseup",a))}function f(t){e.focusedEditor==t.editor&&(e.focusedEditor=null),e.activeEditor||(s.unbind(document,"selectionchange",i),s.unbind(document,"focusin",o),s.unbind(document,"mouseup",a),i=o=a=null)}e.on("AddEditor",d),e.on("RemoveEditor",f)}var i,o,a,s=e.DOM,l=function(e,t){var n=e?e.settings.custom_ui_selector:"",i=s.getParent(t,function(t){return r.isEditorUIElement(t)||!!n&&e.dom.is(t,n)});return null!==i};return r.isEditorUIElement=function(e){return e.className.toString().indexOf("mce-")!==-1},r._isUIElement=l,r}),r(ut,[at,g,w,ue,d,m,u,pe,st,lt,N],function(e,t,n,r,i,o,a,s,l,u,c){function d(e){v(x.editors,function(t){"scroll"===e.type?t.fire("ScrollWindow",e):t.fire("ResizeWindow",e)})}function f(e,n){n!==w&&(n?t(window).on("resize scroll",d):t(window).off("resize scroll",d),w=n)}function p(e){var t=x.editors,n;delete t[e.id];for(var r=0;r0&&v(g(t),function(e){var t;(t=m.get(e))?n.push(t):v(document.forms,function(t){v(t.elements,function(t){t.name===e&&(e="mce_editor_"+b++,m.setAttrib(t,"id",e),n.push(t))})})});break;case"textareas":case"specific_textareas":v(m.select("textarea"),function(t){e.editor_deselector&&u(t,e.editor_deselector)||e.editor_selector&&!u(t,e.editor_selector)||n.push(t)})}return n}function d(){function a(t,n,r){var i=new e(t,n,f);p.push(i),i.on("init",function(){++u===g.length&&x(p)}),i.targetElm=i.targetElm||r,i.render()}var u=0,p=[],g;return m.unbind(window,"ready",d),l("onpageload"),g=t.unique(c(n)),n.types?void v(n.types,function(e){o.each(g,function(t){return!m.is(t,e.selector)||(a(s(t),y({},n,e),t),!1)})}):(o.each(g,function(e){h(f.get(e.id))}),g=o.grep(g,function(e){return!f.get(e.id)}),void v(g,function(e){r(n,e)?i("Could not initialize inline editor on invalid inline target element",e):a(s(e),n,e)}))}var f=this,p,C;C=o.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option tbody tfoot thead tr script noscript style textarea video audio iframe object menu"," ");var x=function(e){p=e};return f.settings=n,m.bind(window,"ready",d),new a(function(e){p?e(p):x=function(t){e(t)}})},get:function(e){return arguments.length?e in this.editors?this.editors[e]:null:this.editors},add:function(e){var t=this,n=t.editors;return n[e.id]=e,n.push(e),f(n,!0),t.activeEditor=e,t.fire("AddEditor",{editor:e}),C||(C=function(){t.fire("BeforeUnload")},m.bind(window,"beforeunload",C)),e},createEditor:function(t,n){return this.add(new e(t,n,this))},remove:function(e){var t=this,n,r=t.editors,i;{if(e)return"string"==typeof e?(e=e.selector||e,void v(m.select(e),function(e){i=r[e.id],i&&t.remove(i)})):(i=e,r[i.id]?(p(i)&&t.fire("RemoveEditor",{editor:i}),r.length||m.unbind(window,"beforeunload",C),i.remove(),f(r,r.length>0),i):null);for(n=r.length-1;n>=0;n--)t.remove(r[n])}},execCommand:function(t,n,r){var i=this,o=i.get(r);switch(t){case"mceAddEditor":return i.get(r)||new e(r,i.settings,i).render(),!0;case"mceRemoveEditor":return o&&o.remove(),!0;case"mceToggleEditor":return o?(o.isHidden()?o.show():o.hide(),!0):(i.execCommand("mceAddEditor",0,r),!0)}return!!i.activeEditor&&i.activeEditor.execCommand(t,n,r)},triggerSave:function(){v(this.editors,function(e){e.save()})},addI18n:function(e,t){l.add(e,t)},translate:function(e){return l.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!=e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e}},y(x,s),x.setup(),window.tinymce=window.tinyMCE=x,x}),r(ct,[ut,m],function(e,t){var n=t.each,r=t.explode;e.on("AddEditor",function(e){var t=e.editor;t.on("preInit",function(){function e(e,t){n(t,function(t,n){t&&s.setStyle(e,n,t)}),s.rename(e,"span")}function i(e){s=t.dom,l.convert_fonts_to_spans&&n(s.select("font,u,strike",e.node),function(e){o[e.nodeName.toLowerCase()](s,e)})}var o,a,s,l=t.settings;l.inline_styles&&(a=r(l.font_size_legacy_values),o={font:function(t,n){e(n,{backgroundColor:n.style.backgroundColor,color:n.color,fontFamily:n.face,fontSize:a[parseInt(n.size,10)-1]})},u:function(n,r){"html4"===t.settings.schema&&e(r,{textDecoration:"underline"})},strike:function(t,n){e(n,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",i))})})}),r(dt,[pe,m],function(e,t){var n={send:function(e){function r(){!e.async||4==i.readyState||o++>1e4?(e.success&&o<1e4&&200==i.status?e.success.call(e.success_scope,""+i.responseText,i,e):e.error&&e.error.call(e.error_scope,o>1e4?"TIMED_OUT":"GENERAL",i,e),i=null):setTimeout(r,10)}var i,o=0;if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=e.async!==!1,e.data=e.data||"",n.fire("beforeInitialize",{settings:e}),i=new XMLHttpRequest){if(i.overrideMimeType&&i.overrideMimeType(e.content_type),i.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(i.withCredentials=!0),e.content_type&&i.setRequestHeader("Content-Type",e.content_type),e.requestheaders&&t.each(e.requestheaders,function(e){i.setRequestHeader(e.key,e.value)}),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i=n.fire("beforeSend",{xhr:i,settings:e}).xhr,i.send(e.data),!e.async)return r();setTimeout(r,10)}}};return t.extend(n,e),n}),r(ft,[],function(){function e(t,n){var r,i,o,a;if(n=n||'"',null===t)return"null";if(o=typeof t,"string"==o)return i="\bb\tt\nn\ff\rr\"\"''\\\\",n+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=i.indexOf(t),r+1?"\\"+i.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e))})+n;if("object"==o){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(r=0,i="[";r0?",":"")+e(t[r],n);return i+"]"}i="{";for(a in t)t.hasOwnProperty(a)&&(i+="function"!=typeof t[a]?(i.length>1?","+n:n)+a+n+":"+e(t[a],n):"");return i+"}"}return""+t}return{serialize:e,parse:function(e){try{return window[String.fromCharCode(101)+"val"]("("+e+")")}catch(t){}}}}),r(pt,[ft,dt,m],function(e,t,n){function r(e){this.settings=i({},e),this.count=0}var i=n.extend;return r.sendRPC=function(e){return(new r).send(e)},r.prototype={send:function(n){var r=n.error,o=n.success;n=i(this.settings,n),n.success=function(t,i){t=e.parse(t),"undefined"==typeof t&&(t={error:"JSON Parse error."}),t.error?r.call(n.error_scope||n.scope,t.error,i):o.call(n.success_scope||n.scope,t.result)},n.error=function(e,t){r&&r.call(n.error_scope||n.scope,e,t)},n.data=e.serialize({id:n.id||"c"+this.count++,method:n.method,params:n.params}),n.content_type="application/json",t.send(n)}},r}),r(ht,[w],function(e){return{callbacks:{},count:0,send:function(n){var r=this,i=e.DOM,o=n.count!==t?n.count:r.count,a="tinymce_jsonp_"+o;r.callbacks[o]=function(e){i.remove(a),delete r.callbacks[o],n.callback(e)},i.add(i.doc.body,"script",{id:a,src:n.url,type:"text/javascript"}),r.count++}}}),r(mt,[],function(){function e(){s=[];for(var e in a)s.push(e);i.length=s.length}function n(){function n(e){var n,r;return r=e!==t?c+e:i.indexOf(",",c),r===-1||r>i.length?null:(n=i.substring(c,r),c=r+1,n)}var r,i,s,c=0;if(a={},u){o.load(l),i=o.getAttribute(l)||"";do{var d=n();if(null===d)break;if(r=n(parseInt(d,32)||0),null!==r){if(d=n(),null===d)break;s=n(parseInt(d,32)||0),r&&(a[r]=s)}}while(null!==r);e()}}function r(){var t,n="";if(u){for(var r in a)t=a[r],n+=(n?",":"")+r.length.toString(32)+","+r+","+t.length.toString(32)+","+t;o.setAttribute(l,n);try{o.save(l)}catch(i){}e()}}var i,o,a,s,l,u;try{if(window.localStorage)return localStorage}catch(c){}return l="tinymce",o=document.documentElement,u=!!o.addBehavior,u&&o.addBehavior("#default#userData"),i={key:function(e){return s[e]},getItem:function(e){return e in a?a[e]:null},setItem:function(e,t){a[e]=""+t,r()},removeItem:function(e){delete a[e],r()},clear:function(){a={},r()}},n(),i}),r(gt,[w,f,E,N,m,d],function(e,t,n,r,i,o){var a=window.tinymce;return a.DOM=e.DOM,a.ScriptLoader=n.ScriptLoader,a.PluginManager=r.PluginManager,a.ThemeManager=r.ThemeManager,a.dom=a.dom||{},a.dom.Event=t.Event,i.each("trim isArray is toArray makeMap each map grep inArray extend create walk createNS resolve explode _addCacheSuffix".split(" "),function(e){a[e]=i[e]}),i.each("isOpera isWebKit isIE isGecko isMac".split(" "),function(e){a[e]=o[e.substr(2).toLowerCase()]}),{}}),r(vt,[ce,m],function(e,t){return e.extend({Defaults:{firstControlClass:"first",lastControlClass:"last"},init:function(e){this.settings=t.extend({},this.Defaults,e)},preRender:function(e){e.bodyClasses.add(this.settings.containerClass)},applyClasses:function(e){var t=this,n=t.settings,r,i,o,a;r=n.firstControlClass,i=n.lastControlClass,e.each(function(e){e.classes.remove(r).remove(i).add(n.controlClass),e.visible()&&(o||(o=e),a=e)}),o&&o.classes.add(r),a&&a.classes.add(i)},renderHtml:function(e){var t=this,n="";return t.applyClasses(e.items()),e.items().each(function(e){n+=e.renderHtml()}),n},recalc:function(){},postRender:function(){},isNative:function(){return!1}})}),r(yt,[vt],function(e){return e.extend({Defaults:{containerClass:"abs-layout",controlClass:"abs-layout-item"},recalc:function(e){e.items().filter(":visible").each(function(e){var t=e.settings;e.layoutRect({x:t.x,y:t.y,w:t.w,h:t.h}),e.recalc&&e.recalc()})},renderHtml:function(e){return'
    '+this._super(e)}})}),r(bt,[Pe],function(e){return e.extend({Defaults:{classes:"widget btn",role:"button"},init:function(e){var t=this,n;t._super(e),e=t.settings,n=t.settings.size,t.on("click mousedown",function(e){e.preventDefault()}),t.on("touchstart",function(e){t.fire("click",e),e.preventDefault()}),e.subtype&&t.classes.add(e.subtype),n&&t.classes.add("btn-"+n),e.icon&&t.icon(e.icon)},icon:function(e){return arguments.length?(this.state.set("icon",e),this):this.state.get("icon")},repaint:function(){var e=this.getEl().firstChild,t;e&&(t=e.style,t.width=t.height="100%"),this._super()},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.state.get("icon"),i,o=e.state.get("text"),a="";return i=e.settings.image,i?(r="none","string"!=typeof i&&(i=window.getSelection?i[0]:i[1]),i=" style=\"background-image: url('"+i+"')\""):i="",o&&(e.classes.add("btn-has-text"),a=''+e.encode(o)+""),r=r?n+"ico "+n+"i-"+r:"",'
    "},bindStates:function(){function e(e){var i=n("span."+r,t.getEl());e?(i[0]||(n("button:first",t.getEl()).append(''),i=n("span."+r,t.getEl())),i.html(t.encode(e))):i.remove(),t.classes.toggle("btn-has-text",!!e)}var t=this,n=t.$,r=t.classPrefix+"txt";return t.state.on("change:text",function(t){e(t.value)}),t.state.on("change:icon",function(n){var r=n.value,i=t.classPrefix;t.settings.icon=r,r=r?i+"ico "+i+"i-"+t.settings.icon:"";var o=t.getEl().firstChild,a=o.getElementsByTagName("i")[0];r?(a&&a==o.firstChild||(a=document.createElement("i"),o.insertBefore(a,o.firstChild)),a.className=r):a&&o.removeChild(a),e(t.state.get("text"))}),t._super()}})}),r(Ct,[Ne],function(e){return e.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var e=this,t=e._layout;return e.classes.add("btn-group"),e.preRender(),t.preRender(e),'
    '+(e.settings.html||"")+t.renderHtml(e)+"
    "}})}),r(xt,[Pe],function(e){return e.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(e){var t=this;t._super(e),t.on("click mousedown",function(e){e.preventDefault()}),t.on("click",function(e){e.preventDefault(),t.disabled()||t.checked(!t.checked())}),t.checked(t.settings.checked)},checked:function(e){return arguments.length?(this.state.set("checked",e),this):this.state.get("checked")},value:function(e){return arguments.length?this.checked(e):this.checked()},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix;return'
    '+e.encode(e.state.get("text"))+"
    "},bindStates:function(){function e(e){t.classes.toggle("checked",e),t.aria("checked",e)}var t=this;return t.state.on("change:text",function(e){t.getEl("al").firstChild.data=t.translate(e.value)}),t.state.on("change:checked change:value",function(n){t.fire("change"),e(n.value)}),t.state.on("change:icon",function(e){var n=e.value,r=t.classPrefix;if("undefined"==typeof n)return t.settings.icon;t.settings.icon=n,n=n?r+"ico "+r+"i-"+t.settings.icon:"";var i=t.getEl().firstChild,o=i.getElementsByTagName("i")[0];n?(o&&o==i.firstChild||(o=document.createElement("i"),i.insertBefore(o,i.firstChild)),o.className=n):o&&i.removeChild(o)}),t.state.get("checked")&&e(!0),t._super()}})}),r(wt,[Pe,we,ve,g,I,m],function(e,t,n,r,i,o){return e.extend({init:function(e){var t=this;t._super(e),e=t.settings,t.classes.add("combobox"),t.subinput=!0,t.ariaTarget="inp",e.menu=e.menu||e.values,e.menu&&(e.icon="caret"),t.on("click",function(n){var i=n.target,o=t.getEl();if(r.contains(o,i)||i==o)for(;i&&i!=o;)i.id&&i.id.indexOf("-open")!=-1&&(t.fire("action"),e.menu&&(t.showMenu(),n.aria&&t.menu.items()[0].focus())),i=i.parentNode}),t.on("keydown",function(e){var n;13==e.keyCode&&"INPUT"===e.target.nodeName&&(e.preventDefault(),t.parents().reverse().each(function(e){if(e.toJSON)return n=e,!1}),t.fire("submit",{data:n.toJSON()}))}),t.on("keyup",function(e){if("INPUT"==e.target.nodeName){var n=t.state.get("value"),r=e.target.value;r!==n&&(t.state.set("value",r),t.fire("autocomplete",e))}}),t.on("mouseover",function(e){var n=t.tooltip().moveTo(-65535);if(t.statusLevel()&&e.target.className.indexOf(t.classPrefix+"status")!==-1){var r=t.statusMessage()||"Ok",i=n.text(r).show().testMoveRel(e.target,["bc-tc","bc-tl","bc-tr"]);n.classes.toggle("tooltip-n","bc-tc"==i),n.classes.toggle("tooltip-nw","bc-tl"==i),n.classes.toggle("tooltip-ne","bc-tr"==i),n.moveRel(e.target,i)}})},statusLevel:function(e){return arguments.length>0&&this.state.set("statusLevel",e),this.state.get("statusLevel")},statusMessage:function(e){return arguments.length>0&&this.state.set("statusMessage",e),this.state.get("statusMessage")},showMenu:function(){var e=this,n=e.settings,r;e.menu||(r=n.menu||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",e.menu=t.create(r).parent(e).renderTo(e.getContainerElm()),e.fire("createmenu"),e.menu.reflow(),e.menu.on("cancel",function(t){t.control===e.menu&&e.focus()}),e.menu.on("show hide",function(t){t.control.items().each(function(t){t.active(t.value()==e.value())})}).fire("show"),e.menu.on("select",function(t){e.value(t.control.value())}),e.on("focusin",function(t){"INPUT"==t.target.tagName.toUpperCase()&&e.menu.hide()}),e.aria("expanded",!0)),e.menu.show(),e.menu.layoutRect({w:e.layoutRect().w}),e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},focus:function(){this.getEl("inp").focus()},repaint:function(){var e=this,t=e.getEl(),i=e.getEl("open"),o=e.layoutRect(),a,s,l=0,u=t.firstChild;e.statusLevel()&&"none"!==e.statusLevel()&&(l=parseInt(n.getRuntimeStyle(u,"padding-right"),10)-parseInt(n.getRuntimeStyle(u,"padding-left"),10)),a=i?o.w-n.getSize(i).width-10:o.w-10;var c=document;return c.all&&(!c.documentMode||c.documentMode<=8)&&(s=e.layoutRect().h-2+"px"),r(u).css({width:a-l,lineHeight:s}),e._super(),e},postRender:function(){var e=this;return r(this.getEl("inp")).on("change",function(t){e.state.set("value",t.target.value),e.fire("change",t)}),e._super()},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.classPrefix,i=e.state.get("value")||"",o,a,s="",l="",u="";return"spellcheck"in n&&(l+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(l+=' maxlength="'+n.maxLength+'"'),n.size&&(l+=' size="'+n.size+'"'),n.subtype&&(l+=' type="'+n.subtype+'"'),u='',e.disabled()&&(l+=' disabled="disabled"'),o=n.icon,o&&"caret"!=o&&(o=r+"ico "+r+"i-"+n.icon),a=e.state.get("text"),(o||a)&&(s='
    ",e.classes.add("has-open")),'
    '+u+s+"
    "},value:function(e){return arguments.length?(this.state.set("value",e),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value), +this.state.get("value"))},showAutoComplete:function(e,n){var r=this;if(0===e.length)return void r.hideMenu();var i=function(e,t){return function(){r.fire("selectitem",{title:t,value:e})}};r.menu?r.menu.items().remove():r.menu=t.create({type:"menu",classes:"combobox-menu",layout:"flow"}).parent(r).renderTo(),o.each(e,function(e){r.menu.add({text:e.title,url:e.previewUrl,match:n,classes:"menu-item-ellipsis",onclick:i(e.value,e.title)})}),r.menu.renderNew(),r.hideMenu(),r.menu.on("cancel",function(e){e.control.parent()===r.menu&&(e.stopPropagation(),r.focus(),r.hideMenu())}),r.menu.on("select",function(){r.focus()});var a=r.layoutRect().w;r.menu.layoutRect({w:a,minW:0,maxW:a}),r.menu.reflow(),r.menu.show(),r.menu.moveRel(r.getEl(),r.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},hideMenu:function(){this.menu&&this.menu.hide()},bindStates:function(){var e=this;e.state.on("change:value",function(t){e.getEl("inp").value!=t.value&&(e.getEl("inp").value=t.value)}),e.state.on("change:disabled",function(t){e.getEl("inp").disabled=t.value}),e.state.on("change:statusLevel",function(t){var r=e.getEl("status"),i=e.classPrefix,o=t.value;n.css(r,"display","none"===o?"none":""),n.toggleClass(r,i+"i-checkmark","ok"===o),n.toggleClass(r,i+"i-warning","warn"===o),n.toggleClass(r,i+"i-error","error"===o),e.classes.toggle("has-status","none"!==o),e.repaint()}),n.on(e.getEl("status"),"mouseleave",function(){e.tooltip().hide()}),e.on("cancel",function(t){e.menu&&e.menu.visible()&&(t.stopPropagation(),e.hideMenu())});var t=function(e,t){t&&t.items().length>0&&t.items().eq(e)[0].focus()};return e.on("keydown",function(n){var r=n.keyCode;"INPUT"===n.target.nodeName&&(r===i.DOWN?(n.preventDefault(),e.fire("autocomplete"),t(0,e.menu)):r===i.UP&&(n.preventDefault(),t(-1,e.menu)))}),e._super()},remove:function(){r(this.getEl("inp")).off(),this.menu&&this.menu.remove(),this._super()}})}),r(Et,[wt],function(e){return e.extend({init:function(e){var t=this;e.spellcheck=!1,e.onaction&&(e.icon="none"),t._super(e),t.classes.add("colorbox"),t.on("change keyup postrender",function(){t.repaintColor(t.value())})},repaintColor:function(e){var t=this.getEl("open"),n=t?t.getElementsByTagName("i")[0]:null;if(n)try{n.style.background=e}catch(r){}},bindStates:function(){var e=this;return e.state.on("change:value",function(t){e.state.get("rendered")&&e.repaintColor(t.value)}),e._super()}})}),r(Nt,[bt,Ae],function(e,t){return e.extend({showPanel:function(){var e=this,n=e.settings;if(e.active(!0),e.panel)e.panel.show();else{var r=n.panel;r.type&&(r={layout:"grid",items:r}),r.role=r.role||"dialog",r.popover=!0,r.autohide=!0,r.ariaRoot=!0,e.panel=new t(r).on("hide",function(){e.active(!1)}).on("cancel",function(t){t.stopPropagation(),e.focus(),e.hidePanel()}).parent(e).renderTo(e.getContainerElm()),e.panel.fire("show"),e.panel.reflow()}e.panel.moveRel(e.getEl(),n.popoverAlign||(e.isRtl()?["bc-tr","bc-tc"]:["bc-tl","bc-tc"]))},hidePanel:function(){var e=this;e.panel&&e.panel.hide()},postRender:function(){var e=this;return e.aria("haspopup",!0),e.on("click",function(t){t.control===e&&(e.panel&&e.panel.visible()?e.hidePanel():(e.showPanel(),e.panel.focus(!!t.aria)))}),e._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})}),r(_t,[Nt,w],function(e,t){var n=t.DOM;return e.extend({init:function(e){this._super(e),this.classes.add("colorbutton")},color:function(e){return e?(this._color=e,this.getEl("preview").style.backgroundColor=e,this):this._color},resetColor:function(){return this._color=null,this.getEl("preview").style.backgroundColor=null,this},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.state.get("text"),i=e.settings.icon?n+"ico "+n+"i-"+e.settings.icon:"",o=e.settings.image?" style=\"background-image: url('"+e.settings.image+"')\"":"",a="";return r&&(e.classes.add("btn-has-text"),a=''+e.encode(r)+""),'
    '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(r){r.aria&&"down"==r.aria.key||r.control!=e||n.getParent(r.target,"."+e.classPrefix+"open")||(r.stopImmediatePropagation(),t.call(e,r))}),delete e.settings.onclick,e._super()}})}),r(St,[],function(){function e(e){function i(e,i,o){var a,s,l,u,c,d;return a=0,s=0,l=0,e/=255,i/=255,o/=255,c=t(e,t(i,o)),d=n(e,n(i,o)),c==d?(l=c,{h:0,s:0,v:100*l}):(u=e==c?i-o:o==c?e-i:o-e,a=e==c?3:o==c?1:5,a=60*(a-u/(d-c)),s=(d-c)/d,l=d,{h:r(a),s:r(100*s),v:r(100*l)})}function o(e,i,o){var a,s,l,u;if(e=(parseInt(e,10)||0)%360,i=parseInt(i,10)/100,o=parseInt(o,10)/100,i=n(0,t(i,1)),o=n(0,t(o,1)),0===i)return void(d=f=p=r(255*o));switch(a=e/60,s=o*i,l=s*(1-Math.abs(a%2-1)),u=o-s,Math.floor(a)){case 0:d=s,f=l,p=0;break;case 1:d=l,f=s,p=0;break;case 2:d=0,f=s,p=l;break;case 3:d=0,f=l,p=s;break;case 4:d=l,f=0,p=s;break;case 5:d=s,f=0,p=l;break;default:d=f=p=0}d=r(255*(d+u)),f=r(255*(f+u)),p=r(255*(p+u))}function a(){function e(e){return e=parseInt(e,10).toString(16),e.length>1?e:"0"+e}return"#"+e(d)+e(f)+e(p)}function s(){return{r:d,g:f,b:p}}function l(){return i(d,f,p)}function u(e){var t;return"object"==typeof e?"r"in e?(d=e.r,f=e.g,p=e.b):"v"in e&&o(e.h,e.s,e.v):(t=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(e))?(d=parseInt(t[1],10),f=parseInt(t[2],10),p=parseInt(t[3],10)):(t=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(e))?(d=parseInt(t[1],16),f=parseInt(t[2],16),p=parseInt(t[3],16)):(t=/#([0-F])([0-F])([0-F])/gi.exec(e))&&(d=parseInt(t[1]+t[1],16),f=parseInt(t[2]+t[2],16),p=parseInt(t[3]+t[3],16)),d=d<0?0:d>255?255:d,f=f<0?0:f>255?255:f,p=p<0?0:p>255?255:p,c}var c=this,d=0,f=0,p=0;e&&u(e),c.toRgb=s,c.toHsv=l,c.toHex=a,c.parse=u}var t=Math.min,n=Math.max,r=Math.round;return e}),r(kt,[Pe,_e,ve,St],function(e,t,n,r){return e.extend({Defaults:{classes:"widget colorpicker"},init:function(e){this._super(e)},postRender:function(){function e(e,t){var r=n.getPos(e),i,o;return i=t.pageX-r.x,o=t.pageY-r.y,i=Math.max(0,Math.min(i/e.clientWidth,1)),o=Math.max(0,Math.min(o/e.clientHeight,1)),{x:i,y:o}}function i(e,t){var i=(360-e.h)/360;n.css(d,{top:100*i+"%"}),t||n.css(p,{left:e.s+"%",top:100-e.v+"%"}),f.style.background=new r({s:100,v:100,h:e.h}).toHex(),s.color().parse({s:e.s,v:e.v,h:e.h})}function o(t){var n;n=e(f,t),u.s=100*n.x,u.v=100*(1-n.y),i(u),s.fire("change")}function a(t){var n;n=e(c,t),u=l.toHsv(),u.h=360*(1-n.y),i(u,!0),s.fire("change")}var s=this,l=s.color(),u,c,d,f,p;c=s.getEl("h"),d=s.getEl("hp"),f=s.getEl("sv"),p=s.getEl("svp"),s._repaint=function(){u=l.toHsv(),i(u)},s._super(),s._svdraghelper=new t(s._id+"-sv",{start:o,drag:o}),s._hdraghelper=new t(s._id+"-h",{start:a,drag:a}),s._repaint()},rgb:function(){return this.color().toRgb()},value:function(e){var t=this;return arguments.length?(t.color().parse(e),void(t._rendered&&t._repaint())):t.color().toHex()},color:function(){return this._color||(this._color=new r),this._color},renderHtml:function(){function e(){var e,t,n="",i,a;for(i="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",a=o.split(","),e=0,t=a.length-1;e';return n}var t=this,n=t._id,r=t.classPrefix,i,o="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",a="background: -ms-linear-gradient(top,"+o+");background: linear-gradient(to bottom,"+o+");";return i='
    '+e()+'
    ','
    '+i+"
    "}})}),r(Tt,[Pe],function(e){return e.extend({init:function(e){var t=this;e.delimiter||(e.delimiter="\xbb"),t._super(e),t.classes.add("path"),t.canFocus=!0,t.on("click",function(e){var n,r=e.target;(n=r.getAttribute("data-index"))&&t.fire("select",{value:t.row()[n],index:n})}),t.row(t.settings.row)},focus:function(){var e=this;return e.getEl().firstChild.focus(),e},row:function(e){return arguments.length?(this.state.set("row",e),this):this.state.get("row")},renderHtml:function(){var e=this;return'
    '+e._getDataPathHtml(e.state.get("row"))+"
    "},bindStates:function(){var e=this;return e.state.on("change:row",function(t){e.innerHtml(e._getDataPathHtml(t.value))}),e._super()},_getDataPathHtml:function(e){var t=this,n=e||[],r,i,o="",a=t.classPrefix;for(r=0,i=n.length;r0?'":"")+'
    '+n[r].name+"
    ";return o||(o='
    \xa0
    '),o}})}),r(Rt,[Tt],function(e){return e.extend({postRender:function(){function e(e){if(1===e.nodeType){if("BR"==e.nodeName||e.getAttribute("data-mce-bogus"))return!0;if("bookmark"===e.getAttribute("data-mce-type"))return!0}return!1}var t=this,n=t.settings.editor;return n.settings.elementpath!==!1&&(t.on("select",function(e){n.focus(),n.selection.select(this.row()[e.index].element),n.nodeChanged()}),n.on("nodeChange",function(r){for(var i=[],o=r.parents,a=o.length;a--;)if(1==o[a].nodeType&&!e(o[a])){var s=n.fire("ResolveName",{name:o[a].nodeName.toLowerCase(),target:o[a]});if(s.isDefaultPrevented()||i.push({name:s.name,element:o[a]}),s.isPropagationStopped())break}t.row(i)})),t._super()}})}),r(At,[Ne],function(e){return e.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.classes.add("formitem"),t.preRender(e),'
    '+(e.settings.title?'
    '+e.settings.title+"
    ":"")+'
    '+(e.settings.html||"")+t.renderHtml(e)+"
    "}})}),r(Bt,[Ne,At,m],function(e,t,n){return e.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:20,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var e=this,r=e.items();e.settings.formItemDefaults||(e.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),r.each(function(r){var i,o=r.settings.label;o&&(i=new t(n.extend({items:{type:"label",id:r._id+"-l",text:o,flex:0,forId:r._id,disabled:r.disabled()}},e.settings.formItemDefaults)),i.type="formitem",r.aria("labelledby",r._id+"-l"),"undefined"==typeof r.settings.flex&&(r.settings.flex=1),e.replace(r,i),i.add(r))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var e=this;e._super(),e.fromJSON(e.settings.data)},bindStates:function(){function e(){var e=0,n=[],r,i,o;if(t.settings.labelGapCalc!==!1)for(o="children"==t.settings.labelGapCalc?t.find("formitem"):t.items(),o.filter("formitem").each(function(t){var r=t.items()[0],i=r.getEl().clientWidth;e=i>e?i:e,n.push(r)}),i=t.settings.labelGap||0,r=n.length;r--;)n[r].settings.minWidth=e+i}var t=this;t._super(),t.on("show",e),e()}})}),r(Dt,[Bt],function(e){return e.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.preRender(),t.preRender(e),'
    '+(e.settings.title?''+e.settings.title+"":"")+'
    '+(e.settings.html||"")+t.renderHtml(e)+"
    "}})}),r(Lt,[w,z,h,it,m,_],function(e,t,n,r,i,o){var a=i.trim,s=function(e,t,n,r,i){return{type:e,title:t,url:n,level:r,attach:i}},l=function(e){for(;e=e.parentNode;){var t=e.contentEditable;if(t&&"inherit"!==t)return o.isContentEditableTrue(e)}return!1},u=function(t,n){return e.DOM.select(t,n)},c=function(e){return e.innerText||e.textContent},d=function(e){return e.id?e.id:r.uuid("h")},f=function(e){return e&&"A"===e.nodeName&&(e.id||e.name)},p=function(e){return f(e)&&m(e)},h=function(e){return e&&/^(H[1-6])$/.test(e.nodeName)},m=function(e){return l(e)&&!o.isContentEditableFalse(e)},g=function(e){return h(e)&&m(e)},v=function(e){return h(e)?parseInt(e.nodeName.substr(1),10):0},y=function(e){var t=d(e),n=function(){e.id=t};return s("header",c(e),"#"+t,v(e),n)},b=function(e){var n=e.id||e.name,r=c(e);return s("anchor",r?r:"#"+n,"#"+n,0,t.noop)},C=function(e){return n.map(n.filter(e,g),y)},x=function(e){return n.map(n.filter(e,p),b)},w=function(e){var t=u("h1,h2,h3,h4,h5,h6,a:not([href])",e);return t},E=function(e){return a(e.title).length>0},N=function(e){var t=w(e);return n.filter(C(t).concat(x(t)),E)};return{find:N}}),r(Mt,[wt,m,h,z,I,Lt],function(e,t,n,r,i,o){var a={},s=5,l=function(e){return{title:e.title,value:{title:{raw:e.title},url:e.url,attach:e.attach}}},u=function(e){return t.map(e,l)},c=function(e,t){return{title:e,value:{title:e,url:t,attach:r.noop}}},d=function(e,t){var r=n.find(t,function(t){return t.url===e});return!r},f=function(e,t,n){var r=t in e?e[t]:n;return r===!1?null:r},p=function(e,i,o,s){var l={title:"-"},p=function(e){var a=n.filter(e[o],function(e){return d(e,i)});return t.map(a,function(e){return{title:e,value:{title:e,url:e,attach:r.noop}}})},h=function(e){var t=n.filter(i,function(t){return t.type==e});return u(t)},g=function(){var e=h("anchor"),t=f(s,"anchor_top","#top"),n=f(s,"anchor_bottom","#bottom");return null!==t&&e.unshift(c("",t)),null!==n&&e.push(c("",n)),e},v=function(e){return n.reduce(e,function(e,t){var n=0===e.length||0===t.length;return n?e.concat(t):e.concat(l,t)},[])};return s.typeahead_urls===!1?[]:"file"===o?v([m(e,p(a)),m(e,h("header")),m(e,g())]):m(e,p(a))},h=function(e,t){var r=a[t];/^https?/.test(e)&&(r?n.indexOf(r,e)===-1&&(a[t]=r.slice(0,s).concat(e)):a[t]=[e])},m=function(e,n){var r=e.toLowerCase(),i=t.grep(n,function(e){return e.title.toLowerCase().indexOf(r)!==-1});return 1===i.length&&i[0].title===e?[]:i},g=function(e){var t=e.title;return t.raw?t.raw:t},v=function(e,t,n,r){var i=function(i){var a=o.find(n),s=p(i,a,r,t);e.showAutoComplete(s,i)};e.on("autocomplete",function(){i(e.value())}),e.on("selectitem",function(t){var n=t.value;e.value(n.url);var i=g(n);"image"===r?e.fire("change",{meta:{alt:i,attach:n.attach}}):e.fire("change",{meta:{text:i,attach:n.attach}}),e.focus()}),e.on("click",function(t){0===e.value().length&&"INPUT"===t.target.nodeName&&i("")}),e.on("PostRender",function(){e.getRoot().on("submit",function(t){t.isDefaultPrevented()||h(e.value(),r)})})},y=function(e){var t=e.status,n=e.message;return"valid"===t?{status:"ok",message:n}:"unknown"===t?{status:"warn",message:n}:"invalid"===t?{status:"warn",message:n}:{status:"none",message:""}},b=function(e,t,n){var r=t.filepicker_validator_handler;if(r){var i=function(t){return 0===t.length?void e.statusLevel("none"):void r({url:t,type:n},function(t){var n=y(t);e.statusMessage(n.message),e.statusLevel(n.status)})};e.state.on("change:value",function(e){i(e.value)})}};return e.extend({init:function(e){var n=this,r=tinymce.activeEditor,i=r.settings,o,a,s,l=e.filetype;e.spellcheck=!1,s=i.file_picker_types||i.file_browser_callback_types,s&&(s=t.makeMap(s,/[, ]/)),s&&!s[l]||(a=i.file_picker_callback,!a||s&&!s[l]?(a=i.file_browser_callback,!a||s&&!s[l]||(o=function(){a(n.getEl("inp").id,n.value(),l,window)})):o=function(){var e=n.fire("beforecall").meta;e=t.extend({filetype:l},e),a.call(r,function(e,t){n.value(e).fire("change",{meta:t})},n.value(),e)}),o&&(e.icon="browse",e.onaction=o),n._super(e),v(n,i,r.getBody(),l),b(n,i,l)}})}),r(Pt,[yt],function(e){return e.extend({recalc:function(e){var t=e.layoutRect(),n=e.paddingBox;e.items().filter(":visible").each(function(e){e.layoutRect({x:n.left,y:n.top,w:t.innerW-n.right-n.left,h:t.innerH-n.top-n.bottom}),e.recalc&&e.recalc()})}})}),r(Ot,[yt],function(e){return e.extend({recalc:function(e){var t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,g,v=[],y,b,C,x,w,E,N,_,S,k,T,R,A,B,D,L,M,P,O,H,I,F,z=Math.max,U=Math.min;for(r=e.items().filter(":visible"),i=e.layoutRect(),o=e.paddingBox,a=e.settings,f=e.isRtl()?a.direction||"row-reversed":a.direction,s=a.align,l=e.isRtl()?a.pack||"end":a.pack,u=a.spacing||0,"row-reversed"!=f&&"column-reverse"!=f||(r=r.set(r.toArray().reverse()),f=f.split("-")[0]),"column"==f?(S="y",N="h",_="minH",k="maxH",R="innerH",T="top",A="deltaH",B="contentH",O="left",M="w",D="x",L="innerW",P="minW",H="right",I="deltaW",F="contentW"):(S="x",N="w",_="minW",k="maxW",R="innerW",T="left",A="deltaW",B="contentW",O="top",M="h",D="y",L="innerH",P="minH",H="bottom",I="deltaH",F="contentH"),d=i[R]-o[T]-o[T],E=c=0,t=0,n=r.length;t0&&(c+=g,h[k]&&v.push(p),h.flex=g),d-=h[_],y=o[O]+h[P]+o[H],y>E&&(E=y);if(x={},d<0?x[_]=i[_]-d+i[A]:x[_]=i[R]-d+i[A],x[P]=E+i[I],x[B]=i[R]-d,x[F]=E,x.minW=U(x.minW,i.maxW),x.minH=U(x.minH,i.maxH),x.minW=z(x.minW,i.startMinWidth),x.minH=z(x.minH,i.startMinHeight),!i.autoResize||x.minW==i.minW&&x.minH==i.minH){for(C=d/c,t=0,n=v.length;tb?(d-=h[k]-h[_],c-=h.flex,h.flex=0,h.maxFlexSize=b):h.maxFlexSize=0;for(C=d/c,w=o[T],x={},0===c&&("end"==l?w=d+o[T]:"center"==l?(w=Math.round(i[R]/2-(i[R]-d)/2)+o[T],w<0&&(w=o[T])):"justify"==l&&(w=o[T],u=Math.floor(d/(r.length-1)))),x[D]=o[O],t=0,n=r.length;t0&&(y+=h.flex*C),x[N]=y,x[S]=w,p.layoutRect(x),p.recalc&&p.recalc(),w+=y+u}else if(x.w=x.minW,x.h=x.minH,e.layoutRect(x),this.recalc(e),null===e._lastRect){var W=e.parent();W&&(W._lastRect=null,W.recalc())}}})}),r(Ht,[vt],function(e){return e.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(e){e.items().filter(":visible").each(function(e){e.recalc&&e.recalc()})},isNative:function(){return!0}})}),r(It,[w],function(e){var n=function(e,t,n){for(;n!==t;){if(n.style[e])return n.style[e];n=n.parentNode}return""},r=function(e){return/[0-9.]+px$/.test(e)?Math.round(72*parseInt(e,10)/96)+"pt":e},i=function(e){return e.replace(/[\'\"]/g,"").replace(/,\s+/g,",")},o=function(t,n){return e.DOM.getStyle(n,t,!0)},a=function(e,t){var r=n("fontSize",e,t);return""!==r?r:o("fontSize",t)},s=function(e,r){var a=n("fontFamily",e,r),s=""!==a?a:o("fontFamily",r);return s!==t?i(s):""};return{getFontSize:a,getFontFamily:s,toPt:r}}),r(Ft,[xe,Pe,Ae,m,h,w,ut,d,It],function(e,t,n,r,i,o,a,s,l){function u(e){e.settings.ui_container&&(s.container=o.DOM.select(e.settings.ui_container)[0])}function c(t){t.on("ScriptsLoaded",function(){t.rtl&&(e.rtl=!0)})}function d(e){function t(t,n){return function(){var r=this;e.on("nodeChange",function(i){var o=e.formatter,a=null;f(i.parents,function(e){if(f(t,function(t){if(n?o.matchNode(e,n,{value:t.value})&&(a=t.value):o.matchNode(e,t.value)&&(a=t.value),a)return!1}),a)return!1}),r.value(a)})}}function i(t){return function(){var n=this,r=function(e){return e?e.split(",")[0]:""};e.on("nodeChange",function(i){var o,a=null;o=l.getFontFamily(e.getBody(),i.element),f(t,function(e){e.value.toLowerCase()===o.toLowerCase()&&(a=e.value)}),f(t,function(e){a||r(e.value).toLowerCase()!==r(o).toLowerCase()||(a=e.value)}),n.value(a),!a&&o&&n.text(r(o))})}}function o(t){return function(){var n=this;e.on("nodeChange",function(r){var i,o,a=null;i=l.getFontSize(e.getBody(),r.element),o=l.toPt(i),f(t,function(e){e.value===i?a=i:e.value===o&&(a=o)}),n.value(a),a||n.text(o)})}}function a(e){e=e.replace(/;$/,"").split(";");for(var t=e.length;t--;)e[t]=e[t].split("=");return e}function s(){function t(e){var n=[];if(e)return f(e,function(e){var o={text:e.title,icon:e.icon};if(e.items)o.menu=t(e.items);else{var a=e.format||"custom"+r++;e.format||(e.name=a,i.push(e)),o.format=a,o.cmd=e.cmd}n.push(o)}),n}function n(){var n;return n=t(e.settings.style_formats_merge?e.settings.style_formats?o.concat(e.settings.style_formats):o:e.settings.style_formats||o)}var r=0,i=[],o=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}];return e.on("init",function(){f(i,function(t){e.formatter.register(t.name,t)})}),{type:"menu",items:n(),onPostRender:function(t){e.fire("renderFormatsMenu",{control:t.control})},itemDefaults:{preview:!0,textStyle:function(){if(this.settings.format)return e.formatter.getCssText(this.settings.format)},onPostRender:function(){var t=this;t.parent().on("show",function(){var n,r;n=t.settings.format,n&&(t.disabled(!e.formatter.canApply(n)),t.active(e.formatter.match(n))),r=t.settings.cmd,r&&t.active(e.queryCommandState(r))})},onclick:function(){this.settings.format&&h(this.settings.format),this.settings.cmd&&e.execCommand(this.settings.cmd)}}}}function u(t){return function(){var n=this;e.formatter?e.formatter.formatChanged(t,function(e){n.active(e)}):e.on("init",function(){e.formatter.formatChanged(t,function(e){n.active(e)})})}}function c(t){return function(){function n(){var n="redo"==t?"hasRedo":"hasUndo";return!!e.undoManager&&e.undoManager[n]()}var r=this;r.disabled(!n()),e.on("Undo Redo AddUndo TypingUndo ClearUndos SwitchMode",function(){r.disabled(e.readonly||!n())})}}function d(){var t=this;e.on("VisualAid",function(e){t.active(e.hasVisual)}),t.active(e.hasVisual)}function h(t){t.control&&(t=t.control.value()),t&&e.execCommand("mceToggleFormat",!1,t)}function m(t){var n=t.length;return r.each(t,function(t){t.menu&&(t.hidden=0===m(t.menu));var r=t.format;r&&(t.hidden=!e.formatter.canApply(r)),t.hidden&&n--}),n}function g(t){var n=t.items().length;return t.items().each(function(t){t.menu&&t.visible(g(t.menu)>0),!t.menu&&t.settings.menu&&t.visible(m(t.settings.menu)>0);var r=t.settings.format;r&&t.visible(e.formatter.canApply(r)),t.visible()||n--}),n}var v;v=s(),f({bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript"},function(t,n){e.addButton(n,{tooltip:t,onPostRender:u(n),onclick:function(){h(n)}})}),f({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),f({blockquote:["Blockquote","mceBlockQuote"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"],alignnone:["No alignment","JustifyNone"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:u(n)})});var y=function(e){var t=e;return t.length>0&&"-"===t[0].text&&(t=t.slice(1)),t.length>0&&"-"===t[t.length-1].text&&(t=t.slice(0,t.length-1)),t},b=function(t){var n,i;if("string"==typeof t)i=t.split(" ");else if(r.isArray(t))return p(r.map(t,b));return n=r.grep(i,function(t){return"|"===t||t in e.menuItems}),r.map(n,function(t){return"|"===t?{text:"-"}:e.menuItems[t]})},C=function(t){var n=[{text:"-"}],i=r.grep(e.menuItems,function(e){return e.context===t});return r.each(i,function(e){"before"==e.separator&&n.push({text:"|"}),e.prependToContext?n.unshift(e):n.push(e),"after"==e.separator&&n.push({text:"|"})}),n},x=function(e){return y(e.insert_button_items?b(e.insert_button_items):C("insert"))};e.addButton("undo",{tooltip:"Undo",onPostRender:c("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:c("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:c("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:c("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:d,cmd:"mceToggleVisualAid"}),e.addButton("remove",{tooltip:"Remove",icon:"remove",cmd:"Delete"}),e.addButton("insert",{type:"menubutton",icon:"insert",menu:[],oncreatemenu:function(){this.menu.add(x(e.settings)),this.menu.renderNew()}}),f({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline","Meta+U"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:v,onShowMenu:function(){e.settings.style_formats_autohide&&g(this.menu)}}),e.addButton("formatselect",function(){var n=[],r=a(e.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return f(r,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:r[0][0],values:n,fixedWidth:!0,onselect:h,onPostRender:t(n)}}),e.addButton("fontselect",function(){var t="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",n=[],r=a(e.settings.font_formats||t);return f(r,function(e){n.push({text:{raw:e[0]},value:e[1],textStyle:e[1].indexOf("dings")==-1?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:n,fixedWidth:!0,onPostRender:i(n),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var t=[],n="8pt 10pt 12pt 14pt 18pt 24pt 36pt",r=e.settings.fontsize_formats||n;return f(r.split(" "),function(e){var n=e,r=e,i=e.split("=");i.length>1&&(n=i[0],r=i[1]),t.push({text:n,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:t,fixedWidth:!0,onPostRender:o(t),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:v})}var f=r.each,p=function(e){return i.reduce(e,function(e,t){return e.concat(t)},[])};a.on("AddEditor",function(e){var t=e.editor;c(t),d(t),u(t)}),e.translate=function(e){return a.translate(e)},t.tooltips=!s.iOS}),r(zt,[yt],function(e){return e.extend({recalc:function(e){var t,n,r,i,o,a,s,l,u,c,d,f,p,h,m,g,v,y,b,C,x,w,E,N=[],_=[],S,k,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e.paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;dN[d]?S:N[d],_[f]=k>_[f]?k:_[f];for(T=o.innerW-g.left-g.right,w=0,d=0;d0?y:0),T-=(d>0?y:0)+N[d];for(R=o.innerH-g.top-g.bottom,E=0,f=0;f0?b:0),R-=(f>0?b:0)+_[f];if(w+=g.left+g.right,E+=g.top+g.bottom,l={},l.minW=w+(o.w-o.innerW),l.minH=E+(o.h-o.innerH),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH,l.minW=Math.min(l.minW,o.maxW),l.minH=Math.min(l.minH,o.maxH),l.minW=Math.max(l.minW,o.startMinWidth),l.minH=Math.max(l.minH,o.startMinHeight),!o.autoResize||l.minW==o.minW&&l.minH==o.minH){o.autoResize&&(l=e.layoutRect(l),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH);var D;D="start"==t.packV?0:R>0?Math.floor(R/n):0;var L=0,M=t.flexWidths;if(M)for(d=0;d'},src:function(e){this.getEl().src=e},html:function(e,n){var r=this,i=this.getEl().contentWindow.document.body;return i?(i.innerHTML=e,n&&n()):t.setTimeout(function(){r.html(e)}),this}})}),r(Wt,[Pe],function(e){return e.extend({init:function(e){var t=this;t._super(e),t.classes.add("widget").add("infobox"),t.canFocus=!1},severity:function(e){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(e)},help:function(e){this.state.set("help",e)},renderHtml:function(){var e=this,t=e.classPrefix;return'
    '+e.encode(e.state.get("text"))+'
    '},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl("body").firstChild.data=e.encode(t.value),e.state.get("rendered")&&e.updateLayoutRect()}),e.state.on("change:help",function(t){ +e.classes.toggle("has-help",t.value),e.state.get("rendered")&&e.updateLayoutRect()}),e._super()}})}),r(Vt,[Pe,ve],function(e,t){return e.extend({init:function(e){var t=this;t._super(e),t.classes.add("widget").add("label"),t.canFocus=!1,e.multiline&&t.classes.add("autoscroll"),e.strong&&t.classes.add("strong")},initLayoutRect:function(){var e=this,n=e._super();if(e.settings.multiline){var r=t.getSize(e.getEl());r.width>n.maxW&&(n.minW=n.maxW,e.classes.add("multiline")),e.getEl().style.width=n.minW+"px",n.startMinH=n.h=n.minH=Math.min(n.maxH,t.getSize(e.getEl()).height)}return n},repaint:function(){var e=this;return e.settings.multiline||(e.getEl().style.lineHeight=e.layoutRect().h+"px"),e._super()},severity:function(e){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(e)},renderHtml:function(){var e=this,t,n,r=e.settings.forId;return!r&&(n=e.settings.forName)&&(t=e.getRoot().find("#"+n)[0],t&&(r=t._id)),r?'":''+e.encode(e.state.get("text"))+""},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.innerHtml(e.encode(t.value)),e.state.get("rendered")&&e.updateLayoutRect()}),e._super()}})}),r($t,[Ne],function(e){return e.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(e){var t=this;t._super(e),t.classes.add("toolbar")},postRender:function(){var e=this;return e.items().each(function(e){e.classes.add("toolbar-item")}),e._super()}})}),r(qt,[$t],function(e){return e.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})}),r(jt,[bt,we,qt],function(e,t,n){function r(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1}var i=e.extend({init:function(e){var t=this;t._renderOpen=!0,t._super(e),e=t.settings,t.classes.add("menubtn"),e.fixedWidth&&t.classes.add("fixed-width"),t.aria("haspopup",!0),t.state.set("menu",e.menu||t.render())},showMenu:function(e){var n=this,r;return n.menu&&n.menu.visible()&&e!==!1?n.hideMenu():(n.menu||(r=n.state.get("menu")||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",r.renderTo?n.menu=r.parent(n).show().renderTo():n.menu=t.create(r).parent(n).renderTo(),n.fire("createmenu"),n.menu.reflow(),n.menu.on("cancel",function(e){e.control.parent()===n.menu&&(e.stopPropagation(),n.focus(),n.hideMenu())}),n.menu.on("select",function(){n.focus()}),n.menu.on("show hide",function(e){e.control==n.menu&&n.activeMenu("show"==e.type),n.aria("expanded","show"==e.type)}).fire("show")),n.menu.show(),n.menu.layoutRect({w:n.layoutRect().w}),n.menu.moveRel(n.getEl(),n.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]),void n.fire("showmenu"))},hideMenu:function(){var e=this;e.menu&&(e.menu.items().each(function(e){e.hideMenu&&e.hideMenu()}),e.menu.hide())},activeMenu:function(e){this.classes.toggle("active",e)},renderHtml:function(){var e=this,t=e._id,r=e.classPrefix,i=e.settings.icon,o,a=e.state.get("text"),s="";return o=e.settings.image,o?(i="none","string"!=typeof o&&(o=window.getSelection?o[0]:o[1]),o=" style=\"background-image: url('"+o+"')\""):o="",a&&(e.classes.add("btn-has-text"),s=''+e.encode(a)+""),i=e.settings.icon?r+"ico "+r+"i-"+i:"",e.aria("role",e.parent()instanceof n?"menuitem":"button"),'
    '},postRender:function(){var e=this;return e.on("click",function(t){t.control===e&&r(t.target,e.getEl())&&(e.focus(),e.showMenu(!t.aria),t.aria&&e.menu.items().filter(":visible")[0].focus())}),e.on("mouseenter",function(t){var n=t.control,r=e.parent(),o;n&&r&&n instanceof i&&n.parent()==r&&(r.items().filter("MenuButton").each(function(e){e.hideMenu&&e!=n&&(e.menu&&e.menu.visible()&&(o=!0),e.hideMenu())}),o&&(n.focus(),n.showMenu()))}),e._super()},bindStates:function(){var e=this;return e.state.on("change:menu",function(){e.menu&&e.menu.remove(),e.menu=null}),e._super()},remove:function(){this._super(),this.menu&&this.menu.remove()}});return i}),r(Yt,[Pe,we,d,c],function(e,t,n,r){return e.extend({Defaults:{border:0,role:"menuitem"},init:function(e){var t=this,n;t._super(e),e=t.settings,t.classes.add("menu-item"),e.menu&&t.classes.add("menu-item-expand"),e.preview&&t.classes.add("menu-item-preview"),n=t.state.get("text"),"-"!==n&&"|"!==n||(t.classes.add("menu-item-sep"),t.aria("role","separator"),t.state.set("text","-")),e.selectable&&(t.aria("role","menuitemcheckbox"),t.classes.add("menu-item-checkbox"),e.icon="selected"),e.preview||e.selectable||t.classes.add("menu-item-normal"),t.on("mousedown",function(e){e.preventDefault()}),e.menu&&!e.ariaHideMenu&&t.aria("haspopup",!0)},hasMenus:function(){return!!this.settings.menu},showMenu:function(){var e=this,n=e.settings,r,i=e.parent();if(i.items().each(function(t){t!==e&&t.hideMenu()}),n.menu){r=e.menu,r?r.show():(r=n.menu,r.length?r={type:"menu",items:r}:r.type=r.type||"menu",i.settings.itemDefaults&&(r.itemDefaults=i.settings.itemDefaults),r=e.menu=t.create(r).parent(e).renderTo(),r.reflow(),r.on("cancel",function(t){t.stopPropagation(),e.focus(),r.hide()}),r.on("show hide",function(e){e.control.items&&e.control.items().each(function(e){e.active(e.settings.selected)})}).fire("show"),r.on("hide",function(t){t.control===r&&e.classes.remove("selected")}),r.submenu=!0),r._parentMenu=i,r.classes.add("menu-sub");var o=r.testMoveRel(e.getEl(),e.isRtl()?["tl-tr","bl-br","tr-tl","br-bl"]:["tr-tl","br-bl","tl-tr","bl-br"]);r.moveRel(e.getEl(),o),r.rel=o,o="menu-sub-"+o,r.classes.remove(r._lastRel).add(o),r._lastRel=o,e.classes.add("selected"),e.aria("expanded",!0)}},hideMenu:function(){var e=this;return e.menu&&(e.menu.items().each(function(e){e.hideMenu&&e.hideMenu()}),e.menu.hide(),e.aria("expanded",!1)),e},renderHtml:function(){function e(e){var t,r,i={};for(i=n.mac?{alt:"⌥",ctrl:"⌘",shift:"⇧",meta:"⌘"}:{meta:"Ctrl"},e=e.split("+"),t=0;t").replace(new RegExp(t("]mce~match!"),"g"),"")}var o=this,a=o._id,s=o.settings,l=o.classPrefix,u=o.state.get("text"),c=o.settings.icon,d="",f=s.shortcut,p=o.encode(s.url),h="";return c&&o.parent().classes.add("menu-has-icons"),s.image&&(d=" style=\"background-image: url('"+s.image+"')\""),f&&(f=e(f)),c=l+"ico "+l+"i-"+(o.settings.icon||"none"),h="-"!==u?'\xa0":"",u=i(o.encode(r(u))),p=i(o.encode(r(p))),'
    '+h+("-"!==u?''+u+"":"")+(f?'
    '+f+"
    ":"")+(s.menu?'
    ':"")+(p?'":"")+"
    "},postRender:function(){var e=this,t=e.settings,n=t.textStyle;if("function"==typeof n&&(n=n.call(this)),n){var i=e.getEl("text");i&&i.setAttribute("style",n)}return e.on("mouseenter click",function(n){n.control===e&&(t.menu||"click"!==n.type?(e.showMenu(),n.aria&&e.menu.focus(!0)):(e.fire("select"),r.requestAnimationFrame(function(){e.parent().hideAll()})))}),e._super(),e},hover:function(){var e=this;return e.parent().items().each(function(e){e.classes.remove("selected")}),e.classes.toggle("selected",!0),e},active:function(e){return"undefined"!=typeof e&&this.aria("checked",e),this._super(e)},remove:function(){this._super(),this.menu&&this.menu.remove()}})}),r(Xt,[g,xe,c],function(e,t,n){return function(r,i){var o=this,a,s=t.classPrefix,l;o.show=function(t,u){function c(){a&&(e(r).append('
    '),u&&u())}return o.hide(),a=!0,t?l=n.setTimeout(c,t):c(),o},o.hide=function(){var e=r.lastChild;return n.clearTimeout(l),e&&e.className.indexOf("throbber")!=-1&&e.parentNode.removeChild(e),a=!1,o}}}),r(Kt,[Ae,Yt,Xt,m],function(e,t,n,r){return e.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(e){var t=this;if(e.autohide=!0,e.constrainToViewport=!0,"function"==typeof e.items&&(e.itemsFactory=e.items,e.items=[]),e.itemDefaults)for(var n=e.items,i=n.length;i--;)n[i]=r.extend({},e.itemDefaults,n[i]);t._super(e),t.classes.add("menu")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var e=this;e.hideAll(),e.fire("select")},load:function(){function e(){t.throbber&&(t.throbber.hide(),t.throbber=null)}var t=this,r,i;i=t.settings.itemsFactory,i&&(t.throbber||(t.throbber=new n(t.getEl("body"),!0),0===t.items().length?(t.throbber.show(),t.fire("loading")):t.throbber.show(100,function(){t.items().remove(),t.fire("loading")}),t.on("hide close",e)),t.requestTime=r=(new Date).getTime(),t.settings.itemsFactory(function(n){return 0===n.length?void t.hide():void(t.requestTime===r&&(t.getEl().style.width="",t.getEl("body").style.width="",e(),t.items().remove(),t.getEl("body").innerHTML="",t.add(n),t.renderNew(),t.fire("loaded")))}))},hideAll:function(){var e=this;return this.find("menuitem").exec("hideMenu"),e._super()},preRender:function(){var e=this;return e.items().each(function(t){var n=t.settings;if(n.icon||n.image||n.selectable)return e._hasIcons=!0,!1}),e.settings.itemsFactory&&e.on("postrender",function(){e.settings.itemsFactory&&e.load()}),e._super()}})}),r(Gt,[jt,Kt],function(e,t){return e.extend({init:function(e){function t(r){for(var a=0;a0&&(o=r[0].text,n.state.set("value",r[0].value)),n.state.set("menu",r)),n.state.set("text",e.text||o),n.classes.add("listbox"),n.on("select",function(t){var r=t.control;a&&(t.lastControl=a),e.multiple?r.active(!r.active()):n.value(t.control.value()),a=r})},bindStates:function(){function e(e,n){e instanceof t&&e.items().each(function(e){e.hasMenus()||e.active(e.value()===n)})}function n(e,t){var r;if(e)for(var i=0;i'},postRender:function(){var e=this;e._super(),e.resizeDragHelper=new t(this._id,{start:function(){e.fire("ResizeStart")},drag:function(t){"both"!=e.settings.direction&&(t.deltaX=0),e.fire("Resize",t)},stop:function(){e.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})}),r(Zt,[Pe],function(e){function t(e){var t="";if(e)for(var n=0;n'+e[n]+"";return t}return e.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(e){var t=this;t._super(e),t.settings.size&&(t.size=t.settings.size),t.settings.options&&(t._options=t.settings.options),t.on("keydown",function(e){var n;13==e.keyCode&&(e.preventDefault(),t.parents().reverse().each(function(e){if(e.toJSON)return n=e,!1}),t.fire("submit",{data:n.toJSON()}))})},options:function(e){return arguments.length?(this.state.set("options",e),this):this.state.get("options")},renderHtml:function(){var e=this,n,r="";return n=t(e._options),e.size&&(r=' size = "'+e.size+'"'),'"},bindStates:function(){var e=this;return e.state.on("change:options",function(n){e.getEl().innerHTML=t(n.value)}),e._super()}})}),r(en,[Pe,_e,ve],function(e,t,n){function r(e,t,n){return en&&(e=n),e}function i(e,t,n){e.setAttribute("aria-"+t,n)}function o(e,t){var r,o,a,s,l,u;"v"==e.settings.orientation?(s="top",a="height",o="h"):(s="left",a="width",o="w"),u=e.getEl("handle"),r=(e.layoutRect()[o]||100)-n.getSize(u)[a],l=r*((t-e._minValue)/(e._maxValue-e._minValue))+"px",u.style[s]=l,u.style.height=e.layoutRect().h+"px",i(u,"valuenow",t),i(u,"valuetext",""+e.settings.previewFilter(t)),i(u,"valuemin",e._minValue),i(u,"valuemax",e._maxValue)}return e.extend({init:function(e){var t=this;e.previewFilter||(e.previewFilter=function(e){return Math.round(100*e)/100}),t._super(e),t.classes.add("slider"),"v"==e.orientation&&t.classes.add("vertical"),t._minValue=e.minValue||0,t._maxValue=e.maxValue||100,t._initValue=t.state.get("value")},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix;return'
    '},reset:function(){this.value(this._initValue).repaint()},postRender:function(){function e(e,t,n){return(n+e)/(t-e)}function i(e,t,n){return n*(t-e)-e}function o(t,n){function o(o){var a;a=s.value(),a=i(t,n,e(t,n,a)+.05*o),a=r(a,t,n),s.value(a),s.fire("dragstart",{value:a}),s.fire("drag",{value:a}),s.fire("dragend",{value:a})}s.on("keydown",function(e){switch(e.keyCode){case 37:case 38:o(-1);break;case 39:case 40:o(1)}})}function a(e,i,o){var a,l,u,h,m;s._dragHelper=new t(s._id,{handle:s._id+"-handle",start:function(e){a=e[c],l=parseInt(s.getEl("handle").style[d],10),u=(s.layoutRect()[p]||100)-n.getSize(o)[f],s.fire("dragstart",{value:m})},drag:function(t){var n=t[c]-a;h=r(l+n,0,u),o.style[d]=h+"px",m=e+h/u*(i-e),s.value(m),s.tooltip().text(""+s.settings.previewFilter(m)).show().moveRel(o,"bc tc"),s.fire("drag",{value:m})},stop:function(){s.tooltip().hide(),s.fire("dragend",{value:m})}})}var s=this,l,u,c,d,f,p;l=s._minValue,u=s._maxValue,"v"==s.settings.orientation?(c="screenY",d="top",f="height",p="h"):(c="screenX",d="left",f="width",p="w"),s._super(),o(l,u,s.getEl("handle")),a(l,u,s.getEl("handle"))},repaint:function(){this._super(),o(this,this.value())},bindStates:function(){var e=this;return e.state.on("change:value",function(t){o(e,t.value)}),e._super()}})}),r(tn,[Pe],function(e){return e.extend({renderHtml:function(){var e=this;return e.classes.add("spacer"),e.canFocus=!1,'
    '}})}),r(nn,[jt,ve,g],function(e,t,n){return e.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var e=this,r=e.getEl(),i=e.layoutRect(),o,a;return e._super(),o=r.firstChild,a=r.lastChild,n(o).css({width:i.w-t.getSize(a).width,height:i.h-2}),n(a).css({height:i.h-2}),e},activeMenu:function(e){var t=this;n(t.getEl().lastChild).toggleClass(t.classPrefix+"active",e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r,i=e.state.get("icon"),o=e.state.get("text"),a="";return r=e.settings.image,r?(i="none","string"!=typeof r&&(r=window.getSelection?r[0]:r[1]),r=" style=\"background-image: url('"+r+"')\""):r="",i=e.settings.icon?n+"ico "+n+"i-"+i:"",o&&(e.classes.add("btn-has-text"),a=''+e.encode(o)+""),'
    '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(e){var n=e.target;if(e.control==this)for(;n;){if(e.aria&&"down"!=e.aria.key||"BUTTON"==n.nodeName&&n.className.indexOf("open")==-1)return e.stopImmediatePropagation(),void(t&&t.call(this,e));n=n.parentNode}}),delete e.settings.onclick,e._super()}})}),r(rn,[Ht],function(e){return e.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}})}),r(on,[ke,g,ve],function(e,t,n){return e.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(e){var n;this.activeTabId&&(n=this.getEl(this.activeTabId),t(n).removeClass(this.classPrefix+"active"),n.setAttribute("aria-selected","false")),this.activeTabId="t"+e,n=this.getEl("t"+e),n.setAttribute("aria-selected","true"),t(n).addClass(this.classPrefix+"active"),this.items()[e].show().fire("showtab"),this.reflow(),this.items().each(function(t,n){e!=n&&t.hide()})},renderHtml:function(){var e=this,t=e._layout,n="",r=e.classPrefix;return e.preRender(),t.preRender(e),e.items().each(function(t,i){var o=e._id+"-t"+i;t.aria("role","tabpanel"),t.aria("labelledby",o),n+='"}),'
    '+n+'
    '+t.renderHtml(e)+"
    "},postRender:function(){var e=this;e._super(),e.settings.activeTab=e.settings.activeTab||0,e.activateTab(e.settings.activeTab),this.on("click",function(t){var n=t.target.parentNode;if(n&&n.id==e._id+"-head")for(var r=n.childNodes.length;r--;)n.childNodes[r]==t.target&&e.activateTab(r)})},initLayoutRect:function(){var e=this,t,r,i;r=n.getSize(e.getEl("head")).width,r=r<0?0:r,i=0,e.items().each(function(e){r=Math.max(r,e.layoutRect().minW),i=Math.max(i,e.layoutRect().minH)}),e.items().each(function(e){e.settings.x=0,e.settings.y=0,e.settings.w=r,e.settings.h=i,e.layoutRect({x:0,y:0,w:r,h:i})});var o=n.getSize(e.getEl("head")).height;return e.settings.minWidth=r,e.settings.minHeight=i+o,t=e._super(),t.deltaH+=o,t.innerH=t.h-t.deltaH,t}})}),r(an,[Pe,m,ve],function(e,t,n){return e.extend({init:function(e){var t=this;t._super(e),t.classes.add("textbox"),e.multiline?t.classes.add("multiline"):(t.on("keydown",function(e){var n;13==e.keyCode&&(e.preventDefault(),t.parents().reverse().each(function(e){if(e.toJSON)return n=e,!1}),t.fire("submit",{data:n.toJSON()}))}),t.on("keyup",function(e){t.state.set("value",e.target.value)}))},repaint:function(){var e=this,t,n,r,i,o=0,a;t=e.getEl().style,n=e._layoutRect,a=e._lastRepaintRect||{};var s=document;return!e.settings.multiline&&s.all&&(!s.documentMode||s.documentMode<=8)&&(t.lineHeight=n.h-o+"px"),r=e.borderBox,i=r.left+r.right+8,o=r.top+r.bottom+(e.settings.multiline?8:0),n.x!==a.x&&(t.left=n.x+"px",a.x=n.x),n.y!==a.y&&(t.top=n.y+"px",a.y=n.y),n.w!==a.w&&(t.width=n.w-i+"px",a.w=n.w),n.h!==a.h&&(t.height=n.h-o+"px",a.h=n.h),e._lastRepaintRect=a,e.fire("repaint",{},!1),e},renderHtml:function(){var e=this,r=e.settings,i,o;return i={id:e._id,hidefocus:"1"},t.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(e){i[e]=r[e]}),e.disabled()&&(i.disabled="disabled"),r.subtype&&(i.type=r.subtype),o=n.create(r.multiline?"textarea":"input",i),o.value=e.state.get("value"),o.className=e.classes,o.outerHTML},value:function(e){return arguments.length?(this.state.set("value",e),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var e=this;e.getEl().value=e.state.get("value"),e._super(),e.$el.on("change",function(t){e.state.set("value",t.target.value),e.fire("change",t)})},bindStates:function(){var e=this;return e.state.on("change:value",function(t){e.getEl().value!=t.value&&(e.getEl().value=t.value)}),e.state.on("change:disabled",function(t){e.getEl().disabled=t.value}),e._super()},remove:function(){this.$el.off(),this._super()}})}),r(sn,[],function(){var e=this||window,t=function(){return e.tinymce};return"function"==typeof e.define&&(e.define.amd||e.define("ephox/tinymce",[],t)),"object"==typeof module&&(module.exports=window.tinymce),{}}),a([l,u,c,d,f,p,m,g,v,y,C,w,E,N,T,A,B,D,L,M,P,O,I,F,j,Y,J,te,le,ue,ce,de,pe,me,ge,Ce,xe,we,Ee,Ne,_e,Se,ke,Te,Re,Ae,Be,De,Le,Me,Pe,Oe,He,Ie,Ue,Ve,at,st,lt,ut,dt,ft,pt,ht,mt,gt,vt,yt,bt,Ct,xt,wt,Et,Nt,_t,St,kt,Tt,Rt,At,Bt,Dt,Mt,Pt,Ot,Ht,Ft,zt,Ut,Wt,Vt,$t,qt,jt,Yt,Xt,Kt,Gt,Jt,Qt,Zt,en,tn,nn,rn,on,an])}(window); +/** + * simplemde v1.11.2 + * Copyright Next Step Webs, Inc. + * @link https://github.com/NextStepWebs/simplemde-markdown-editor + * @license MIT + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.SimpleMDE=e()}}(function(){var e;return function t(e,n,r){function i(a,l){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!l&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;at;++t)s[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(e){var t,n,r,i,o,a,l=e.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[l-2]?2:"="===e[l-1]?1:0,a=new u(3*l/4-o),r=o>0?l-4:l;var s=0;for(t=0,n=0;r>t;t+=4,n+=3)i=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],a[s++]=i>>16&255,a[s++]=i>>8&255,a[s++]=255&i;return 2===o?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,a[s++]=255&i):1===o&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,a[s++]=i>>8&255,a[s++]=255&i),a}function o(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function a(e,t,n){for(var r,i=[],a=t;n>a;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(o(r));return i.join("")}function l(e){for(var t,n=e.length,r=n%3,i="",o=[],l=16383,c=0,u=n-r;u>c;c+=l)o.push(a(e,c,c+l>u?u:c+l));return 1===r?(t=e[n-1],i+=s[t>>2],i+=s[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+="="),o.push(i),o.join("")}n.toByteArray=i,n.fromByteArray=l;var s=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},{}],2:[function(e,t,n){},{}],3:[function(e,t,n){(function(t){"use strict";function r(){try{var e=new Uint8Array(1);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(i()=t?o(e,t):void 0!==n?"string"==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function u(e,t){if(s(t),e=o(e,0>t?0:0|m(t)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;t>n;n++)e[n]=0;return e}function f(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|v(t,n);return e=o(e,r),e.write(t,n),e}function h(e,t){var n=0|m(t.length);e=o(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t,n,r){if(t.byteLength,0>n||t.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,t>=n)return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return N(this,t,n);case"ascii":return E(this,t,n);case"binary":return O(this,t,n);case"base64":return M(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function x(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function b(e,t,n,r){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,l=t.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}for(var s=-1,c=0;a>n+c;c++)if(i(e,n+c)===i(t,-1===s?0:c-s)){if(-1===s&&(s=c),c-s+1===l)return(n+s)*o}else-1!==s&&(c-=c-s),s=-1;return-1}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;r>a;a++){var l=parseInt(t.substr(2*a,2),16);if(isNaN(l))return a;e[n+a]=l}return a}function k(e,t,n,r){return V(q(t,e.length-n),e,n,r)}function S(e,t,n,r){return V(G(t),e,n,r)}function C(e,t,n,r){return S(e,t,n,r)}function L(e,t,n,r){return V($(t),e,n,r)}function T(e,t,n,r){return V(Y(t,e.length-n),e,n,r)}function M(e,t,n){return 0===t&&n===e.length?X.fromByteArray(e):X.fromByteArray(e.slice(t,n))}function N(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],a=null,l=o>239?4:o>223?3:o>191?2:1;if(n>=i+l){var s,c,u,f;switch(l){case 1:128>o&&(a=o);break;case 2:s=e[i+1],128===(192&s)&&(f=(31&o)<<6|63&s,f>127&&(a=f));break;case 3:s=e[i+1],c=e[i+2],128===(192&s)&&128===(192&c)&&(f=(15&o)<<12|(63&s)<<6|63&c,f>2047&&(55296>f||f>57343)&&(a=f));break;case 4:s=e[i+1],c=e[i+2],u=e[i+3],128===(192&s)&&128===(192&c)&&128===(192&u)&&(f=(15&o)<<18|(63&s)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(a=f))}}null===a?(a=65533,l=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),i+=l}return A(r)}function A(e){var t=e.length;if(Q>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Q));return n}function E(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function O(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=U(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,r,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||o>t)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function H(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function W(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function B(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function _(e,t,n,r,i){return i||B(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||B(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(e,t,n,r,52,8),n+8}function z(e){if(e=j(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function j(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function U(e){return 16>e?"0"+e.toString(16):e.toString(16)}function q(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],a=0;r>a;a++){if(n=e.charCodeAt(a),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function G(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function $(e){return X.toByteArray(z(e))}function V(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}function K(e){return e!==e}var X=e("base64-js"),Z=e("ieee754"),J=e("isarray");n.Buffer=a,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=i(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,n){return l(null,e,t,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(e,t,n){return c(null,e,t,n)},a.allocUnsafe=function(e){return u(null,e)},a.allocUnsafeSlow=function(e){return u(null,e)},a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);o>i;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return r>n?-1:n>r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!J(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;nt;t+=2)x(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;e>t;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?N(this,0,e):y.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e,t,n,r,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),0>t||n>e.length||0>r||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var o=i-r,l=n-t,s=Math.min(o,l),c=this.slice(r,i),u=e.slice(t,n),f=0;s>f;++f)if(c[f]!==u[f]){o=c[f],l=u[f];break}return l>o?-1:o>l?1:0},a.prototype.indexOf=function(e,t,n){if("string"==typeof t?(n=t,t=0):t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(this,e,t,n);if("number"==typeof e)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):b(this,[e],t,n);throw new TypeError("val must be string, number or Buffer")},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return S(this,e,t,n);case"binary":return C(this,e,t,n);case"base64":return L(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;a.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var r;if(a.TYPED_ARRAY_SUPPORT)r=this.subarray(e,t),r.__proto__=a.prototype;else{var i=t-e;r=new a(i,void 0);for(var o=0;i>o;o++)r[o]=this[o+e]}return r},a.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},a.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),Z.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),Z.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),Z.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),Z.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t=0|t,n=0|n,!r){var i=Math.pow(2,8*n)-1;D(this,e,t,n,i,0)}var o=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+o]=e/a&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):H(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):H(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):W(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):W(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);D(this,e,t,n,i-1,-i)}var o=0,a=1,l=0;for(this[t]=255&e;++oe&&0===l&&0!==this[t+o-1]&&(l=1),this[t+o]=(e/a>>0)-l&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);D(this,e,t,n,i-1,-i)}var o=n-1,a=1,l=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)0>e&&0===l&&0!==this[t+o+1]&&(l=1),this[t+o]=(e/a>>0)-l&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):H(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):H(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):W(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):W(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,n){return _(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return _(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-tn&&r>t)for(i=o-1;i>=0;i--)e[i+t]=this[i+n];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);256>i&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e=255&e);if(0>t||this.length=n)return this;t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;n>o;o++)this[o]=e;else{var l=a.isBuffer(e)?e:q(new a(e,r).toString()),s=l.length;for(o=0;n-t>o;o++)this[o+t]=l[o%s]}return this};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:15,isarray:16}],4:[function(e,t,n){"use strict";function r(e){return e=e||{},"function"!=typeof e.codeMirrorInstance||"function"!=typeof e.codeMirrorInstance.defineMode?void console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`"):(String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}),void e.codeMirrorInstance.defineMode("spell-checker",function(t){if(!r.aff_loading){r.aff_loading=!0;var n=new XMLHttpRequest;n.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff",!0),n.onload=function(){4===n.readyState&&200===n.status&&(r.aff_data=n.responseText,r.num_loaded++,2==r.num_loaded&&(r.typo=new i("en_US",r.aff_data,r.dic_data,{platform:"any"})))},n.send(null)}if(!r.dic_loading){r.dic_loading=!0;var o=new XMLHttpRequest;o.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic",!0),o.onload=function(){4===o.readyState&&200===o.status&&(r.dic_data=o.responseText,r.num_loaded++,2==r.num_loaded&&(r.typo=new i("en_US",r.aff_data,r.dic_data,{platform:"any"})))},o.send(null)}var a='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ',l={token:function(e){var t=e.peek(),n="";if(a.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!a.includes(t);)n+=t,e.next();return r.typo&&!r.typo.check(n)?"spell-error":null}},s=e.codeMirrorInstance.getMode(t,t.backdrop||"text/plain");return e.codeMirrorInstance.overlayMode(s,l,!0)}))}var i=e("typo-js");r.num_loaded=0,r.aff_loading=!1,r.dic_loading=!1,r.aff_data="",r.dic_data="",r.typo,t.exports=r},{"typo-js":18}],5:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function n(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var n=e.state.fullScreenRestore;t.style.width=n.width,t.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(r,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(r):n(r))})})},{"../../lib/codemirror":10}],6:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){function t(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function n(e){t(e);var n=e.state.placeholder=document.createElement("pre");n.style.cssText="height: 0; overflow: visible",n.className="CodeMirror-placeholder";var r=e.getOption("placeholder");"string"==typeof r&&(r=document.createTextNode(r)),n.appendChild(r),e.display.lineSpace.insertBefore(n,e.display.lineSpace.firstChild)}function r(e){o(e)&&n(e)}function i(e){var r=e.getWrapperElement(),i=o(e);r.className=r.className.replace(" CodeMirror-empty","")+(i?" CodeMirror-empty":""),i?n(e):t(e)}function o(e){return 1===e.lineCount()&&""===e.getLine(0)}e.defineOption("placeholder","",function(n,o,a){var l=a&&a!=e.Init;if(o&&!l)n.on("blur",r),n.on("change",i),n.on("swapDoc",i),i(n);else if(!o&&l){n.off("blur",r),n.off("change",i),n.off("swapDoc",i),t(n);var s=n.getWrapperElement();s.className=s.className.replace(" CodeMirror-empty","")}o&&!n.hasFocus()&&r(n)})})},{"../../lib/codemirror":10}],7:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,n=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),a=[],l=0;l")>=0?d[2]:parseInt(d[3],10)+1+d[4];a[l]="\n"+p+g+m}}i.replaceSelections(a)}})},{"../../lib/codemirror":10}],8:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";e.overlayMode=function(t,n,r){return{startState:function(){return{base:e.startState(t),overlay:e.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(r){return{base:e.copyState(t,r.base),overlay:e.copyState(n,r.overlay),basePos:r.basePos,baseCur:null,overlayPos:r.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)=n.line,d=h?n:s(f,0),p=e.markText(u,d,{className:o});if(null==r?i.push(p):i.splice(r++,0,p),h)break;a=f}}function i(e){for(var t=e.state.markedSelection,n=0;n1)return o(e);var t=e.getCursor("start"),n=e.getCursor("end"),a=e.state.markedSelection;if(!a.length)return r(e,t,n);var s=a[0].find(),u=a[a.length-1].find();if(!s||!u||n.line-t.line=0||c(n,s.from)<=0)return o(e);for(;c(t,s.from)>0;)a.shift().clear(),s=a[0].find();for(c(t,s.from)<0&&(s.to.line-t.line0&&(n.line-u.from.linebo&&setTimeout(function(){s.display.input.reset(!0)},20),jt(this),Ki(),bt(this),this.curOp.forceUpdate=!0,Xr(this,i),r.autofocus&&!Ao||s.hasFocus()?setTimeout(Bi(vn,this),20):yn(this);for(var u in ta)ta.hasOwnProperty(u)&&ta[u](this,r[u],na);k(this),r.finishInit&&r.finishInit(this);for(var f=0;fbo&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),wo||go&&Ao||(r.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(r.wrapper):e(r.wrapper)),r.viewFrom=r.viewTo=t.first,r.reportedViewFrom=r.reportedViewTo=t.first,r.view=[],r.renderedView=null,r.externalMeasured=null,r.viewOffset=0,r.lastWrapHeight=r.lastWrapWidth=0,r.updateLineNumbers=null,r.nativeBarWidth=r.barHeight=r.barWidth=0,r.scrollbarsClipped=!1,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.alignWidgets=!1,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null, +r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1,r.selForContextMenu=null,r.activeTouch=null,n.init(r)}function n(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),r(t)}function r(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,_e(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Ja(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Za(e.display.wrapper,"CodeMirror-wrap"),h(e)),a(e),Dt(e),lt(e),setTimeout(function(){y(e)},100)}function o(e){var t=yt(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/xt(e.display)-3);return function(i){if(kr(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;at.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function d(e){var t=Pi(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+qe(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Ye(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function m(e,t,n){this.cm=n;var r=this.vert=ji("div",[ji("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=ji("div",[ji("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),Ea(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ea(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,xo&&8>bo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function g(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Za(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Ea(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?on(t,e):rn(t,e)},t),t.display.scrollbars.addClass&&Ja(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var n=e.display.barWidth,r=e.display.barHeight;x(e,t);for(var i=0;4>i&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&O(e),x(e,p(e)),n=e.display.barWidth,r=e.display.barHeight}function x(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function b(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Ue(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=ni(t,r),a=ni(t,i);if(n&&n.ensure){var l=n.ensure.from.line,s=n.ensure.to.line;o>l?(o=l,a=ni(t,ri(Zr(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=ni(t,ri(Zr(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function w(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=C(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==zt(e))return!1;k(e)&&(Wt(e),t.dims=P(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Wo&&(o=br(e.doc,o),a=wr(e.doc,a));var l=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Ft(e,o,a),n.viewOffset=ri(Zr(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var s=zt(e);if(!l&&0==s&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=Gi();return s>4&&(n.lineDiv.style.display="none"),R(e,n.updateLineNumbers,t.dims),s>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,c&&Gi()!=c&&c.offsetHeight&&c.focus(),Ui(n.cursorDiv),Ui(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,l&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,_e(e,400)),n.updateLineNumbers=null,!0}function N(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=$e(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+qe(e.display)-Ve(e),n.top)}),t.visible=b(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&M(e,t);r=!1){O(e);var i=p(e);Re(e),y(e,i),E(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var n=new L(e,t);if(M(e,n)){O(e),N(e,n);var r=p(e);Re(e),y(e,r),E(e,r),n.finish()}}function E(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Ye(e)+"px"}function O(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;rbo){var a=o.node.offsetTop+o.node.offsetHeight;i=a-n,n=a}else{var l=o.node.getBoundingClientRect();i=l.bottom-l.top}var s=o.line.height-i;if(2>i&&(i=yt(t)),(s>.001||-.001>s)&&(ei(o.line,i),I(o.line),o.rest))for(var c=0;c=t&&f.lineNumber;f.changes&&(Pi(f.changes,"gutter")>-1&&(h=!1),D(e,f,c,n)),h&&(Ui(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,c)))),l=f.node.nextSibling}else{var d=U(e,f,c,n);a.insertBefore(d,l)}c+=f.size}for(;l;)l=r(l)}function D(e,t,n,r){for(var i=0;ibo&&(e.node.style.zIndex=2)),e.node}function W(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=H(e);e.background=n.insertBefore(ji("div",null,t),n.firstChild)}}function B(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Br(e,t)}function _(e,t){var n=t.text.className,r=B(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,F(t)):n&&(t.text.className=n)}function F(e){W(e),e.line.wrapClass?H(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function z(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=H(t);t.gutterBackground=ji("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=H(t),a=t.gutter=ji("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),i.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(ji("div",S(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var l=0;l1)if(Fo&&Fo.text.join("\n")==t){if(r.ranges.length%Fo.text.length==0){s=[];for(var c=0;c=0;c--){var u=r.ranges[c],f=u.from(),h=u.to();u.empty()&&(n&&n>0?f=Bo(f.line,f.ch-n):e.state.overwrite&&!a?h=Bo(h.line,Math.min(Zr(o,h.line).text.length,h.ch+Ii(l).length)):Fo&&Fo.lineWise&&Fo.text.join("\n")==t&&(f=h=Bo(f.line,0)));var d=e.curOp.updateInput,p={from:f,to:h,text:s?s[c%s.length]:l,origin:i||(a?"paste":e.state.cutIncoming?"cut":"+input")};Tn(e.doc,p),Ci(e,"inputRead",e,p)}t&&!a&&Q(e,t),Bn(e),e.curOp.updateInput=d,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var n=e.clipboardData&&e.clipboardData.getData("text/plain");return n?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||At(t,function(){Z(t,n,0,null,"paste")}),!0):void 0}function Q(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var l=0;l-1){a=Fn(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Zr(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Fn(e,i.head.line,"smart"));a&&Ci(e,"electricInput",e,i.head.line)}}}function ee(e){for(var t=[],n=[],r=0;ri?c.map:u[i],a=0;ai?e.line:e.rest[i]),f=o[a]+r;return(0>r||l!=t)&&(f=o[a+(r?1:0)]),Bo(s,f)}}}var i=e.text.firstChild,o=!1;if(!t||!Va(i,t))return ae(Bo(ti(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[n],n=0,!t)){var a=e.rest?Ii(e.rest):e.line;return ae(Bo(ti(a),a.text.length),o)}var l=3==t.nodeType?t:null,s=t;for(l||1!=t.childNodes.length||3!=t.firstChild.nodeType||(l=t.firstChild,n&&(n=l.nodeValue.length));s.parentNode!=i;)s=s.parentNode;var c=e.measure,u=c.maps,f=r(l,s,n);if(f)return ae(f,o);for(var h=s.nextSibling,d=l?l.nodeValue.length-n:0;h;h=h.nextSibling){if(f=r(h,h.firstChild,0))return ae(Bo(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=s.previousSibling,d=n;p;p=p.previousSibling){if(f=r(p,p.firstChild,-1))return ae(Bo(f.line,f.ch+d),o);d+=h.textContent.length}}function ce(e,t,n,r,i){function o(e){return function(t){return t.id==e}}function a(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return""==n&&(n=t.textContent.replace(/\u200b/g,"")),void(l+=n);var u,f=t.getAttribute("cm-marker");if(f){var h=e.findMarks(Bo(r,0),Bo(i+1,0),o(+f));return void(h.length&&(u=h[0].find())&&(l+=Jr(e.doc,u.from,u.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d=0){var a=K(o.from(),i.from()),l=V(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=r&&--t,e.splice(--r,2,new fe(s?l:a,s?a:l))}}return new ue(e,t)}function de(e,t){return new ue([new fe(e,t||e)],0)}function pe(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function me(e,t){if(t.linen?Bo(n,Zr(e,n).text.length):ge(t,Zr(e,t.line).text.length)}function ge(e,t){var n=e.ch;return null==n||n>t?Bo(e.line,t):0>n?Bo(e.line,0):e}function ve(e,t){return t>=e.first&&t=t.ch:l.to>t.ch))){if(i&&(Pa(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(n){var c,u=s.find(0>r?1:-1);if((0>r?s.inclusiveRight:s.inclusiveLeft)&&(u=Pe(e,u,-r,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=_o(u,n))&&(0>r?0>c:c>0))return Oe(e,u,t,r,i)}var f=s.find(0>r?-1:1);return(0>r?s.inclusiveLeft:s.inclusiveRight)&&(f=Pe(e,f,r,f.line==t.line?o:null)),f?Oe(e,f,t,r,i):null}}return t}function Ie(e,t,n,r,i){var o=r||1,a=Oe(e,t,n,o,i)||!i&&Oe(e,t,n,o,!0)||Oe(e,t,n,-o,i)||!i&&Oe(e,t,n,-o,!0);return a?a:(e.cantEdit=!0,Bo(e.first,0))}function Pe(e,t,n,r){return 0>n&&0==t.ch?t.line>e.first?me(e,Bo(t.line-1)):null:n>0&&t.ch==(r||Zr(e,t.line)).text.length?t.line=e.display.viewTo||l.to().linet&&(t=0),t=Math.round(t),r=Math.round(r),l.appendChild(ji("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?u-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return ht(e,Bo(t,n),"div",f,r)}var l,s,f=Zr(a,t),h=f.text.length;return eo(ii(f),n||0,null==i?h:i,function(e,t,a){var f,d,p,m=o(e,"left");if(e==t)f=m,d=p=m.left;else{if(f=o(t-1,"right"),"rtl"==a){var g=m;m=f,f=g}d=m.left,p=f.right}null==n&&0==e&&(d=c),f.top-m.top>3&&(r(d,m.top,null,m.bottom),d=c,m.bottoms.bottom||f.bottom==s.bottom&&f.right>s.right)&&(s=f),c+1>d&&(d=c),r(d,f.top,p-d,f.bottom)}),{start:l,end:s}}var o=e.display,a=e.doc,l=document.createDocumentFragment(),s=Ge(e.display),c=s.left,u=Math.max(o.sizerWidth,$e(e)-o.sizer.offsetLeft)-s.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Zr(a,f.line),p=Zr(a,h.line),m=yr(d)==yr(p),g=i(f.line,f.ch,m?d.text.length+1:null).end,v=i(h.line,m?0:null,h.ch).start;m&&(g.top0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _e(e,t){e.doc.mode.startState&&e.doc.frontier=e.display.viewTo)){var n=+new Date+e.options.workTime,r=sa(t.mode,je(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength,s=Rr(e,o,l?sa(t.mode,r):r,!0);o.styles=s.styles;var c=o.styleClasses,u=s.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var f=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),h=0;!f&&hn?(_e(e,e.options.workDelay),!0):void 0}),i.length&&At(e,function(){for(var t=0;ta;--l){if(l<=o.first)return o.first;var s=Zr(o,l-1);if(s.stateAfter&&(!n||l<=o.frontier))return l;var c=Fa(s.text,null,e.options.tabSize);(null==i||r>c)&&(i=l-1,r=c)}return i}function je(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=ze(e,t,n),a=o>r.first&&Zr(r,o-1).stateAfter;return a=a?sa(r.mode,a):ca(r.mode),r.iter(o,t,function(n){Hr(e,n.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o2&&o.push((s.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Xe(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;rn)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Ze(e,t){t=yr(t);var n=ti(t),r=e.display.externalMeasured=new Pt(e.doc,t,n);r.lineN=n;var i=r.built=Br(e,r);return r.text=i.pre,qi(e.display.lineMeasure,i.pre),r}function Je(e,t,n,r){return tt(e,et(e,t),n,r)}function Qe(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt?(i=0,o=1,a="left"):c>t?(i=t-s,o=i+1):(l==e.length-3||t==c&&e[l+3]>t)&&(o=c-s,i=o-1,t>=c&&(a="right")),null!=i){if(r=e[l+2],s==c&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;l&&e[l-2]==e[l-3]&&e[l-1].insertLeft;)r=e[(l-=3)+2],a="left";if("right"==n&&i==c-s)for(;lu;u++){for(;l&&zi(t.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+sbo&&0==l&&s==o.coverEnd-o.coverStart)i=a.parentNode.getBoundingClientRect();else if(xo&&e.options.lineWrapping){var f=qa(a,l,s).getClientRects();i=f.length?f["right"==r?f.length-1:0]:qo}else i=qa(a,l,s).getBoundingClientRect()||qo;if(i.left||i.right||0==l)break;s=l,l-=1,c="right"}xo&&11>bo&&(i=it(e.display.measure,i))}else{l>0&&(c=r="right");var f;i=e.options.lineWrapping&&(f=a.getClientRects()).length>1?f["right"==r?f.length-1:0]:a.getBoundingClientRect()}if(xo&&9>bo&&!l&&(!i||!i.left&&!i.right)){var h=a.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+xt(e.display),top:h.top,bottom:h.bottom}:qo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,m=(d+p)/2,g=t.view.measure.heights,u=0;un.from?a(e-1):a(e,r)}r=r||Zr(e.doc,t.line),i||(i=et(e,r));var s=ii(r),c=t.ch;if(!s)return a(c);var u=co(s,c),f=l(c,u);return null!=al&&(f.other=l(c,al)),f}function pt(e,t){var n=0,t=me(e.doc,t);e.options.lineWrapping||(n=xt(e.display)*t.ch);var r=Zr(e.doc,t.line),i=ri(r)+Ue(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function mt(e,t,n,r){var i=Bo(e,t);return i.xRel=r,n&&(i.outside=!0),i}function gt(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,0>n)return mt(r.first,0,!0,-1);var i=ni(r,n),o=r.first+r.size-1;if(i>o)return mt(r.first+r.size-1,Zr(r,o).text.length,!0,1);0>t&&(t=0);for(var a=Zr(r,i);;){var l=vt(e,a,i,t,n),s=gr(a),c=s&&s.find(0,!0);if(!s||!(l.ch>c.from.ch||l.ch==c.from.ch&&l.xRel>0))return l;i=ti(a=c.to.line)}}function vt(e,t,n,r,i){function o(r){var i=dt(e,Bo(n,r),"line",t,c);return l=!0,a>i.bottom?i.left-s:ag)return mt(n,d,v,1);for(;;){if(u?d==h||d==fo(t,h,1):1>=d-h){for(var y=p>r||g-r>=r-p?h:d,x=r-(y==h?p:g);zi(t.text.charAt(y));)++y;var b=mt(n,y,y==h?m:v,-1>x?-1:x>1?1:0);return b}var w=Math.ceil(f/2),k=h+w;if(u){k=h;for(var S=0;w>S;++S)k=fo(t,k,1)}var C=o(k);C>r?(d=k,g=C,(v=l)&&(g+=1e3),f=w):(h=k,p=C,m=l,f-=w)}}function yt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==zo){zo=ji("pre");for(var t=0;49>t;++t)zo.appendChild(document.createTextNode("x")),zo.appendChild(ji("br"));zo.appendChild(document.createTextNode("x"))}qi(e.measure,zo);var n=zo.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Ui(e.measure),n||1}function xt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=ji("span","xxxxxxxxxx"),n=ji("pre",[t]);qi(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function bt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Yo},Go?Go.ops.push(e.curOp):e.curOp.ownsGroup=Go={ops:[e.curOp],delayedCallbacks:[]}}function wt(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new L(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Lt(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function Tt(e){var t=e.cm,n=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Je(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Ye(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-$e(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection(e.focus))}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLefto;o=r){var a=new Pt(e.doc,Zr(e.doc,o),o);r=o+a.size,i.push(a)}return i}function Dt(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Wo&&br(e.doc,t)i.viewFrom?Wt(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wt(e);else if(t<=i.viewFrom){var o=_t(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):Wt(e)}else if(n>=i.viewTo){var o=_t(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Wt(e)}else{var a=_t(e,t,t,-1),l=_t(e,n,n+r,1);a&&l?(i.view=i.view.slice(0,a.index).concat(Rt(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):Wt(e)}var s=i.externalMeasured;s&&(n=i.lineN&&t=r.viewTo)){var o=r.view[Bt(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==Pi(a,n)&&a.push(n)}}}function Wt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Bt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,r=0;rt)return r}function _t(e,t,n,r){var i,o=Bt(e,t),a=e.display.view;if(!Wo||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var l=0,s=e.display.viewFrom;o>l;l++)s+=a[l].size;if(s!=t){if(r>0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;br(e.doc,n)!=n;){if(o==(0>r?0:a.length-1))return null;n+=r*a[o-(0>r?1:0)].size,o+=r}return{index:o,lineN:n}}function Ft(e,t,n){var r=e.display,i=r.view;0==i.length||t>=r.viewTo||n<=r.viewFrom?(r.view=Rt(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rt(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,Bt(e,n)))),r.viewTo=n}function zt(e){for(var t=e.display.view,n=0,r=0;r400}var i=e.display;Ea(i.scroller,"mousedown",Et(e,$t)),xo&&11>bo?Ea(i.scroller,"dblclick",Et(e,function(t){if(!Ti(e,t)){var n=Yt(e,t);if(n&&!Jt(e,t)&&!Gt(e.display,t)){Ma(t);var r=e.findWordAt(n);be(e.doc,r.anchor,r.head)}}})):Ea(i.scroller,"dblclick",function(t){Ti(e,t)||Ma(t)}),Do||Ea(i.scroller,"contextmenu",function(t){xn(e,t)});var o,a={end:0};Ea(i.scroller,"touchstart",function(t){if(!Ti(e,t)&&!n(t)){clearTimeout(o);var r=+new Date;i.activeTouch={start:r,moved:!1,prev:r-a.end<=300?a:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Ea(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ea(i.scroller,"touchend",function(n){var o=i.activeTouch;if(o&&!Gt(i,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,l=e.coordsChar(i.activeTouch,"page");a=!o.prev||r(o,o.prev)?new fe(l,l):!o.prev.prev||r(o,o.prev.prev)?e.findWordAt(l):new fe(Bo(l.line,0),me(e.doc,Bo(l.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),Ma(n)}t()}),Ea(i.scroller,"touchcancel",t),Ea(i.scroller,"scroll",function(){i.scroller.clientHeight&&(rn(e,i.scroller.scrollTop),on(e,i.scroller.scrollLeft,!0),Pa(e,"scroll",e))}),Ea(i.scroller,"mousewheel",function(t){an(e,t)}),Ea(i.scroller,"DOMMouseScroll",function(t){an(e,t)}),Ea(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Ti(e,t)||Aa(t)},over:function(t){Ti(e,t)||(tn(e,t),Aa(t))},start:function(t){en(e,t)},drop:Et(e,Qt),leave:function(t){Ti(e,t)||nn(e)}};var l=i.input.getField();Ea(l,"keyup",function(t){pn.call(e,t)}),Ea(l,"keydown",Et(e,hn)),Ea(l,"keypress",Et(e,mn)),Ea(l,"focus",Bi(vn,e)),Ea(l,"blur",Bi(yn,e))}function Ut(t,n,r){var i=r&&r!=e.Init;if(!n!=!i){var o=t.display.dragFunctions,a=n?Ea:Ia;a(t.display.scroller,"dragstart",o.start),a(t.display.scroller,"dragenter",o.enter),a(t.display.scroller,"dragover",o.over),a(t.display.scroller,"dragleave",o.leave),a(t.display.scroller,"drop",o.drop)}}function qt(e){var t=e.display;t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth||(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var n=wi(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function Yt(e,t,n,r){var i=e.display;if(!n&&"true"==wi(t).getAttribute("cm-not-content"))return null;var o,a,l=i.lineSpace.getBoundingClientRect();try{o=t.clientX-l.left,a=t.clientY-l.top}catch(t){return null}var s,c=gt(e,o,a);if(r&&1==c.xRel&&(s=Zr(e.doc,c.line).text).length==c.ch){var u=Fa(s,s.length,e.options.tabSize)-s.length;c=Bo(c.line,Math.max(0,Math.round((o-Ge(e.display).left)/xt(e.display))-u))}return c}function $t(e){var t=this,n=t.display;if(!(Ti(t,e)||n.activeTouch&&n.input.supportsTouch())){if(n.shift=e.shiftKey,Gt(n,e))return void(wo||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Jt(t,e)){var r=Yt(t,e);switch(window.focus(),ki(e)){case 1:t.state.selectingText?t.state.selectingText(e):r?Vt(t,e,r):wi(e)==n.scroller&&Ma(e);break;case 2:wo&&(t.state.lastMiddleDown=+new Date),r&&be(t.doc,r),setTimeout(function(){n.input.focus()},20),Ma(e);break;case 3:Do?xn(t,e):gn(t)}}}}function Vt(e,t,n){xo?setTimeout(Bi(X,e),0):e.curOp.focus=Gi();var r,i=+new Date;Uo&&Uo.time>i-400&&0==_o(Uo.pos,n)?r="triple":jo&&jo.time>i-400&&0==_o(jo.pos,n)?(r="double",Uo={time:i,pos:n}):(r="single",jo={time:i,pos:n});var o,a=e.doc.sel,l=Eo?t.metaKey:t.ctrlKey;e.options.dragDrop&&el&&!e.isReadOnly()&&"single"==r&&(o=a.contains(n))>-1&&(_o((o=a.ranges[o]).from(),n)<0||n.xRel>0)&&(_o(o.to(),n)>0||n.xRel<0)?Kt(e,t,n,l):Xt(e,t,n,r,l)}function Kt(e,t,n,r){var i=e.display,o=+new Date,a=Et(e,function(l){wo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ia(document,"mouseup",a),Ia(i.scroller,"drop",a),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(Ma(l),!r&&+new Date-200=p;p++){var v=Zr(c,p).text,y=za(v,s,o);s==d?i.push(new fe(Bo(p,y),Bo(p,y))):v.length>y&&i.push(new fe(Bo(p,y),Bo(p,za(v,d,o))))}i.length||i.push(new fe(n,n)),Te(c,he(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=u,b=x.anchor,w=t;if("single"!=r){if("double"==r)var k=e.findWordAt(t);else var k=new fe(Bo(t.line,0),me(c,Bo(t.line+1,0)));_o(k.anchor,b)>0?(w=k.head,b=K(x.from(),k.anchor)):(w=k.anchor,b=V(x.to(),k.head))}var i=h.ranges.slice(0);i[f]=new fe(me(c,b),w),Te(c,he(i,f),Ba)}}function a(t){var n=++y,i=Yt(e,t,!0,"rect"==r);if(i)if(0!=_o(i,g)){e.curOp.focus=Gi(),o(i);var l=b(s,c);(i.line>=l.to||i.linev.bottom?20:0;u&&setTimeout(Et(e,function(){y==n&&(s.scroller.scrollTop+=u,a(t))}),50)}}function l(t){e.state.selectingText=!1,y=1/0,Ma(t),s.input.focus(),Ia(document,"mousemove",x),Ia(document,"mouseup",w),c.history.lastSelOrigin=null}var s=e.display,c=e.doc;Ma(t);var u,f,h=c.sel,d=h.ranges;if(i&&!t.shiftKey?(f=c.sel.contains(n),u=f>-1?d[f]:new fe(n,n)):(u=c.sel.primary(),f=c.sel.primIndex),Oo?t.shiftKey&&t.metaKey:t.altKey)r="rect",i||(u=new fe(n,n)),n=Yt(e,t,!0,!0),f=-1;else if("double"==r){var p=e.findWordAt(n);u=e.display.shift||c.extend?xe(c,u,p.anchor,p.head):p}else if("triple"==r){var m=new fe(Bo(n.line,0),me(c,Bo(n.line+1,0)));u=e.display.shift||c.extend?xe(c,u,m.anchor,m.head):m}else u=xe(c,u,n);i?-1==f?(f=d.length,Te(c,he(d.concat([u]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==r&&!t.shiftKey?(Te(c,he(d.slice(0,f).concat(d.slice(f+1)),0),{scroll:!1,origin:"*mouse"}),h=c.sel):ke(c,f,u,Ba):(f=0,Te(c,new ue([u],0),Ba),h=c.sel);var g=n,v=s.wrapper.getBoundingClientRect(),y=0,x=Et(e,function(e){ki(e)?a(e):l(e)}),w=Et(e,l);e.state.selectingText=w,Ea(document,"mousemove",x),Ea(document,"mouseup",w)}function Zt(e,t,n,r){try{var i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ma(t);var a=e.display,l=a.lineDiv.getBoundingClientRect();if(o>l.bottom||!Ni(e,n))return bi(t);o-=l.top-a.viewOffset;for(var s=0;s=i){var u=ni(e.doc,o),f=e.options.gutters[s];return Pa(e,n,e,u,f,t),bi(t)}}}function Jt(e,t){return Zt(e,t,"gutterClick",!0)}function Qt(e){var t=this;if(nn(t),!Ti(t,e)&&!Gt(t.display,e)){Ma(e),xo&&($o=+new Date);var n=Yt(t,e,!0),r=e.dataTransfer.files;if(n&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),a=0,l=function(e,r){if(!t.options.allowDropFileTypes||-1!=Pi(t.options.allowDropFileTypes,e.type)){var l=new FileReader;l.onload=Et(t,function(){var e=l.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[r]=e,++a==i){n=me(t.doc,n);var s={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Tn(t.doc,s),Le(t.doc,de(n,Qo(s)))}}),l.readAsText(e)}},s=0;i>s;++s)l(r[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Eo?e.altKey:e.ctrlKey))var c=t.listSelections();if(Me(t.doc,de(n,n)),c)for(var s=0;sa.clientWidth,s=a.scrollHeight>a.clientHeight;if(r&&l||i&&s){if(i&&Eo&&wo)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var f=0;fh?d=Math.max(0,d+h-50):p=Math.min(e.doc.height,p+h+50),A(e,{top:d,bottom:p})}20>Vo&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Ko=(Ko*Vo+n)/(Vo+1),++Vo)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}function ln(e,t,n){if("string"==typeof t&&(t=ua[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ha}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function sn(e,t,n){for(var r=0;rbo&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var r=un(t,e);Co&&(Jo=r?n:null,!r&&88==n&&!rl&&(Eo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||dn(t)}}function dn(e){function t(e){18!=e.keyCode&&e.altKey||(Za(n,"CodeMirror-crosshair"),Ia(document,"keyup",t),Ia(document,"mouseover",t))}var n=e.display.lineDiv;Ja(n,"CodeMirror-crosshair"),Ea(document,"keyup",t),Ea(document,"mouseover",t)}function pn(e){16==e.keyCode&&(this.doc.sel.shift=!1),Ti(this,e)}function mn(e){var t=this;if(!(Gt(t.display,e)||Ti(t,e)||e.ctrlKey&&!e.altKey||Eo&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(Co&&n==Jo)return Jo=null,void Ma(e);if(!Co||e.which&&!(e.which<10)||!un(t,e)){var i=String.fromCharCode(null==r?n:r);fn(t,e,i)||t.display.input.onKeyPress(e)}}}function gn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,yn(e))},100)}function vn(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Pa(e,"focus",e),e.state.focused=!0,Ja(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),wo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Be(e))}function yn(e){e.state.delayingBlurEvent||(e.state.focused&&(Pa(e,"blur",e),e.state.focused=!1,Za(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function xn(e,t){Gt(e.display,t)||bn(e,t)||Ti(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function bn(e,t){return Ni(e,"gutterContextMenu")?Zt(e,t,"gutterContextMenu",!1):!1}function wn(e,t){if(_o(e,t.from)<0)return e;if(_o(e,t.to)<=0)return Qo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Qo(t).ch-t.to.ch),Bo(n,r)}function kn(e,t){for(var n=[],r=0;r=0;--i)Mn(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Mn(e,t)}}function Mn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=_o(t.from,t.to)){var n=kn(e,t);ci(e,t,n,e.cm?e.cm.curOp.id:NaN),En(e,t,n,or(e,t));var r=[];Kr(e,function(e,n){n||-1!=Pi(r,e.history)||(xi(e.history,t),r.push(e.history)),En(e,t,null,or(e,t))})}}function Nn(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,l="undo"==t?i.undone:i.done,s=0;s=0;--s){var f=r.changes[s];if(f.origin=t,u&&!Ln(e,f,!1))return void(a.length=0);c.push(ai(e,f));var h=s?kn(e,f):Ii(a);En(e,f,h,lr(e,f)),!s&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Qo(f)});var d=[];Kr(e,function(e,t){t||-1!=Pi(d,e.history)||(xi(e.history,f),d.push(e.history)),En(e,f,null,lr(e,f))})}}}}function An(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Ri(e.sel.ranges,function(e){return new fe(Bo(e.anchor.line+t,e.anchor.ch),Bo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:Bo(o,Zr(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Jr(e,t.from,t.to),n||(n=kn(e,t)),e.cm?On(e.cm,t,r):Yr(e,t,r),Me(e,n,Wa)}}function On(e,t,n){var r=e.doc,i=e.display,a=t.from,l=t.to,s=!1,c=a.line;e.options.lineWrapping||(c=ti(yr(Zr(r,a.line))),r.iter(c,l.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&Mi(e),Yr(r,t,n,o(e)),e.options.lineWrapping||(r.iter(c,a.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,a.line),_e(e,400);var u=t.text.length-(l.line-a.line)-1;t.full?Dt(e):a.line!=l.line||1!=t.text.length||Gr(e.doc,t)?Dt(e,a.line,l.line+1,u):Ht(e,a.line,"text");var h=Ni(e,"changes"),d=Ni(e,"change");if(d||h){var p={from:a,to:l,text:t.text,removed:t.removed,origin:t.origin};d&&Ci(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function In(e,t,n,r,i){if(r||(r=n),_o(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=e.splitLines(t)),Tn(e,{from:n,to:r,text:t,origin:i})}function Pn(e,t){if(!Ti(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Mo){var o=ji("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Ue(e.display))+"px; height: "+(t.bottom-t.top+Ye(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Rn(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,a=dt(e,t),l=n&&n!=t?dt(e,n):a,s=Hn(e,Math.min(a.left,l.left),Math.min(a.top,l.top)-r,Math.max(a.left,l.left),Math.max(a.bottom,l.bottom)+r),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=s.scrollTop&&(rn(e,s.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(o=!0)),null!=s.scrollLeft&&(on(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(o=!0)),!o)break}return a}function Dn(e,t,n,r,i){var o=Hn(e,t,n,r,i);null!=o.scrollTop&&rn(e,o.scrollTop),null!=o.scrollLeft&&on(e,o.scrollLeft)}function Hn(e,t,n,r,i){var o=e.display,a=yt(e.display);0>n&&(n=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Ve(e),c={};i-n>s&&(i=n+s);var u=e.doc.height+qe(o),f=a>n,h=i>u-a;if(l>n)c.scrollTop=f?0:n;else if(i>l+s){var d=Math.min(n,(h?u:i)-s);d!=l&&(c.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=$e(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),g=r-t>m;return g&&(r=t+m),10>t?c.scrollLeft=0:p>t?c.scrollLeft=Math.max(0,t-(g?0:10)):r>m+p-3&&(c.scrollLeft=r+(g?0:10)-m),c}function Wn(e,t,n){null==t&&null==n||_n(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=n&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+n)}function Bn(e){_n(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?Bo(t.line,t.ch-1):t,r=Bo(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function _n(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=pt(e,t.from),r=pt(e,t.to),i=Hn(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Fn(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=je(e,t):n="prev");var a=e.options.tabSize,l=Zr(o,t),s=Fa(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var c,u=l.text.match(/^\s*/)[0];if(r||/\S/.test(l.text)){if("smart"==n&&(c=o.mode.indent(i,l.text.slice(u.length),l.text),c==Ha||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?Fa(Zr(o,t-1).text,null,a):0:"add"==n?c=s+e.options.indentUnit:"subtract"==n?c=s-e.options.indentUnit:"number"==typeof n&&(c=s+n),c=Math.max(0,c);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(c/a);d;--d)h+=a,f+=" ";if(c>h&&(f+=Oi(c-h)),f!=u)return In(o,f,Bo(t,0),Bo(t,u.length),"+input"),l.stateAfter=null,!0;for(var d=0;d=0;t--)In(e.doc,"",r[t].from,r[t].to,"+delete");Bn(e)})}function Un(e,t,n,r,i){function o(){var t=l+n;return t=e.first+e.size?!1:(l=t,u=Zr(e,t))}function a(e){var t=(i?fo:ho)(u,s,n,!0);if(null==t){if(e||!o())return!1;s=i?(0>n?io:ro)(u):0>n?u.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,c=n,u=Zr(e,l);if("char"==r)a();else if("column"==r)a(!0);else if("word"==r||"group"==r)for(var f=null,h="group"==r,d=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(0>n)||a(!p);p=!1){var m=u.text.charAt(s)||"\n",g=_i(m,d)?"w":h&&"\n"==m?"n":!h||/\s/.test(m)?null:"p";if(!h||p||g||(g="s"),f&&f!=g){0>n&&(n=1,a());break}if(g&&(f=g),n>0&&!a(!p))break}var v=Ie(e,Bo(l,s),t,c,!0);return _o(t,v)||(v.hitSide=!0),v}function qn(e,t,n,r){var i,o=e.doc,a=t.left;if("page"==r){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+n*(l-(0>n?1.5:.5)*yt(e.display))}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;;){var s=gt(e,a,i);if(!s.outside)break;if(0>n?0>=i:i>=o.height){s.hitSide=!0;break}i+=5*n}return s}function Gn(t,n,r,i){e.defaults[t]=n,r&&(ta[t]=i?function(e,t,n){n!=na&&r(e,t,n)}:r)}function Yn(e){for(var t,n,r,i,o=e.split(/-(?!$)/),e=o[o.length-1],a=0;a0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=ji("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(vr(e,t.line,t,n,o)||t.line!=n.line&&vr(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Wo=!0}o.addToHistory&&ci(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var l,s=t.line,c=e.cm;if(e.iter(s,n.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&yr(e)==c.display.maxLine&&(l=!0),o.collapsed&&s!=t.line&&ei(e,0),nr(e,new Qn(o,s==t.line?t.ch:null,s==n.line?n.ch:null)),++s}),o.collapsed&&e.iter(t.line,n.line+1,function(t){kr(e,t)&&ei(t,0)}),o.clearOnEnter&&Ea(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Ho=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ga,o.atomic=!0),c){if(l&&(c.curOp.updateMaxLine=!0),o.collapsed)Dt(c,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var u=t.line;u<=n.line;u++)Ht(c,u,"text");o.atomic&&Ae(c.doc),Ci(c,"markerAdded",c,o)}return o}function Kn(e,t,n,r,i){r=Wi(r),r.shared=!1;var o=[Vn(e,t,n,r,i)],a=o[0],l=r.widgetNode;return Kr(e,function(e){l&&(r.widgetNode=l.cloneNode(!0)),o.push(Vn(e,me(e,t),me(e,n),r,i));for(var s=0;s=t:o.to>t);(r||(r=[])).push(new Qn(a,o.from,s?null:o.to))}}return r}function ir(e,t,n){if(e)for(var r,i=0;i=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&l)for(var f=0;ff;++f)p.push(m);p.push(s)}return p}function ar(e){for(var t=0;t0)){var u=[s,1],f=_o(c.from,l.from),h=_o(c.to,l.to);(0>f||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:l.from}),(h>0||!a.inclusiveRight&&!h)&&u.push({from:l.to,to:c.to}),i.splice.apply(i,u),s+=u.length-1}}return i}function cr(e){var t=e.markedSpans;if(t){for(var n=0;n=0&&0>=f||0>=u&&f>=0)&&(0>=u&&(s.marker.inclusiveRight&&i.inclusiveLeft?_o(c.to,n)>=0:_o(c.to,n)>0)||u>=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?_o(c.from,r)<=0:_o(c.from,r)<0)))return!0}}}function yr(e){for(var t;t=mr(e);)e=t.find(-1,!0).line;return e}function xr(e){for(var t,n;t=gr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function br(e,t){var n=Zr(e,t),r=yr(n);return n==r?t:ti(r)}function wr(e,t){if(t>e.lastLine())return t;var n,r=Zr(e,t);if(!kr(e,r))return t;for(;n=gr(r);)r=n.find(1,!0).line;return ti(r)+1}function kr(e,t){var n=Wo&&t.markedSpans;if(n)for(var r,i=0;io;o++){i&&(i[0]=e.innerMode(t,r).mode);var a=t.token(n,r);if(n.pos>n.start)return a}throw new Error("Mode "+t.name+" failed to advance stream.")}function Ir(e,t,n,r){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?sa(a.mode,u):u}}var o,a=e.doc,l=a.mode;t=me(a,t);var s,c=Zr(a,t.line),u=je(e,t.line,n),f=new ma(c.text,e.options.tabSize);for(r&&(s=[]);(r||f.pose.options.maxHighlightLength?(l=!1,a&&Hr(e,t,r,f.pos),f.pos=t.length,s=null):s=Ar(Or(n,f,r,h),o),h){var d=h[0].name;d&&(s="m-"+(s?d+" "+s:d))}if(!l||u!=s){for(;cc;){var r=i[s];r>e&&i.splice(s,1,e,i[s+1],r),s+=2,c=Math.min(e,r)}if(t)if(l.opaque)i.splice(n,s-n,e,"cm-overlay "+t),s=n+2;else for(;s>n;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Dr(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=je(e,ti(t)),i=Rr(e,t,t.text.length>e.options.maxHighlightLength?sa(e.doc.mode,r):r);t.stateAfter=r,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Hr(e,t,n,r){var i=e.doc.mode,o=new ma(t,e.options.tabSize);for(o.start=o.pos=r||0,""==t&&Er(i,n);!o.eol();)Or(i,o,n),o.start=o.pos}function Wr(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?ka:wa;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Br(e,t){var n=ji("span",null,null,wo?"padding-right: .1px":null),r={pre:ji("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,splitSpaces:(xo||wo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,a=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=Fr,Ji(e.display.measure)&&(o=ii(a))&&(r.addToken=jr(r.addToken,o)),r.map=[];var l=t!=e.display.externalMeasured&&ti(a);qr(a,r,Dr(e,a,l)),a.styleClasses&&(a.styleClasses.bgClass&&(r.bgClass=$i(a.styleClasses.bgClass,r.bgClass||"")),a.styleClasses.textClass&&(r.textClass=$i(a.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Zi(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(wo){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Pa(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=$i(r.pre.className,r.textClass||"")),r}function _r(e){var t=ji("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Fr(e,t,n,r,i,o,a){if(t){var l=e.splitSpaces?t.replace(/ {3,}/g,zr):t,s=e.cm.state.specialChars,c=!1;if(s.test(t))for(var u=document.createDocumentFragment(),f=0;;){s.lastIndex=f;var h=s.exec(t),d=h?h.index-f:t.length-f;if(d){var p=document.createTextNode(l.slice(f,f+d));xo&&9>bo?u.appendChild(ji("span",[p])):u.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!h)break;if(f+=d+1," "==h[0]){var m=e.cm.options.tabSize,g=m-e.col%m,p=u.appendChild(ji("span",Oi(g),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=g}else if("\r"==h[0]||"\n"==h[0]){var p=u.appendChild(ji("span","\r"==h[0]?"␍":"␤","cm-invalidchar"));p.setAttribute("cm-text",h[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(h[0]);p.setAttribute("cm-text",h[0]),xo&&9>bo?u.appendChild(ji("span",[p])):u.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var u=document.createTextNode(l);e.map.push(e.pos,e.pos+t.length,u),xo&&9>bo&&(c=!0),e.pos+=t.length}if(n||r||i||c||a){var v=n||"";r&&(v+=r),i&&(v+=i);var y=ji("span",[u],v,a);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(u)}}function zr(e){for(var t=" ",n=0;nc&&h.from<=c)break}if(h.to>=u)return e(n,r,i,o,a,l,s);e(n,r.slice(0,h.to-c),i,o,null,l,s),o=null,r=r.slice(h.to-c),c=h.to}}}function Ur(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function qr(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var a,l,s,c,u,f,h,d=i.length,p=0,m=1,g="",v=0;;){if(v==p){s=c=u=f=l="",h=null,v=1/0;for(var y,x=[],b=0;bp||k.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&v>w.to&&(v=w.to,c=""),k.className&&(s+=" "+k.className),k.css&&(l=(l?l+";":"")+k.css),k.startStyle&&w.from==p&&(u+=" "+k.startStyle),k.endStyle&&w.to==v&&(y||(y=[])).push(k.endStyle,w.to),k.title&&!f&&(f=k.title),k.collapsed&&(!h||dr(h.marker,k)<0)&&(h=w)):w.from>p&&v>w.from&&(v=w.from)}if(y)for(var b=0;b=d)break;for(var S=Math.min(d,v);;){if(g){var C=p+g.length;if(!h){var L=C>S?g.slice(0,S-p):g;t.addToken(t,L,a?a+s:s,u,p+L.length==v?c:"",f,l)}if(C>=S){g=g.slice(S-p),p=S;break}p=C,u=""}g=i.slice(o,o=n[m++]),a=Wr(n[m++],t.cm.options)}}else for(var m=1;mn;++n)o.push(new ba(c[n],i(n),r));return o}var l=t.from,s=t.to,c=t.text,u=Zr(e,l.line),f=Zr(e,s.line),h=Ii(c),d=i(c.length-1),p=s.line-l.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Gr(e,t)){var m=a(0,c.length-1);o(f,f.text,d),p&&e.remove(l.line,p),m.length&&e.insert(l.line,m)}else if(u==f)if(1==c.length)o(u,u.text.slice(0,l.ch)+h+u.text.slice(s.ch),d);else{var m=a(1,c.length-1);m.push(new ba(h+u.text.slice(s.ch),d,r)),o(u,u.text.slice(0,l.ch)+c[0],i(0)),e.insert(l.line+1,m)}else if(1==c.length)o(u,u.text.slice(0,l.ch)+c[0]+f.text.slice(s.ch),i(0)),e.remove(l.line+1,p);else{o(u,u.text.slice(0,l.ch)+c[0],i(0)),o(f,h+f.text.slice(s.ch),d);var m=a(1,c.length-1);p>1&&e.remove(l.line+1,p-1),e.insert(l.line+1,m)}Ci(e,"change",e,t)}function $r(e){this.lines=e,this.parent=null;for(var t=0,n=0;tt||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(o>t){n=i;break}t-=o}return n.lines[t]}function Jr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i}),r}function Qr(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function ei(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function ti(e){if(null==e.parent)return null;for(var t=e.parent,n=Pi(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function ni(e,t){var n=e.first;e:do{for(var r=0;rt){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;rt)break;t-=l}return n+r}function ri(e){e=yr(e);for(var t=0,n=e.parent,r=0;r1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Ii(e.done)):void 0}function ci(e,t,n,r){var i=e.history;i.undone.length=0;var o,a=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>a-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=si(i,i.lastOp==r))){var l=Ii(o.changes);0==_o(t.from,t.to)&&0==_o(t.from,l.to)?l.to=Qo(t):o.changes.push(ai(e,t))}else{var s=Ii(i.done);for(s&&s.ranges||hi(e.sel,i.done),o={changes:[ai(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||Pa(e,"historyAdded")}function ui(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function fi(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ui(e,o,Ii(i.done),t))?i.done[i.done.length-1]=t:hi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&r.clearRedo!==!1&&li(i.undone)}function hi(e,t){var n=Ii(t);n&&n.ranges&&n.equals(e)||t.push(e)}function di(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function pi(e){if(!e)return null;for(var t,n=0;n-1&&(Ii(l)[f]=u[f],delete u[f])}}}return i}function vi(e,t,n,r){n0?r.slice():Oa:r||Oa}function Ci(e,t){function n(e){return function(){e.apply(null,o)}}var r=Si(e,t,!1);if(r.length){var i,o=Array.prototype.slice.call(arguments,2);Go?i=Go.delayedCallbacks:Ra?i=Ra:(i=Ra=[],setTimeout(Li,0));for(var a=0;a0}function Ai(e){e.prototype.on=function(e,t){Ea(this,e,t)},e.prototype.off=function(e,t){Ia(this,e,t)}}function Ei(){this.id=null}function Oi(e){for(;ja.length<=e;)ja.push(Ii(ja)+" ");return ja[e]}function Ii(e){return e[e.length-1]}function Pi(e,t){for(var n=0;n-1&&Ya(e)?!0:t.test(e):Ya(e)}function Fi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function zi(e){return e.charCodeAt(0)>=768&&$a.test(e)}function ji(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o0;--t)e.removeChild(e.firstChild);return e}function qi(e,t){return Ui(e).appendChild(t)}function Gi(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Yi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $i(e,t){for(var n=e.split(" "),r=0;r2&&!(xo&&8>bo))}var n=Ka?ji("span","​"):ji("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Ji(e){if(null!=Xa)return Xa;var t=qi(e,document.createTextNode("AخA")),n=qa(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=qa(t,1,2).getBoundingClientRect();return Xa=r.right-n.right<3}function Qi(e){if(null!=il)return il;var t=qi(e,ji("span","x")),n=t.getBoundingClientRect(),r=qa(t,0,1).getBoundingClientRect();return il=Math.abs(n.left-r.left)>1}function eo(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;ot||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function to(e){return e.level%2?e.to:e.from}function no(e){return e.level%2?e.from:e.to}function ro(e){var t=ii(e);return t?to(t[0]):0}function io(e){var t=ii(e);return t?no(Ii(t)):e.text.length}function oo(e,t){var n=Zr(e.doc,t),r=yr(n);r!=n&&(t=ti(r));var i=ii(r),o=i?i[0].level%2?io(r):ro(r):0;return Bo(t,o)}function ao(e,t){for(var n,r=Zr(e.doc,t);n=gr(r);)r=n.find(1,!0).line,t=null;var i=ii(r),o=i?i[0].level%2?ro(r):io(r):r.text.length;return Bo(null==t?ti(r):t,o)}function lo(e,t){var n=oo(e,t.line),r=Zr(e.doc,n.line),i=ii(r);if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return Bo(n.line,a?0:o)}return n}function so(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function co(e,t){al=null;for(var n,r=0;rt)return r;if(i.from==t||i.to==t){if(null!=n)return so(e,i.level,e[n].level)?(i.from!=i.to&&(al=n),r):(i.from!=i.to&&(al=r),n);n=r}}return n}function uo(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&zi(e.text.charAt(t)));return t}function fo(e,t,n,r){var i=ii(e);if(!i)return ho(e,t,n,r);for(var o=co(i,t),a=i[o],l=uo(e,t,a.level%2?-n:n,r);;){if(l>a.from&&l0==a.level%2?a.to:a.from);if(a=i[o+=n],!a)return null;l=n>0==a.level%2?uo(e,a.to,-1,r):uo(e,a.from,1,r)}}function ho(e,t,n,r){var i=t+n;if(r)for(;i>0&&zi(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var po=navigator.userAgent,mo=navigator.platform,go=/gecko\/\d/i.test(po),vo=/MSIE \d/.test(po),yo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(po),xo=vo||yo,bo=xo&&(vo?document.documentMode||6:yo[1]),wo=/WebKit\//.test(po),ko=wo&&/Qt\/\d+\.\d+/.test(po),So=/Chrome\//.test(po),Co=/Opera\//.test(po),Lo=/Apple Computer/.test(navigator.vendor),To=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(po),Mo=/PhantomJS/.test(po),No=/AppleWebKit/.test(po)&&/Mobile\/\w+/.test(po),Ao=No||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(po),Eo=No||/Mac/.test(mo),Oo=/\bCrOS\b/.test(po),Io=/win/i.test(mo),Po=Co&&po.match(/Version\/(\d*\.\d*)/);Po&&(Po=Number(Po[1])),Po&&Po>=15&&(Co=!1,wo=!0);var Ro=Eo&&(ko||Co&&(null==Po||12.11>Po)),Do=go||xo&&bo>=9,Ho=!1,Wo=!1;m.prototype=Wi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=Eo&&!To?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ei,this.disableVert=new Ei},enableZeroWidthBar:function(e,t){function n(){var r=e.getBoundingClientRect(),i=document.elementFromPoint(r.left+1,r.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},m.prototype),g.prototype=Wi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},g.prototype),e.scrollbarModel={"native":m,"null":g},L.prototype.signal=function(e,t){Ni(e,t)&&this.events.push(arguments)},L.prototype.finish=function(){for(var e=0;e=9&&n.hasSelection&&(n.hasSelection=null),n.poll()}),Ea(o,"paste",function(e){Ti(r,e)||J(e,r)||(r.state.pasteIncoming=!0,n.fastPoll())}),Ea(o,"cut",t),Ea(o,"copy",t),Ea(e.scroller,"paste",function(t){Gt(e,t)||Ti(r,t)||(r.state.pasteIncoming=!0,n.focus())}),Ea(e.lineSpace,"selectstart",function(t){Gt(e,t)||Ma(t)}),Ea(o,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ea(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,n=e.doc,r=De(e);if(e.options.moveInputWithCursor){var i=dt(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},showSelection:function(e){var t=this.cm,n=t.display;qi(n.cursorDiv,e.cursors),qi(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,n,r=this.cm,i=r.doc;if(r.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=rl&&(o.to().line-o.from().line>100||(n=r.getSelection()).length>1e3);var a=t?"-":n||r.getSelection();this.textarea.value=a,r.state.focused&&Ua(this.textarea),xo&&bo>=9&&(this.hasSelection=a)}else e||(this.prevInput=this.textarea.value="",xo&&bo>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Ao||Gi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0; +},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))}var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,n=this.prevInput;if(this.contextMenuPending||!e.state.focused||nl(t)&&!n&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=t.value;if(r==n&&!e.somethingSelected())return!1;if(xo&&bo>=9&&this.hasSelection===r||Eo&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=r.charCodeAt(0);if(8203!=i||n||(n="​"),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(n.length,r.length);a>o&&n.charCodeAt(o)==r.charCodeAt(o);)++o;var l=this;return At(e,function(){Z(e,r.slice(o),n.length-o,null,l.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=r,l.composing&&(l.composing.range.clear(),l.composing.range=e.markText(l.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){xo&&bo>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=a.selectionStart){var e=i.somethingSelected(),t="​"+(e?a.value:"");a.value="⇚",a.value=t,r.prevInput=e?"":"​",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function n(){if(r.contextMenuPending=!1,r.wrapper.style.cssText=f,a.style.cssText=u,xo&&9>bo&&o.scrollbars.setScrollTop(o.scroller.scrollTop=s),null!=a.selectionStart){(!xo||xo&&9>bo)&&t();var e=0,n=function(){o.selForContextMenu==i.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&"​"==r.prevInput?Et(i,ua.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(n,500):o.input.reset()};o.detectingSelectAll=setTimeout(n,200)}}var r=this,i=r.cm,o=i.display,a=r.textarea,l=Yt(i,e),s=o.scroller.scrollTop;if(l&&!Co){var c=i.options.resetSelectionOnContextMenu;c&&-1==i.doc.sel.contains(l)&&Et(i,Te)(i.doc,de(l),Wa);var u=a.style.cssText,f=r.wrapper.style.cssText;r.wrapper.style.cssText="position: absolute";var h=r.wrapper.getBoundingClientRect();if(a.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px; z-index: 1000; background: "+(xo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",wo)var d=window.scrollY;if(o.input.focus(),wo&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(a.value=r.prevInput=" "),r.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),xo&&bo>=9&&t(),Do){Aa(e);var p=function(){Ia(window,"mouseup",p),setTimeout(n,20)};Ea(window,"mouseup",p)}else setTimeout(n,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:Di,needsContentAttribute:!1},ne.prototype),ie.prototype=Wi({init:function(e){function t(e){if(!Ti(r,e)){if(r.somethingSelected())Fo={lineWise:!1,text:r.getSelections()},"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=ee(r);Fo={lineWise:!0,text:t.text},"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,Wa),r.replaceSelection("",null,"cut")})}if(e.clipboardData&&!No)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Fo.text.join("\n"));else{var n=re(),i=n.firstChild;r.display.lineSpace.insertBefore(n,r.display.lineSpace.firstChild),i.value=Fo.text.join("\n");var o=document.activeElement;Ua(i),setTimeout(function(){r.display.lineSpace.removeChild(n),o.focus()},50)}}}var n=this,r=n.cm,i=n.div=e.lineDiv;te(i),Ea(i,"paste",function(e){Ti(r,e)||J(e,r)}),Ea(i,"compositionstart",function(e){var t=e.data;if(n.composing={sel:r.doc.sel,data:t,startData:t},t){var i=r.doc.sel.primary(),o=r.getLine(i.head.line),a=o.indexOf(t,Math.max(0,i.head.ch-t.length));a>-1&&a<=i.head.ch&&(n.composing.sel=de(Bo(i.head.line,a),Bo(i.head.line,a+t.length)))}}),Ea(i,"compositionupdate",function(e){n.composing.data=e.data}),Ea(i,"compositionend",function(e){var t=n.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||n.applyComposition(t),n.composing==t&&(n.composing=null)},50))}),Ea(i,"touchstart",function(){n.forceCompositionEnd()}),Ea(i,"input",function(){n.composing||!r.isReadOnly()&&n.pollContent()||At(n.cm,function(){Dt(r)})}),Ea(i,"copy",t),Ea(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),n=le(this.cm,e.anchorNode,e.anchorOffset),r=le(this.cm,e.focusNode,e.focusOffset);if(!n||n.bad||!r||r.bad||0!=_o(K(n,r),t.from())||0!=_o(V(n,r),t.to())){var i=oe(this.cm,t.from()),o=oe(this.cm,t.to());if(i||o){var a=this.cm.display.view,l=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var s=a[a.length-1].measure,c=s.maps?s.maps[s.maps.length-1]:s.map;o={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}}else i={node:a[0].measure.map[2],offset:0};try{var u=qa(i.node,i.offset,o.offset,o.node)}catch(f){}u&&(!go&&this.cm.state.focused?(e.collapse(i.node,i.offset),u.collapsed||e.addRange(u)):(e.removeAllRanges(),e.addRange(u)),l&&null==e.anchorNode?e.addRange(l):go&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){qi(this.cm.display.cursorDiv,e.cursors),qi(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Va(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():At(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var n=le(t,e.anchorNode,e.anchorOffset),r=le(t,e.focusNode,e.focusOffset);n&&r&&At(t,function(){Te(t.doc,de(n,r),Wa),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.linet.viewTo-1)return!1;var o;if(r.line==t.viewFrom||0==(o=Bt(e,r.line)))var a=ti(t.view[0].line),l=t.view[0].node;else var a=ti(t.view[o].line),l=t.view[o-1].node.nextSibling;var s=Bt(e,i.line);if(s==t.view.length-1)var c=t.viewTo-1,u=t.lineDiv.lastChild;else var c=ti(t.view[s+1].line)-1,u=t.view[s+1].node.previousSibling;for(var f=e.doc.splitLines(ce(e,l,u,a,c)),h=Jr(e.doc,Bo(a,0),Bo(c,Zr(e.doc,c).text.length));f.length>1&&h.length>1;)if(Ii(f)==Ii(h))f.pop(),h.pop(),c--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),a++}for(var d=0,p=0,m=f[0],g=h[0],v=Math.min(m.length,g.length);v>d&&m.charCodeAt(d)==g.charCodeAt(d);)++d;for(var y=Ii(f),x=Ii(h),b=Math.min(y.length-(1==f.length?d:0),x.length-(1==h.length?d:0));b>p&&y.charCodeAt(y.length-p-1)==x.charCodeAt(x.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var w=Bo(a,d),k=Bo(c,h.length?Ii(h).length-p:0);return f.length>1||f[0]||_o(w,k)?(In(e.doc,f,w,k,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?Et(this.cm,Dt)(this.cm):e.data&&e.data!=e.startData&&Et(this.cm,Z)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||Et(this.cm,Z)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:Di,resetPosition:Di,needsContentAttribute:!0},ie.prototype),e.inputStyles={textarea:ne,contenteditable:ie},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t=0&&_o(e,r.to())<=0)return n}return-1}},fe.prototype={from:function(){return K(this.anchor,this.head)},to:function(){return V(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var zo,jo,Uo,qo={left:0,right:0,top:0,bottom:0},Go=null,Yo=0,$o=0,Vo=0,Ko=null;xo?Ko=-.53:go?Ko=15:So?Ko=-.7:Lo&&(Ko=-1/3);var Xo=function(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}};e.wheelEventPixels=function(e){var t=Xo(e);return t.x*=Ko,t.y*=Ko,t};var Zo=new Ei,Jo=null,Qo=e.changeEnd=function(e){return e.text?Bo(e.from.line+e.text.length-1,Ii(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var n=this.options,r=n[e];n[e]==t&&"mode"!=e||(n[e]=t,ta.hasOwnProperty(e)&&Et(this,ta[e])(this,t,r))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"]($n(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(Fn(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Bn(this));else{var o=i.from(),a=i.to(),l=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var s=l;n>s;++s)Fn(this,s,e);var c=this.doc.sel.ranges;0==o.ch&&t.length==c.length&&c[r].from().ch>0&&ke(this.doc,r,new fe(o,c[r].to()),Wa)}}}),getTokenAt:function(e,t){return Ir(this,e,t)},getLineTokens:function(e,t){return Ir(this,Bo(e),t,!0)},getTokenTypeAt:function(e){e=me(this.doc,e);var t,n=Dr(this,Zr(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]l?t:0==l?null:t.slice(0,l-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!la.hasOwnProperty(t))return n;var r=la[t],i=this.getModeAt(e);if("string"==typeof i[t])r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var o=0;oi&&(e=i,r=!0),n=Zr(this.doc,e)}else n=e;return ut(this,n,{top:0,left:0},t||"page").top+(r?this.doc.height-ri(n):0)},defaultTextHeight:function(){return yt(this.display)},defaultCharWidth:function(){return xt(this.display)},setGutterMarker:Ot(function(e,t,n){return zn(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Fi(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Ot(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,Ht(t,r,"gutter"),Fi(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Zr(this.doc,e),!e)return null}else{var t=ti(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display;e=dt(this,me(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)a=e.top;else if("above"==r||"near"==r){var s=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>c&&(l=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),n&&Dn(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:Ot(hn),triggerOnKeyPress:Ot(mn),triggerOnKeyUp:pn,execCommand:function(e){return ua.hasOwnProperty(e)?ua[e].call(null,this):void 0},triggerElectric:Ot(function(e){Q(this,e)}),findPosH:function(e,t,n,r){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=me(this.doc,e);t>o&&(a=Un(this.doc,a,i,n,r),!a.hitSide);++o);return a},moveH:Ot(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?Un(n.doc,r.head,e,t,n.options.rtlMoveVisually):0>e?r.from():r.to()},_a)}),deleteH:Ot(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):jn(this,function(n){var i=Un(r,n.head,e,t,!1);return 0>e?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,o=r;0>t&&(i=-1,t=-t);for(var a=0,l=me(this.doc,e);t>a;++a){var s=dt(this,l,"div");if(null==o?o=s.left:s.left=o,l=qn(this,s,i,n),l.hitSide)break}return l},moveV:Ot(function(e,t){var n=this,r=this.doc,i=[],o=!n.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var l=dt(n,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=qn(n,l,e,t);return"page"==t&&a==r.sel.primary()&&Wn(n,null,ht(n,s,"div").top-l.top),s},_a),i.length)for(var a=0;a0&&l(n.charAt(r-1));)--r;for(;i.5)&&a(this),Pa(this,"refresh",this)}),swapDoc:Ot(function(e){var t=this.doc;return t.cm=null,Xr(this,e),lt(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Ci(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ai(e);var ea=e.defaults={},ta=e.optionHandlers={},na=e.Init={toString:function(){return"CodeMirror.Init"}};Gn("value","",function(e,t){e.setValue(t)},!0),Gn("mode",null,function(e,t){e.doc.modeOption=t,n(e)},!0),Gn("indentUnit",2,n,!0),Gn("indentWithTabs",!1),Gn("smartIndent",!0),Gn("tabSize",4,function(e){r(e),lt(e),Dt(e)},!0),Gn("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(Bo(r,o))}r++});for(var i=n.length-1;i>=0;i--)In(e.doc,t,n[i],Bo(n[i].line,n[i].ch+t.length))}}),Gn("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,n,r){t.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),r!=e.Init&&t.refresh()}),Gn("specialCharPlaceholder",_r,function(e){e.refresh()},!0),Gn("electricChars",!0),Gn("inputStyle",Ao?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Gn("rtlMoveVisually",!Io),Gn("wholeLineUpdateBefore",!0),Gn("theme","default",function(e){l(e),s(e)},!0),Gn("keyMap","default",function(t,n,r){var i=$n(n),o=r!=e.Init&&$n(r);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Gn("extraKeys",null),Gn("lineWrapping",!1,i,!0),Gn("gutters",[],function(e){d(e.options),s(e)},!0),Gn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?C(e.display)+"px":"0",e.refresh()},!0),Gn("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Gn("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Gn("lineNumbers",!1,function(e){d(e.options),s(e)},!0),Gn("firstLineNumber",1,s,!0),Gn("lineNumberFormatter",function(e){return e},s,!0),Gn("showCursorWhenSelecting",!1,Re,!0),Gn("resetSelectionOnContextMenu",!0),Gn("lineWiseCopyCut",!0),Gn("readOnly",!1,function(e,t){"nocursor"==t?(yn(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Gn("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Gn("dragDrop",!0,Ut),Gn("allowDropFileTypes",null),Gn("cursorBlinkRate",530),Gn("cursorScrollMargin",0),Gn("cursorHeight",1,Re,!0),Gn("singleCursorHeightPerLine",!0,Re,!0),Gn("workTime",100),Gn("workDelay",100),Gn("flattenSpans",!0,r,!0),Gn("addModeClass",!1,r,!0),Gn("pollInterval",100),Gn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Gn("historyEventDelay",1250),Gn("viewportMargin",10,function(e){e.refresh()},!0),Gn("maxHighlightLength",1e4,r,!0),Gn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Gn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Gn("autofocus",null);var ra=e.modes={},ia=e.mimeModes={};e.defineMode=function(t,n){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),ra[t]=n},e.defineMIME=function(e,t){ia[e]=t},e.resolveMode=function(t){if("string"==typeof t&&ia.hasOwnProperty(t))t=ia[t];else if(t&&"string"==typeof t.name&&ia.hasOwnProperty(t.name)){var n=ia[t.name];"string"==typeof n&&(n={name:n}),t=Hi(n,t),t.name=n.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,n){var n=e.resolveMode(n),r=ra[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(oa.hasOwnProperty(n.name)){var o=oa[n.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var a in n.modeProps)i[a]=n.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var oa=e.modeExtensions={};e.extendMode=function(e,t){var n=oa.hasOwnProperty(e)?oa[e]:oa[e]={};Wi(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){Ca.prototype[e]=t},e.defineOption=Gn;var aa=[];e.defineInitHook=function(e){aa.push(e)};var la=e.helpers={};e.registerHelper=function(t,n,r){la.hasOwnProperty(t)||(la[t]=e[t]={_global:[]}),la[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),la[t]._global.push({pred:r,val:i})};var sa=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},ca=e.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};e.innerMode=function(e,t){for(;e.innerMode;){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var ua=e.commands={selectAll:function(e){e.setSelection(Bo(e.firstLine(),0),Bo(e.lastLine()),Wa)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Wa)},killLine:function(e){jn(e,function(t){if(t.empty()){var n=Zr(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new Bo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Bo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=Zr(e.doc,i.line-1).text;a&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),Bo(i.line-1,a.length-1),Bo(i.line,1),"+transpose")}n.push(new fe(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){At(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange(e.doc.lineSeparator(),r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0)}Bn(e)})},openLine:function(e){e.replaceSelection("\n","start")},toggleOverwrite:function(e){e.toggleOverwrite()}},fa=e.keyMap={};fa.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},fa.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},fa.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},fa.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},fa["default"]=Eo?fa.macDefault:fa.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=Ri(n.split(" "),Yn),o=0;o=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.post},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ga=0,va=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ga};Ai(va),va.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&bt(e),Ni(this,"clear")){var n=this.find();n&&Ci(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&Dt(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ae(e.doc)),e&&Ci(e,"markerCleared",e,this),t&&kt(e),this.parent&&this.parent.clear()}},va.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;in;++n){var i=this.lines[n];this.height-=i.height,Nr(i),Ci(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;re;++e)if(n(this.lines[e]))return!0}},Vr.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;ne){var o=Math.min(t,i-e),a=r.height;if(r.removeInner(e,o),this.height-=a-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof $r))){var l=[];this.collapse(l),this.children=[new $r(l)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t=e){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var a=i.lines.length%25+25,l=a;l10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;re){var a=Math.min(t,o-e);if(i.iterN(e,a,n))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var Sa=0,Ca=e.Doc=function(e,t,n,r){if(!(this instanceof Ca))return new Ca(e,t,n,r);null==n&&(n=0),Vr.call(this,[new $r([new ba("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var i=Bo(n,0);this.sel=de(i),this.history=new oi(null),this.id=++Sa,this.modeOption=t,this.lineSep=r,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Yr(this,{from:i,to:i,text:e}),Te(this,de(i),Wa)};Ca.prototype=Hi(Vr.prototype,{constructor:Ca,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r=0;o--)Tn(this,r[o]);l?Le(this,l):this.cm&&Bn(this.cm)}),undo:It(function(){Nn(this,"undo")}),redo:It(function(){Nn(this,"redo")}),undoSelection:It(function(){Nn(this,"undo",!0)}),redoSelection:It(function(){Nn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=me(this,e),t=me(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;l=s.to||null==s.from&&i!=e.line||null!=s.from&&i==t.line&&s.from>=t.ch||n&&!n(s.marker)||r.push(s.marker.parent||s.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;re?(t=e,!0):(e-=o,void++n)}),me(this,Bo(n,t))},indexFromPos:function(e){e=me(this,e);var t=e.ch;if(e.linet&&(t=e.from),null!=e.to&&e.tol||l>=t)return a+(t-o);a+=l-o,a+=n-a%n,o=l+1}},za=e.findColumn=function(e,t,n){for(var r=0,i=0;;){var o=e.indexOf(" ",r);-1==o&&(o=e.length);var a=o-r;if(o==e.length||i+a>=t)return r+Math.min(a,t-i);if(i+=o-r,i+=n-i%n,r=o+1,i>=t)return r}},ja=[""],Ua=function(e){e.select()};No?Ua=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:xo&&(Ua=function(e){try{e.select()}catch(t){}});var qa,Ga=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ya=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Ga.test(e))},$a=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;qa=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var Va=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};xo&&11>bo&&(Gi=function(){try{return document.activeElement}catch(e){return document.body}});var Ka,Xa,Za=e.rmClass=function(e,t){var n=e.className,r=Yi(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},Ja=e.addClass=function(e,t){var n=e.className;Yi(t).test(n)||(e.className+=(n?" ":"")+t)},Qa=!1,el=function(){if(xo&&9>bo)return!1;var e=ji("div");return"draggable"in e||"dragDrop"in e}(),tl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;r>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},nl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},rl=function(){var e=ji("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),il=null,ol=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)ol[e+48]=ol[e+96]=String(e);for(var e=65;90>=e;e++)ol[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)ol[e+111]=ol[e+63235]="F"+e}();var al,ll=function(){function e(e){return 247>=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?r.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",r="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,l=/[Lb1n]/,s=/[1n]/,c="L";return function(n){if(!i.test(n))return!1;for(var r,u=n.length,f=[],h=0;u>h;++h)f.push(r=e(n.charCodeAt(h)));for(var h=0,d=c;u>h;++h){var r=f[h];"m"==r?f[h]=d:d=r}for(var h=0,p=c;u>h;++h){var r=f[h];"1"==r&&"r"==p?f[h]="n":a.test(r)&&(p=r,"r"==r&&(f[h]="R"))}for(var h=1,d=f[0];u-1>h;++h){var r=f[h];"+"==r&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=r||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=r}for(var h=0;u>h;++h){var r=f[h];if(","==r)f[h]="N";else if("%"==r){for(var m=h+1;u>m&&"%"==f[m];++m);for(var g=h&&"!"==f[h-1]||u>m&&"1"==f[m]?"1":"N",v=h;m>v;++v)f[v]=g;h=m-1}}for(var h=0,p=c;u>h;++h){var r=f[h];"L"==p&&"1"==r?f[h]="L":a.test(r)&&(p=r)}for(var h=0;u>h;++h)if(o.test(f[h])){for(var m=h+1;u>m&&o.test(f[m]);++m);for(var y="L"==(h?f[h-1]:c),x="L"==(u>m?f[m]:c),g=y||x?"L":"R",v=h;m>v;++v)f[v]=g;h=m-1}for(var b,w=[],h=0;u>h;)if(l.test(f[h])){var k=h;for(++h;u>h&&l.test(f[h]);++h);w.push(new t(0,k,h))}else{var S=h,C=w.length;for(++h;u>h&&"L"!=f[h];++h);for(var v=S;h>v;)if(s.test(f[v])){v>S&&w.splice(C,0,new t(1,S,v));var L=v;for(++v;h>v&&s.test(f[v]);++v);w.splice(C,0,new t(2,L,v)),S=v}else++v;h>S&&w.splice(C,0,new t(1,S,h))}return 1==w[0].level&&(b=n.match(/^\s+/))&&(w[0].from=b[0].length,w.unshift(new t(0,0,b[0].length))),1==Ii(w).level&&(b=n.match(/\s+$/))&&(Ii(w).to-=b[0].length,w.push(new t(0,u-b[0].length,u))),2==w[0].level&&w.unshift(new t(1,w[0].to,w[0].to)),w[0].level!=Ii(w).level&&w.push(new t(w[0].level,u,u)),w}}();return e.version="5.15.2",e})},{}],11:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror"),t("../markdown/markdown"),t("../../addon/mode/overlay")):"function"==typeof e&&e.amd?e(["../../lib/codemirror","../markdown/markdown","../../addon/mode/overlay"],i):i(CodeMirror)}(function(e){"use strict";var t=/^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;e.defineMode("gfm",function(n,r){function i(e){return e.code=!1,null}var o=0,a={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,n){if(n.combineTokens=null,n.codeBlock)return e.match(/^```+/)?(n.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(n.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),n.codeBlock=!0,null;if("`"===e.peek()){e.next();var i=e.pos;e.eatWhile("`");var a=1+e.pos-i;return n.code?a===o&&(n.code=!1):(o=a,n.code=!0),null}if(n.code)return e.next(),null;if(e.eatSpace())return n.ateSpace=!0,null;if((e.sol()||n.ateSpace)&&(n.ateSpace=!1,r.gitHubSpice!==!1)){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/))return n.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return n.combineTokens=!0,"link"}return e.match(t)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1)))?(n.combineTokens=!0,"link"):(e.next(),null)},blankLine:i},l={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var s in r)l[s]=r[s];return l.name="markdown",e.overlayMode(e.getMode(n,l),a)},"markdown"),e.defineMIME("text/x-gfm","gfm")})},{"../../addon/mode/overlay":8,"../../lib/codemirror":10,"../markdown/markdown":12}],12:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror"),t("../xml/xml"),t("../meta")):"function"==typeof e&&e.amd?e(["../../lib/codemirror","../xml/xml","../meta"],i):i(CodeMirror)}(function(e){"use strict";e.defineMode("markdown",function(t,n){function r(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}function i(e,t,n){return t.f=t.inline=n,n(e,t)}function o(e,t,n){return t.f=t.block=n,n(e,t)}function a(e){return!e||!/\S/.test(e.string)}function l(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,k&&e.f==c&&(e.f=p,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine=null,null}function s(t,o){var l=t.sol(),s=o.list!==!1,c=o.indentedCode;o.indentedCode=!1,s&&(o.indentationDiff>=0?(o.indentationDiff<4&&(o.indentation-=o.indentationDiff),o.list=null):o.indentation>0?o.list=null:o.list=!1);var f=null;if(o.indentationDiff>=4)return t.skipToEnd(),c||a(o.prevLine)?(o.indentation-=4,o.indentedCode=!0,S.code):null;if(t.eatSpace())return null;if((f=t.match(A))&&f[1].length<=6)return o.header=f[1].length,n.highlightFormatting&&(o.formatting="header"),o.f=o.inline,h(o);if(!(a(o.prevLine)||o.quote||s||c)&&(f=t.match(E)))return o.header="="==f[0].charAt(0)?1:2,n.highlightFormatting&&(o.formatting="header"),o.f=o.inline,h(o);if(t.eat(">"))return o.quote=l?1:o.quote+1,n.highlightFormatting&&(o.formatting="quote"),t.eatSpace(),h(o);if("["===t.peek())return i(t,o,y);if(t.match(L,!0))return o.hr=!0,S.hr;if((a(o.prevLine)||s)&&(t.match(T,!1)||t.match(M,!1))){var d=null;for(t.match(T,!0)?d="ul":(t.match(M,!0),d="ol"),o.indentation=t.column()+t.current().length,o.list=!0;o.listStack&&t.column()")>-1)&&(n.f=p,n.block=s,n.htmlState=null)}return r}function u(e,t){return t.fencedChars&&e.match(t.fencedChars,!1)?(t.localMode=t.localState=null,t.f=t.block=f,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),S.code)}function f(e,t){e.match(t.fencedChars),t.block=s,t.f=p,t.fencedChars=null,n.highlightFormatting&&(t.formatting="code-block"),t.code=1;var r=h(t);return t.code=0,r}function h(e){var t=[];if(e.formatting){t.push(S.formatting),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r=e.quote?t.push(S.formatting+"-"+e.formatting[r]+"-"+e.quote):t.push("error"))}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(S.linkHref,"url"):(e.strong&&t.push(S.strong),e.em&&t.push(S.em),e.strikethrough&&t.push(S.strikethrough),e.linkText&&t.push(S.linkText),e.code&&t.push(S.code)),e.header&&t.push(S.header,S.header+"-"+e.header),e.quote&&(t.push(S.quote),!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?t.push(S.quote+"-"+e.quote):t.push(S.quote+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listStack.length-1)%3;i?1===i?t.push(S.list2):t.push(S.list3):t.push(S.list1)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}function d(e,t){return e.match(O,!0)?h(t):void 0}function p(t,r){var i=r.text(t,r);if("undefined"!=typeof i)return i;if(r.list)return r.list=null,h(r);if(r.taskList){var a="x"!==t.match(N,!0)[1];return a?r.taskOpen=!0:r.taskClosed=!0,n.highlightFormatting&&(r.formatting="task"),r.taskList=!1,h(r)}if(r.taskOpen=!1,r.taskClosed=!1,r.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(r.formatting="header"), +h(r);var l=t.sol(),s=t.next();if(r.linkTitle){r.linkTitle=!1;var u=s;"("===s&&(u=")"),u=(u+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var f="^\\s*(?:[^"+u+"\\\\]+|\\\\\\\\|\\\\.)"+u;if(t.match(new RegExp(f),!0))return S.linkHref}if("`"===s){var d=r.formatting;n.highlightFormatting&&(r.formatting="code"),t.eatWhile("`");var p=t.current().length;if(0==r.code)return r.code=p,h(r);if(p==r.code){var v=h(r);return r.code=0,v}return r.formatting=d,h(r)}if(r.code)return h(r);if("\\"===s&&(t.next(),n.highlightFormatting)){var y=h(r),x=S.formatting+"-escape";return y?y+" "+x:x}if("!"===s&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),r.inline=r.f=g,S.image;if("["===s&&t.match(/[^\]]*\](\(.*\)| ?\[.*?\])/,!1))return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),h(r);if("]"===s&&r.linkText&&t.match(/\(.*?\)| ?\[.*?\]/,!1)){n.highlightFormatting&&(r.formatting="link");var y=h(r);return r.linkText=!1,r.inline=r.f=g,y}if("<"===s&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=h(r);return y?y+=" ":y="",y+S.linkInline}if("<"===s&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=h(r);return y?y+=" ":y="",y+S.linkEmail}if("<"===s&&t.match(/^(!--|\w)/,!1)){var b=t.string.indexOf(">",t.pos);if(-1!=b){var k=t.string.substring(t.start,b);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(k)&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(w),o(t,r,c)}if("<"===s&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";var C=!1;if(!n.underscoresBreakWords&&"_"===s&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var L=t.pos-2;if(L>=0){var T=t.string.charAt(L);"_"!==T&&T.match(/(\w)/,!1)&&(C=!0)}}if("*"===s||"_"===s&&!C)if(l&&" "===t.peek());else{if(r.strong===s&&t.eat(s)){n.highlightFormatting&&(r.formatting="strong");var v=h(r);return r.strong=!1,v}if(!r.strong&&t.eat(s))return r.strong=s,n.highlightFormatting&&(r.formatting="strong"),h(r);if(r.em===s){n.highlightFormatting&&(r.formatting="em");var v=h(r);return r.em=!1,v}if(!r.em)return r.em=s,n.highlightFormatting&&(r.formatting="em"),h(r)}else if(" "===s&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return h(r);t.backUp(1)}if(n.strikethrough)if("~"===s&&t.eatWhile(s)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var v=h(r);return r.strikethrough=!1,v}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),h(r)}else if(" "===s&&t.match(/^~~/,!0)){if(" "===t.peek())return h(r);t.backUp(2)}return" "===s&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),h(r)}function m(e,t){var r=e.next();if(">"===r){t.f=t.inline=p,n.highlightFormatting&&(t.formatting="link");var i=h(t);return i?i+=" ":i="",i+S.linkInline}return e.match(/^[^>]+/,!0),S.linkInline}function g(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=v("("===r?")":"]",0),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,h(t)):"error"}function v(e){return function(t,r){var i=t.next();if(i===e){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link-string");var o=h(r);return r.linkHref=!1,o}return t.match(P[e]),r.linkHref=!0,h(r)}}function y(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=x,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,h(t)):i(e,t,p)}function x(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=b,n.highlightFormatting&&(t.formatting="link");var r=h(t);return t.linkText=!1,r}return e.match(/^([^\]\\]|\\.)+/,!0),S.linkText}function b(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=p,S.linkHref+" url")}var w=e.getMode(t,"text/html"),k="null"==w.name;void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.underscoresBreakWords&&(n.underscoresBreakWords=!0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1),void 0===n.tokenTypeOverrides&&(n.tokenTypeOverrides={});var S={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"tag",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough"};for(var C in S)S.hasOwnProperty(C)&&n.tokenTypeOverrides[C]&&(S[C]=n.tokenTypeOverrides[C]);var L=/^([*\-_])(?:\s*\1){2,}\s*$/,T=/^[*\-+]\s+/,M=/^[0-9]+([.)])\s+/,N=/^\[(x| )\](?=\s)/,A=n.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,E=/^ *(?:\={1,}|-{1,})\s*$/,O=/^[^#!\[\]*_\\<>` "'(~]+/,I=new RegExp("^("+(n.fencedCodeBlocks===!0?"~~~+|```+":n.fencedCodeBlocks)+")[ \\t]*([\\w+#-]*)"),P={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/},R={startState:function(){return{f:s,prevLine:null,thisLine:null,block:s,htmlState:null,indentation:0,inline:p,text:d,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t.thisLine,block:t.block,htmlState:t.htmlState&&e.copyState(w,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?e.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listStack:t.listStack.slice(0),quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine){var n=t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n){if(l(t),!n)return null;t.prevLine=null}t.prevLine=t.thisLine,t.thisLine=e,t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.f=t.block;var r=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(t.indentationDiff=Math.min(r-t.indentation,4),t.indentation=t.indentation+t.indentationDiff,r>0)return null}return t.f(e,t)},innerMode:function(e){return e.block==c?{state:e.htmlState,mode:w}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:R}},blankLine:l,getType:h,fold:"markdown"};return R},"xml"),e.defineMIME("text/x-markdown","markdown")})},{"../../lib/codemirror":10,"../meta":13,"../xml/xml":14}],13:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../lib/codemirror")):"function"==typeof e&&e.amd?e(["../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";e.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["pgp"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists.txt$/},{name:"CoffeeScript",mime:"text/x-coffeescript",mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history).md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"]},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Jade",mime:"text/x-jade",mode:"jade",ext:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"null",mode:"jinja2"},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mime:"text/n-triples",mode:"ntriples",ext:["nt"]},{name:"Objective C",mime:"text/x-objectivec",mode:"clike",ext:["m","mm"],alias:["objective-c","objc"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mime:"application/x-httpd-php",mode:"php",ext:["php","php3","php4","php5","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mime:"text/x-sh",mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki ",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mime:"text/x-yaml",mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]}];for(var t=0;t-1&&t.substring(i+1,t.length);return o?e.findModeByExtension(o):void 0},e.findModeByName=function(t){t=t.toLowerCase();for(var n=0;n")):null:e.match("--")?n(s("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(c(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=s("meta","?>"),"meta"):(T=e.eat("/")?"closeTag":"openTag",t.tokenize=a,"tag bracket");if("&"==r){var i;return i=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function a(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=o,T=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return T="equals",null;if("<"==n){t.tokenize=o,t.state=d,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=l(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function l(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=a;break}return"string"};return t.isInAttribute=!0,t}function s(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=o;break}n.next()}return e}}function c(e){return function(t,n){for(var r;null!=(r=t.next());){if("<"==r)return n.tokenize=c(e+1),n.tokenize(t,n);if(">"==r){if(1==e){n.tokenize=o;break}return n.tokenize=c(e-1),n.tokenize(t,n)}}return"meta"}}function u(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(S.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function f(e){e.context&&(e.context=e.context.prev)}function h(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!S.contextGrabbers.hasOwnProperty(n)||!S.contextGrabbers[n].hasOwnProperty(t))return;f(e)}}function d(e,t,n){return"openTag"==e?(n.tagStart=t.column(),p):"closeTag"==e?m:d}function p(e,t,n){return"word"==e?(n.tagName=t.current(),M="tag",y):(M="error",p)}function m(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&S.implicitlyClosed.hasOwnProperty(n.context.tagName)&&f(n),n.context&&n.context.tagName==r||S.matchClosing===!1?(M="tag",g):(M="tag error",v)}return M="error",v}function g(e,t,n){return"endTag"!=e?(M="error",g):(f(n),d)}function v(e,t,n){return M="error",g(e,t,n)}function y(e,t,n){if("word"==e)return M="attribute",x;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||S.autoSelfClosers.hasOwnProperty(r)?h(n,r):(h(n,r),n.context=new u(n,r,i==n.indented)),d}return M="error",y}function x(e,t,n){return"equals"==e?b:(S.allowMissing||(M="error"),y(e,t,n))}function b(e,t,n){return"string"==e?w:"word"==e&&S.allowUnquoted?(M="string",y):(M="error",y(e,t,n))}function w(e,t,n){return"string"==e?w:y(e,t,n)}var k=r.indentUnit,S={},C=i.htmlMode?t:n;for(var L in C)S[L]=C[L];for(var L in i)S[L]=i[L];var T,M;return o.isInText=!0,{startState:function(e){var t={tokenize:o,state:d,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;T=null;var n=t.tokenize(e,t);return(n||T)&&"comment"!=n&&(M=null,t.state=t.state(T||n,e,t),M&&(n="error"==M?n+" error":M)),n},indent:function(t,n,r){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+k;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=a&&t.tokenize!=o)return r?r.match(/^(\s*)/)[0].length:0;if(t.tagName)return S.multilineTagIndentPastTag!==!1?t.tagStart+t.tagName.length+2:t.tagStart+k*(S.multilineTagIndentFactor||1);if(S.alignCDATA&&/$/,blockCommentStart:"",configuration:S.htmlMode?"html":"xml",helperType:S.htmlMode?"html":"xml",skipAttribute:function(e){e.state==b&&(e.state=y)}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})})},{"../../lib/codemirror":10}],15:[function(e,t,n){n.read=function(e,t,n,r,i){var o,a,l=8*i-r-1,s=(1<>1,u=-7,f=n?i-1:0,h=n?-1:1,d=e[t+f];for(f+=h,o=d&(1<<-u)-1,d>>=-u,u+=l;u>0;o=256*o+e[t+f],f+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+f],f+=h,u-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var a,l,s,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),t+=a+f>=1?h/s:h*Math.pow(2,1-f),t*s>=2&&(a++,s/=2),a+f>=u?(l=0,a=u):a+f>=1?(l=(t*s-1)*Math.pow(2,i),a+=f):(l=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+d]=255&l,d+=p,l/=256,i-=8);for(a=a<0;e[n+d]=255&a,d+=p,a/=256,c-=8);e[n+d-p]|=128*m}},{}],16:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],17:[function(t,n,r){(function(t){(function(){function t(e){this.tokens=[],this.tokens.links={},this.options=e||h.defaults,this.rules=d.normal,this.options.gfm&&(this.options.tables?this.rules=d.tables:this.rules=d.gfm)}function i(e,t){if(this.options=t||h.defaults,this.links=e,this.rules=p.normal,this.renderer=this.options.renderer||new o,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=p.breaks:this.rules=p.gfm:this.options.pedantic&&(this.rules=p.pedantic)}function o(e){this.options=e||{}}function a(e){this.tokens=[],this.token=null,this.options=e||h.defaults,this.options.renderer=this.options.renderer||new o,this.renderer=this.options.renderer,this.renderer.options=this.options}function l(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function c(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function u(){}function f(e){for(var t,n,r=1;rAn error occured:

    "+l(u.message+"",!0)+"
    ";throw u}}var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:u,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:u,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:u,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/,d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,d.item=c(d.item,"gm")(/bull/g,d.bullet)(),d.list=c(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")(),d.blockquote=c(d.blockquote)("def",d.def)(),d._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",d.html=c(d.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,d._tag)(),d.paragraph=c(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=f({},d),d.gfm=f({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=c(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=f({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,l,s,c,u,f,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},u=0;u ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],this.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(this.rules.item),r=!1,f=o.length,u=0;f>u;u++)s=o[u],c=s.length,s=s.replace(/^ *([*+-]|\d+\.) +/,""),~s.indexOf("\n ")&&(c-=s.length,s=this.options.pedantic?s.replace(/^ {1,4}/gm,""):s.replace(new RegExp("^ {1,"+c+"}","gm"),"")),this.options.smartLists&&u!==f-1&&(l=d.bullet.exec(o[u+1])[0],a===l||a.length>1&&l.length>1||(e=o.slice(u+1).join("\n")+e,u=f-1)),i=r||/\n\n(?!\s*$)/.test(s),u!==f-1&&(r="\n"===s.charAt(s.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(s,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),s={type:"table", +header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:u,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:u,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=c(p.link)("inside",p._inside)("href",p._href)(),p.reflink=c(p.reflink)("inside",p._inside)(),p.normal=f({},p),p.pedantic=f({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=f({},p.normal,{escape:c(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:c(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=f({},p.gfm,{br:c(p.br)("{2,}","*")(),text:c(p.gfm.text)("{2,}","*")()}),i.rules=p,i.output=function(e,t,n){var r=new i(t,n);return r.output(e)},i.prototype.output=function(e){for(var t,n,r,i,o="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),o+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1]),r=this.mangle("mailto:")+n):(n=l(i[1]),r=n),o+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):l(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,o+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){o+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),o+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),o+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),o+=this.renderer.codespan(l(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),o+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),o+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),o+=this.renderer.text(l(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=l(i[1]),r=n,o+=this.renderer.link(r,null,n);return o},i.prototype.outputLink=function(e,t){var n=l(t.href),r=t.title?l(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,l(e[1]))},i.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},i.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;r>i;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},o.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
    '+(n?e:l(e,!0))+"\n
    \n":"
    "+(n?e:l(e,!0))+"\n
    "},o.prototype.blockquote=function(e){return"
    \n"+e+"
    \n"},o.prototype.html=function(e){return e},o.prototype.heading=function(e,t,n){return"'+e+"\n"},o.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"},o.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},o.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},o.prototype.paragraph=function(e){return"

    "+e+"

    \n"},o.prototype.table=function(e,t){return"\n\n"+e+"\n\n"+t+"\n
    \n"},o.prototype.tablerow=function(e){return"\n"+e+"\n"},o.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},o.prototype.strong=function(e){return""+e+""},o.prototype.em=function(e){return""+e+""},o.prototype.codespan=function(e){return""+e+""},o.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},o.prototype.del=function(e){return""+e+""},o.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(s(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var o='
    "},o.prototype.image=function(e,t,n){var r=''+n+'":">"},o.prototype.text=function(e){return e},a.parse=function(e,t,n){var r=new a(t,n);return r.parse(e)},a.prototype.parse=function(e){this.inline=new i(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},a.prototype.next=function(){return this.token=this.tokens.pop()},a.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},a.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},a.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i,o="",a="";for(n="",e=0;ea;a++)for(var s=this.compoundRules[a],c=0,u=s.length;u>c;c++)this.compoundRuleCodes[s[c]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(n);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,l=this.compoundRules.length;l>a;a++){for(var f=this.compoundRules[a],h="",c=0,u=f.length;u>c;c++){var d=f[c];h+=d in this.compoundRuleCodes?"("+this.compoundRuleCodes[d].join("|")+")":d}this.compoundRules[a]=new RegExp(h,"i")}}return this};i.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(t,r){if(r||(r="utf8"),"undefined"!=typeof XMLHttpRequest){var i=new XMLHttpRequest;return i.open("GET",t,!1),i.overrideMimeType&&i.overrideMimeType("text/plain; charset="+r),i.send(null),i.responseText}if("undefined"!=typeof e){var o=e("fs");try{if(o.existsSync(t)){var a=o.statSync(t),l=o.openSync(t,"r"),s=new n(a.size);return o.readSync(l,s,0,s.length,null),s.toString(r,0,s.length)}console.log("Path "+t+" does not exist.")}catch(c){return console.log(c),""}}},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var n=e.split("\n"),r=0,i=n.length;i>r;r++){var o=n[r],a=o.split(/\s+/),l=a[0];if("PFX"==l||"SFX"==l){for(var s=a[1],c=a[2],u=parseInt(a[3],10),f=[],h=r+1,d=r+1+u;d>h;h++){var o=n[h],p=o.split(/\s+/),m=p[2],g=p[3].split("/"),v=g[0];"0"===v&&(v="");var y=this.parseRuleCodes(g[1]),x=p[4],b={};b.add=v,y.length>0&&(b.continuationClasses=y),"."!==x&&("SFX"===l?b.match=new RegExp(x+"$"):b.match=new RegExp("^"+x)),"0"!=m&&("SFX"===l?b.remove=new RegExp(m+"$"):b.remove=m),f.push(b)}t[s]={type:l,combineable:"Y"==c,entries:f},r+=u}else if("COMPOUNDRULE"===l){for(var u=parseInt(a[1],10),h=r+1,d=r+1+u;d>h;h++){var o=n[h],p=o.split(/\s+/);this.compoundRules.push(p[1])}r+=u}else if("REP"===l){var p=o.split(/\s+/);3===p.length&&this.replacementTable.push([p[1],p[2]])}else this.flags[l]=a[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in r&&"object"==typeof r[e]||(r[e]=[]),r[e].push(t)}e=this._removeDicComments(e);for(var n=e.split("\n"),r={},i=1,o=n.length;o>i;i++){var a=n[i],l=a.split("/",2),s=l[0];if(l.length>1){var c=this.parseRuleCodes(l[1]);"NEEDAFFIX"in this.flags&&-1!=c.indexOf(this.flags.NEEDAFFIX)||t(s,c);for(var u=0,f=c.length;f>u;u++){var h=c[u],d=this.rules[h];if(d)for(var p=this._applyRule(s,d),m=0,g=p.length;g>m;m++){var v=p[m];if(t(v,[]),d.combineable)for(var y=u+1;f>y;y++){var x=c[y],b=this.rules[x];if(b&&b.combineable&&d.type!=b.type)for(var w=this._applyRule(v,b),k=0,S=w.length;S>k;k++){var C=w[k];t(C,[])}}}h in this.compoundRuleCodes&&this.compoundRuleCodes[h].push(s)}}else t(s.trim(),[])}return r},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],n=0,r=e.length;r>n;n+=2)t.push(e.substr(n,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var n=t.entries,r=[],i=0,o=n.length;o>i;i++){var a=n[i];if(!a.match||e.match(a.match)){var l=e;if(a.remove&&(l=l.replace(a.remove,"")),"SFX"===t.type?l+=a.add:l=a.add+l,r.push(l),"continuationClasses"in a)for(var s=0,c=a.continuationClasses.length;c>s;s++){var u=this.rules[a.continuationClasses[s]];u&&(r=r.concat(this._applyRule(l,u)))}}}return r},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var n=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}var r=t.toLowerCase();if(r!==t){if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if("undefined"==typeof t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var n=0,r=this.compoundRules.length;r>n;n++)if(e.match(this.compoundRules[n]))return!0;return!1}if("object"==typeof t){for(var n=0,r=t.length;r>n;n++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[n]))return!0;return!1}},hasFlag:function(e,t,n){if(t in this.flags){if("undefined"==typeof n)var n=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(n&&-1!==n.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function n(e){for(var t=[],n=0,r=e.length;r>n;n++){for(var i=e[n],o=[],a=0,l=i.length+1;l>a;a++)o.push([i.substring(0,a),i.substring(a,i.length)]);for(var s=[],a=0,l=o.length;l>a;a++){var u=o[a];u[1]&&s.push(u[0]+u[1].substring(1))}for(var f=[],a=0,l=o.length;l>a;a++){var u=o[a];u[1].length>1&&f.push(u[0]+u[1][1]+u[1][0]+u[1].substring(2))}for(var h=[],a=0,l=o.length;l>a;a++){var u=o[a];if(u[1])for(var d=0,p=c.alphabet.length;p>d;d++)h.push(u[0]+c.alphabet[d]+u[1].substring(1))}for(var m=[],a=0,l=o.length;l>a;a++){var u=o[a];if(u[1])for(var d=0,p=c.alphabet.length;p>d;d++)h.push(u[0]+c.alphabet[d]+u[1])}t=t.concat(s),t=t.concat(f),t=t.concat(h),t=t.concat(m)}return t}function r(e){for(var t=[],n=0;nu;u++)l[u]in s?s[l[u]]+=1:s[l[u]]=1;var h=[];for(var u in s)h.push([u,s[u]]);h.sort(i).reverse();for(var d=[],u=0,f=Math.min(t,h.length);f>u;u++)c.hasFlag(h[u][0],"NOSUGGEST")||d.push(h[u][0]);return d}if(t||(t=5),this.check(e))return[];for(var o=0,a=this.replacementTable.length;a>o;o++){var l=this.replacementTable[o];if(-1!==e.indexOf(l[0])){var s=e.replace(l[0],l[1]);if(this.check(s))return[s]}}var c=this;return c.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}},"undefined"!=typeof t&&(t.exports=i)}).call(this,e("buffer").Buffer,"/node_modules/typo-js")},{buffer:3,fs:2}],19:[function(e,t,n){var r=e("codemirror");r.commands.tabAndIndentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentMore");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}},r.commands.shiftTabAndUnindentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentLess");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}}},{codemirror:10}],20:[function(e,t,n){"use strict";function r(e){return e=U?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function i(e,t,n){e=e||{};var r=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(r.title=a(e.title,e.action,n),U&&(r.title=r.title.replace("Ctrl","⌘"),r.title=r.title.replace("Alt","⌥"))),r.tabIndex=-1,r.className=e.className,r}function o(){var e=document.createElement("i");return e.className="separator",e.innerHTML="|",e}function a(e,t,n){var i,o=e;return t&&(i=Y(t),n[i]&&(o+=" ("+r(n[i])+")")),o}function l(e,t){t=t||e.getCursor("start");var n=e.getTokenAt(t);if(!n.type)return{};for(var r,i,o=n.type.split(" "),a={},l=0;l=0&&(d=c.getLineHandle(o),!t(d));o--);var v,y,x,b,w=c.getTokenAt({line:o,ch:1}),k=n(w).fencedChars;t(c.getLineHandle(u.line))?(v="",y=u.line):t(c.getLineHandle(u.line-1))?(v="",y=u.line-1):(v=k+"\n",y=u.line),t(c.getLineHandle(f.line))?(x="",b=f.line,0===f.ch&&(b+=1)):0!==f.ch&&t(c.getLineHandle(f.line+1))?(x="",b=f.line+1):(x=k+"\n",b=f.line+1),0===f.ch&&(b-=1),c.operation(function(){c.replaceRange(x,{line:b,ch:0},{line:b+(x?0:1),ch:0}),c.replaceRange(v,{line:y,ch:0},{line:y+(v?0:1),ch:0})}),c.setSelection({line:y+(v?1:0),ch:0},{line:b+(v?1:-1),ch:0}),c.focus()}else{var S=u.line;if(t(c.getLineHandle(u.line))&&("fenced"===r(c,u.line+1)?(o=u.line,S=u.line+1):(a=u.line,S=u.line-1)),void 0===o)for(o=S;o>=0&&(d=c.getLineHandle(o),!t(d));o--);if(void 0===a)for(l=c.lineCount(),a=S;l>a&&(d=c.getLineHandle(a),!t(d));a++);c.operation(function(){c.replaceRange("",{line:o,ch:0},{line:o+1,ch:0}),c.replaceRange("",{line:a-1,ch:0},{line:a,ch:0})}),c.focus()}else if("indented"===p){if(u.line!==f.line||u.ch!==f.ch)o=u.line,a=f.line,0===f.ch&&a--;else{for(o=u.line;o>=0;o--)if(d=c.getLineHandle(o),!d.text.match(/^\s*$/)&&"indented"!==r(c,o,d)){o+=1;break}for(l=c.lineCount(),a=u.line;l>a;a++)if(d=c.getLineHandle(a),!d.text.match(/^\s*$/)&&"indented"!==r(c,a,d)){a-=1;break}}var C=c.getLineHandle(a+1),L=C&&c.getTokenAt({line:a+1,ch:C.text.length-1}),T=L&&n(L).indentedCode;T&&c.replaceRange("\n",{line:a+1,ch:0});for(var M=o;a>=M;M++)c.indentLine(M,"subtract");c.focus()}else{var N=u.line===f.line&&u.ch===f.ch&&0===u.ch,A=u.line!==f.line;N||A?i(c,u,f,s):E(c,!1,["`","`"])}}function d(e){var t=e.codemirror;I(t,"quote")}function p(e){var t=e.codemirror;O(t,"smaller")}function m(e){var t=e.codemirror;O(t,"bigger")}function g(e){var t=e.codemirror;O(t,void 0,1)}function v(e){var t=e.codemirror;O(t,void 0,2)}function y(e){var t=e.codemirror;O(t,void 0,3)}function x(e){var t=e.codemirror;I(t,"unordered-list")}function b(e){var t=e.codemirror;I(t,"ordered-list")}function w(e){var t=e.codemirror;R(t)}function k(e){var t=e.codemirror,n=l(t),r=e.options,i="http://";return r.promptURLs&&(i=prompt(r.promptTexts.link),!i)?!1:void E(t,n.link,r.insertTexts.link,i)}function S(e){var t=e.codemirror,n=l(t),r=e.options,i="http://";return r.promptURLs&&(i=prompt(r.promptTexts.image),!i)?!1:void E(t,n.image,r.insertTexts.image,i)}function C(e){var t=e.codemirror,n=l(t),r=e.options;E(t,n.table,r.insertTexts.table)}function L(e){var t=e.codemirror,n=l(t),r=e.options;E(t,n.image,r.insertTexts.horizontalRule)}function T(e){var t=e.codemirror;t.undo(),t.focus()}function M(e){var t=e.codemirror;t.redo(),t.focus()}function N(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.nextSibling,i=e.toolbarElements["side-by-side"],o=!1;/editor-preview-active-side/.test(r.className)?(r.className=r.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||s(e),r.className+=" editor-preview-active-side"},1),i.className+=" active",n.className+=" CodeMirror-sided",o=!0);var a=n.lastChild;if(/editor-preview-active/.test(a.className)){a.className=a.className.replace(/\s*editor-preview-active\s*/g,"");var l=e.toolbarElements.preview,c=n.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),c.className=c.className.replace(/\s*disabled-for-preview*/g,"")}var u=function(){r.innerHTML=e.options.previewRender(e.value(),r)};t.sideBySideRenderingFunction||(t.sideBySideRenderingFunction=u),o?(r.innerHTML=e.options.previewRender(e.value(),r),t.on("update",t.sideBySideRenderingFunction)):t.off("update",t.sideBySideRenderingFunction),t.refresh()}function A(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.previousSibling,i=e.options.toolbar?e.toolbarElements.preview:!1,o=n.lastChild;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),i&&(i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*disabled-for-preview*/g,""))):(setTimeout(function(){o.className+=" editor-preview-active"},1),i&&(i.className+=" active",r.className+=" disabled-for-preview")),o.innerHTML=e.options.previewRender(e.value(),o);var a=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(a.className)&&N(e)}function E(e,t,n,r){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=n[0],a=n[1],l=e.getCursor("start"),s=e.getCursor("end");r&&(a=a.replace("#url#",r)),t?(i=e.getLine(l.line),o=i.slice(0,l.ch),a=i.slice(l.ch),e.replaceRange(o+a,{line:l.line,ch:0})):(i=e.getSelection(),e.replaceSelection(o+i+a),l.ch+=o.length,l!==s&&(s.ch+=o.length)),e.setSelection(l,s),e.focus()}}function O(e,t,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var r=e.getCursor("start"),i=e.getCursor("end"),o=r.line;o<=i.line;o++)!function(r){var i=e.getLine(r),o=i.search(/[^#]/);i=void 0!==t?0>=o?"bigger"==t?"###### "+i:"# "+i:6==o&&"smaller"==t?i.substr(7):1==o&&"bigger"==t?i.substr(2):"bigger"==t?i.substr(1):"#"+i:1==n?0>=o?"# "+i:o==n?i.substr(o+1):"# "+i.substr(o+1):2==n?0>=o?"## "+i:o==n?i.substr(o+1):"## "+i.substr(o+1):0>=o?"### "+i:o==n?i.substr(o+1):"### "+i.substr(o+1),e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(o);e.focus()}}function I(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n=l(e),r=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},a={quote:"> ","unordered-list":"* ","ordered-list":"1. "},s=r.line;s<=i.line;s++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):a[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(s);e.focus()}}function P(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r="undefined"==typeof r?n:r;var i,o=e.codemirror,a=l(o),s=n,c=r,u=o.getCursor("start"),f=o.getCursor("end");a[t]?(i=o.getLine(u.line),s=i.slice(0,u.ch),c=i.slice(u.ch),"bold"==t?(s=s.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),c=c.replace(/(\*\*|__)/,"")):"italic"==t?(s=s.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),c=c.replace(/(\*|_)/,"")):"strikethrough"==t&&(s=s.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),c=c.replace(/(\*\*|~~)/,"")),o.replaceRange(s+c,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==f&&(f.ch-=2)):"italic"==t&&(u.ch-=1,u!==f&&(f.ch-=1))):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t?(i=i.split("*").join(""),i=i.split("_").join("")):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(s+i+c),u.ch+=n.length,f.ch=u.ch+i.length),o.setSelection(u,f),o.focus()}}function R(e){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className))for(var t,n=e.getCursor("start"),r=e.getCursor("end"),i=n.line;i<=r.line;i++)t=e.getLine(i),t=t.replace(/^[ ]*([# ]+|\*|\-|[> ]+|[0-9]+(.|\)))[ ]*/,""),e.replaceRange(t,{line:i,ch:0},{line:i,ch:99999999999999})}function D(e,t){for(var n in t)t.hasOwnProperty(n)&&(t[n]instanceof Array?e[n]=t[n].concat(e[n]instanceof Array?e[n]:[]):null!==t[n]&&"object"==typeof t[n]&&t[n].constructor===Object?e[n]=D(e[n]||{},t[n]):e[n]=t[n]);return e}function H(e){for(var t=1;t=19968?n[i].length:1;return r}function B(e){e=e||{},e.parent=this;var t=!0;if(e.autoDownloadFontAwesome===!1&&(t=!1),e.autoDownloadFontAwesome!==!0)for(var n=document.styleSheets,r=0;r-1&&(t=!1);if(t){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(e.element)this.element=e.element;else if(null===e.element)return void console.log("SimpleMDE: Error. No element was found.");if(void 0===e.toolbar){e.toolbar=[];for(var o in K)K.hasOwnProperty(o)&&(-1!=o.indexOf("separator-")&&e.toolbar.push("|"),(K[o]["default"]===!0||e.showIcons&&e.showIcons.constructor===Array&&-1!=e.showIcons.indexOf(o))&&e.toolbar.push(o))}e.hasOwnProperty("status")||(e.status=["autosave","lines","words","cursor"]),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=H({highlightFormatting:!0},e.parsingConfig||{}),e.insertTexts=H({},X,e.insertTexts||{}),e.promptTexts=Z,e.blockStyles=H({},J,e.blockStyles||{}),e.shortcuts=H({},G,e.shortcuts||{}),void 0!=e.autosave&&void 0!=e.autosave.unique_id&&""!=e.autosave.unique_id&&(e.autosave.uniqueId=e.autosave.unique_id),this.options=e,this.render(),!e.initialValue||this.options.autosave&&this.options.autosave.foundSavedValue===!0||this.value(e.initialValue)}function _(){if("object"!=typeof localStorage)return!1;try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch(e){return!1}return!0}var F=e("codemirror");e("codemirror/addon/edit/continuelist.js"),e("./codemirror/tablist"),e("codemirror/addon/display/fullscreen.js"),e("codemirror/mode/markdown/markdown.js"),e("codemirror/addon/mode/overlay.js"),e("codemirror/addon/display/placeholder.js"),e("codemirror/addon/selection/mark-selection.js"),e("codemirror/mode/gfm/gfm.js"),e("codemirror/mode/xml/xml.js");var z=e("codemirror-spell-checker"),j=e("marked"),U=/Mac/.test(navigator.platform),q={toggleBold:c,toggleItalic:u,drawLink:k,toggleHeadingSmaller:p,toggleHeadingBigger:m,drawImage:S,toggleBlockquote:d,toggleOrderedList:b,toggleUnorderedList:x,toggleCodeBlock:h,togglePreview:A,toggleStrikethrough:f,toggleHeading1:g,toggleHeading2:v,toggleHeading3:y,cleanBlock:w,drawTable:C,drawHorizontalRule:L,undo:T,redo:M,toggleSideBySide:N,toggleFullScreen:s},G={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},Y=function(e){for(var t in q)if(q[t]===e)return t;return null},$=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0); +}(navigator.userAgent||navigator.vendor||window.opera),e},V="",K={bold:{name:"bold",action:c,className:"fa fa-bold",title:"Bold","default":!0},italic:{name:"italic",action:u,className:"fa fa-italic",title:"Italic","default":!0},strikethrough:{name:"strikethrough",action:f,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:p,className:"fa fa-header",title:"Heading","default":!0},"heading-smaller":{name:"heading-smaller",action:p,className:"fa fa-header fa-header-x fa-header-smaller",title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:m,className:"fa fa-header fa-header-x fa-header-bigger",title:"Bigger Heading"},"heading-1":{name:"heading-1",action:g,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:v,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:y,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:h,className:"fa fa-code",title:"Code"},quote:{name:"quote",action:d,className:"fa fa-quote-left",title:"Quote","default":!0},"unordered-list":{name:"unordered-list",action:x,className:"fa fa-list-ul",title:"Generic List","default":!0},"ordered-list":{name:"ordered-list",action:b,className:"fa fa-list-ol",title:"Numbered List","default":!0},"clean-block":{name:"clean-block",action:w,className:"fa fa-eraser fa-clean-block",title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:k,className:"fa fa-link",title:"Create Link","default":!0},image:{name:"image",action:S,className:"fa fa-picture-o",title:"Insert Image","default":!0},table:{name:"table",action:C,className:"fa fa-table",title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:L,className:"fa fa-minus",title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:A,className:"fa fa-eye no-disable",title:"Toggle Preview","default":!0},"side-by-side":{name:"side-by-side",action:N,className:"fa fa-columns no-disable no-mobile",title:"Toggle Side by Side","default":!0},fullscreen:{name:"fullscreen",action:s,className:"fa fa-arrows-alt no-disable no-mobile",title:"Toggle Fullscreen","default":!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://simplemde.com/markdown-guide",className:"fa fa-question-circle",title:"Markdown Guide","default":!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:T,className:"fa fa-undo no-disable",title:"Undo"},redo:{name:"redo",action:M,className:"fa fa-repeat no-disable",title:"Redo"}},X={link:["[","](#url#)"],image:["![](","#url#)"],table:["","\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],horizontalRule:["","\n\n-----\n\n"]},Z={link:"URL for the link:",image:"URL of the image:"},J={bold:"**",code:"```",italic:"*"};B.prototype.markdown=function(e){if(j){var t={};return this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?t.breaks=!1:t.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0&&window.hljs&&(t.highlight=function(e){return window.hljs.highlightAuto(e).value}),j.setOptions(t),j(e)}},B.prototype.render=function(e){if(e||(e=this.element||document.getElementsByTagName("textarea")[0]),!this._rendered||this._rendered!==e){this.element=e;var t=this.options,n=this,i={};for(var o in t.shortcuts)null!==t.shortcuts[o]&&null!==q[o]&&!function(e){i[r(t.shortcuts[e])]=function(){q[e](n)}}(o);i.Enter="newlineAndIndentContinueMarkdownList",i.Tab="tabAndIndentMarkdownList",i["Shift-Tab"]="shiftTabAndUnindentMarkdownList",i.Esc=function(e){e.getOption("fullScreen")&&s(n)},document.addEventListener("keydown",function(e){e=e||window.event,27==e.keyCode&&n.codemirror.getOption("fullScreen")&&s(n)},!1);var a,l;if(t.spellChecker!==!1?(a="spell-checker",l=t.parsingConfig,l.name="gfm",l.gitHubSpice=!1,z({codeMirrorInstance:F})):(a=t.parsingConfig,a.name="gfm",a.gitHubSpice=!1),this.codemirror=F.fromTextArea(e,{mode:a,backdrop:l,theme:"paper",tabSize:void 0!=t.tabSize?t.tabSize:2,indentUnit:void 0!=t.tabSize?t.tabSize:2,indentWithTabs:t.indentWithTabs!==!1,lineNumbers:!1,autofocus:t.autofocus===!0,extraKeys:i,lineWrapping:t.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:t.placeholder||e.getAttribute("placeholder")||"",styleSelectedText:void 0!=t.styleSelectedText?t.styleSelectedText:!0}),t.forceSync===!0){var c=this.codemirror;c.on("change",function(){c.save()})}this.gui={},t.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),t.status!==!1&&(this.gui.statusbar=this.createStatusbar()),void 0!=t.autosave&&t.autosave.enabled===!0&&this.autosave(),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element;var u=this.codemirror;setTimeout(function(){u.refresh()}.bind(u),0)}},B.prototype.autosave=function(){if(_()){var e=this;if(void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to use the autosave feature");null!=e.element.form&&void 0!=e.element.form&&e.element.form.addEventListener("submit",function(){localStorage.removeItem("smde_"+e.options.autosave.uniqueId)}),this.options.autosave.loaded!==!0&&("string"==typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&""!=localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0),localStorage.setItem("smde_"+this.options.autosave.uniqueId,e.value());var t=document.getElementById("autosaved");if(null!=t&&void 0!=t&&""!=t){var n=new Date,r=n.getHours(),i=n.getMinutes(),o="am",a=r;a>=12&&(a=r-12,o="pm"),0==a&&(a=12),i=10>i?"0"+i:i,t.innerHTML="Autosaved: "+a+":"+i+" "+o}this.autosaveTimeoutId=setTimeout(function(){e.autosave()},this.options.autosave.delay||1e4)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.clearAutosavedValue=function(){if(_()){if(void 0==this.options.autosave||void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to clear the autosave value");localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;n&&/editor-preview-side/.test(n.className)||(n=document.createElement("div"),n.className="editor-preview-side",t.parentNode.insertBefore(n,t.nextSibling));var r=!1,i=!1;return e.on("scroll",function(e){if(r)return void(r=!1);i=!0;var t=e.getScrollInfo().height-e.getScrollInfo().clientHeight,o=parseFloat(e.getScrollInfo().top)/t,a=(n.scrollHeight-n.clientHeight)*o;n.scrollTop=a}),n.onscroll=function(){if(i)return void(i=!1);r=!0;var t=n.scrollHeight-n.clientHeight,o=parseFloat(n.scrollTop)/t,a=(e.getScrollInfo().height-e.getScrollInfo().clientHeight)*o;e.scrollTo(0,a)},n},B.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){var t;for(t=0;t0||"*"===o.repeat||"+"===o.repeat){var l="*"===o.repeat?0:"+"===o.repeat?1:o.repeat;t=o.groupmarker.start+t+o.groupmarker.end+o.quantifiermarker.start+l+","+o.repeat+o.quantifiermarker.end}var c,u=s?"regex_"+o.regex:o.numericInput?t.split("").reverse().join(""):t;return i.prototype.masksCache[u]===a||!0===n?(c={mask:t,maskToken:i.prototype.analyseMask(t,s,o),validPositions:{},_buffer:a,buffer:a,tests:{},metadata:r,maskLength:a},!0!==n&&(i.prototype.masksCache[u]=c,c=e.extend(!0,{},i.prototype.masksCache[u]))):c=e.extend(!0,{},i.prototype.masksCache[u]),c}if(e.isFunction(t.mask)&&(t.mask=t.mask(t)),e.isArray(t.mask)){if(t.mask.length>1){t.keepStatic=null===t.keepStatic||t.keepStatic;var o=t.groupmarker.start;return e.each(t.numericInput?t.mask.reverse():t.mask,function(n,i){o.length>1&&(o+=t.groupmarker.end+t.alternatormarker+t.groupmarker.start),i.mask===a||e.isFunction(i.mask)?o+=i:o+=i.mask}),o+=t.groupmarker.end,r(o,t.mask,t)}t.mask=t.mask.pop()}return t.mask&&t.mask.mask!==a&&!e.isFunction(t.mask.mask)?r(t.mask.mask,t.mask,t):r(t.mask,t.mask,t)}function l(r,s,c){function m(e,t,n){t=t||0;var i,r,o,s=[],l=0,u=v();do{!0===e&&h().validPositions[l]?(r=(o=h().validPositions[l]).match,i=o.locator.slice(),s.push(!0===n?o.input:!1===n?r.nativeDef:I(l,r))):(r=(o=b(l,i,l-1)).match,i=o.locator.slice(),(!1===c.jitMasking||ll)&&s.push(!1===n?r.nativeDef:I(l,r))),l++}while((Q===a||ll);return""===s[s.length-1]&&s.pop(),h().maskLength=l+1,s}function h(){return s}function g(e){var t=h();t.buffer=a,!0!==e&&(t.validPositions={},t.p=0)}function v(e,t,n){var i=-1,r=-1,o=n||h().validPositions;e===a&&(e=-1);for(var s in o){var l=parseInt(s);o[l]&&(t||!0!==o[l].generatedInput)&&(l<=e&&(i=l),l>=e&&(r=l))}return-1!==i&&e-i>1||r=s;o--)h().validPositions[o]!==a&&(!0!==i&&(!h().validPositions[o].match.optionality&&function(e){var t=h().validPositions[e];if(t!==a&&null===t.match.fn){var n=h().validPositions[e-1],i=h().validPositions[e+1];return n!==a&&i!==a}return!1}(o)||!1===c.canClearPosition(h(),o,v(),r,c))||delete h().validPositions[o]);for(g(!0),o=s+1;o<=v();){for(;h().validPositions[s]!==a;)s++;if(o1e4)throw"Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. "+h().mask;if(u===t&&o.matches===a)return f.push({match:o,locator:l.reverse(),cd:m}),!0;if(o.matches!==a){if(o.isGroup&&g!==o){if(o=p(n.matches[e.inArray(o,n.matches)+1],l))return!0}else if(o.isOptional){var k=o;if(o=r(o,i,l,g)){if(s=f[f.length-1].match,!v(s,k))return!0;d=!0,u=t}}else if(o.isAlternator){var b,x=o,P=[],S=f.slice(),w=l.length,A=i.length>0?i.shift():-1;if(-1===A||"string"==typeof A){var E,C=u,O=i.slice(),R=[];if("string"==typeof A)R=A.split(",");else for(E=0;E_&&(o=p(n.matches[_],[_].concat(l.slice(1,l.length)),g))&&(R.push(_.toString()),e.each(f,function(e,t){t.alternation=l.length-1}))}b=f.slice(),u=C,f=[];for(var D=0;D0,o=P.length>0,i=O.slice()}else o=p(x.matches[A]||n.matches[A],[A].concat(l),g);if(o)return!0}else if(o.isQuantifier&&g!==n.matches[e.inArray(o,n.matches)-1])for(var T=o,G=i.length>0?i.shift():0;G<(isNaN(T.quantifier.max)?G+1:T.quantifier.max)&&u<=t;G++){var B=n.matches[e.inArray(T,n.matches)-1];if(o=p(B,[G].concat(l),B)){if(s=f[f.length-1].match,s.optionalQuantifier=G>T.quantifier.min-1,v(s,B)){if(G>T.quantifier.min-1){d=!0,u=t;break}return!0}return!0}}else if(o=r(o,i,l,g))return!0}else u++}for(var g=i.length>0?i.shift():0;gt)break}}function o(e){if(c.keepStatic&&t>0&&e.length>1+(""===e[e.length-1].match.def?1:0)&&!0!==e[0].match.optionality&&!0!==e[0].match.optionalQuantifier&&null===e[0].match.fn&&!/[0-9a-bA-Z]/.test(e[0].match.def)){if(h().validPositions[t-1]===a)return[k(e)];if(h().validPositions[t-1].alternation===e[0].alternation)return[k(e)];if(h().validPositions[t-1])return[k(e)]}return e}var s,l=h().maskToken,u=n?i:0,p=n?n.slice():[0],f=[],d=!1,m=n?n.join(""):"";if(t>-1){if(n===a){for(var g,v=t-1;(g=h().validPositions[v]||h().tests[v])===a&&v>-1;)v--;g!==a&&v>-1&&(p=function(t){var n=[];return e.isArray(t)||(t=[t]),t.length>0&&(t[0].alternation===a?0===(n=k(t.slice()).locator.slice()).length&&(n=t[0].locator.slice()):e.each(t,function(e,t){if(""!==t.def)if(0===n.length)n=t.locator.slice();else for(var a=0;at);y++);}return(0===f.length||d)&&f.push({match:{fn:null,cardinality:0,optionality:!0,casing:null,def:"",placeholder:""},locator:[],cd:m}),n!==a&&h().tests[t]?o(e.extend(!0,[],f)):(h().tests[t]=e.extend(!0,[],f),o(h().tests[t]))}function w(){return h()._buffer===a&&(h()._buffer=m(!1,1),h().buffer===a&&(h().buffer=h()._buffer.slice())),h()._buffer}function A(e){return h().buffer!==a&&!0!==e||(h().buffer=m(!0,v(),!0)),h().buffer}function E(e,t,n){var i,r;if(!0===e)g(),e=0,t=n.length;else for(i=e;i1||e.begin-e.end==1:e.end-e.begin>1||e.end-e.begin==1;return t&&0===e.begin&&e.end===h().maskLength?"full":t}function p(n,i,r){var s=!1;return e.each(S(n),function(l,p){for(var d=p.match,m=i?1:0,k="",b=d.cardinality;b>m;b--)k+=j(n-(b-1));if(i&&(k+=i),A(!0),!1!==(s=null!=d.fn?d.fn.test(k,h(),n,r,c,u(t)):(i===d.def||i===c.skipOptionalPartCharacter)&&""!==d.def&&{c:I(n,d,!0)||d.def,pos:n})){var x=s.c!==a?s.c:i;x=x===c.skipOptionalPartCharacter&&null===d.fn?I(n,d,!0)||d.def:x;var P=n,S=A();if(s.remove!==a&&(e.isArray(s.remove)||(s.remove=[s.remove]),e.each(s.remove.sort(function(e,t){return t-e}),function(e,t){y(t,t+1,!0)})),s.insert!==a&&(e.isArray(s.insert)||(s.insert=[s.insert]),e.each(s.insert.sort(function(e,t){return e-t}),function(e,t){R(t.pos,t.c,!0,o)})),s.refreshFromBuffer){var w=s.refreshFromBuffer;if(E(!0===w?w:w.start,w.end,S),s.pos===a&&s.c===a)return s.pos=v(),!1;if((P=s.pos!==a?s.pos:n)!==n)return s=e.extend(s,R(P,x,!0,o)),!1}else if(!0!==s&&s.pos!==a&&s.pos!==n&&(P=s.pos,E(n,P,A().slice()),P!==n))return s=e.extend(s,R(P,x,!0)),!1;return(!0===s||s.pos!==a||s.c!==a)&&(l>0&&g(!0),f(P,e.extend({},p,{input:C(x,d,P)}),o,u(t))||(s=!1),!1)}}),s}function f(t,n,i,r){if(r||c.insertMode&&h().validPositions[t]!==a&&i===a){var o,s=e.extend(!0,{},h().validPositions),l=v(a,!0);for(o=t;o<=l;o++)delete h().validPositions[o];h().validPositions[t]=e.extend(!0,{},n);var u,p=!0,f=h().validPositions,m=!1,y=h().maskLength;for(o=u=t;o<=l;o++){var k=s[o];if(k!==a)for(var b=u;b=h().maskLength-1)break;if(h().maskLength-1&&!h().validPositions[n];n--);var i,r;for(n++;nn)&&(""===(r=S(n,b(n-1).locator,n-1).slice())[r.length-1].match.def&&r.pop(),(i=k(r))&&(i.match.def===c.radixPointDefinitionSymbol||!M(n,!0)||e.inArray(c.radixPoint,A())Math.abs(i-l)&&(c=t);break}u=0;b--)if((l=h().validPositions[b])&&l.alternation!==a){if(r=b,s=h().validPositions[r].alternation,u.locator[l.alternation]!==l.locator[l.alternation])break;u=l}if(s!==a){m=parseInt(r);var x=u.locator[u.alternation||s]!==a?u.locator[u.alternation||s]:d[0];x.length>0&&(x=x.split(",")[0]);var P=h().validPositions[m],w=h().validPositions[m-1];e.each(S(m,w?w.locator:a,m-1),function(r,l){d=l.locator[s]?l.locator[s].toString().split(","):[];for(var u=0;u0;){var C=b.shift();if(C!==c.skipOptionalPartCharacter&&!(k=R(v(a,!0)+1,C,!1,o,!0)))break}if(k){h().validPositions[m].locator=E;var O=v(t)+1;for(p=m+1;pO?O:t,n,i,o,!0)}if(k)return!1;g(),h().validPositions=e.extend(!0,{},y)}}})}return k}(m,n,r)),!0===x&&(x={pos:m})}if(e.isFunction(c.postValidation)&&!1!==x&&!r&&!0!==o&&!0!==l){var T=c.postValidation(A(!0),x,c);if(T.refreshFromBuffer&&T.buffer){var G=T.refreshFromBuffer;E(!0===G?G:G.start,G.end,T.buffer)}x=!0===T?x:T}return x&&x.pos===a&&(x.pos=m),!1!==x&&!0!==l||(g(!0),h().validPositions=e.extend(!0,{},w)),x}function M(e,t){var n=b(e).match;if(""===n.def&&(n=x(e).match),null!=n.fn)return n.fn;if(!0!==t&&e>-1){var a=S(e);return a.length>1+(""===a[a.length-1].match.def?1:0)}return!1}function _(e,t){var n=h().maskLength;if(e>=n)return n;var a=e;for(S(n+1).length>1&&(m(!0,n+1,!0),n=h().maskLength);++a0&&(!0===t&&!0!==x(a).match.newBlockMarker||!0!==t&&!M(a)&&((n=S(a)).length<2||2===n.length&&""===n[1].match.def)););return a}function j(e){return h().validPositions[e]===a?I(e):h().validPositions[e].input}function N(t,n,i,r,o){if(r&&e.isFunction(c.onBeforeWrite)){var s=c.onBeforeWrite.call(W,r,n,i,c);if(s){if(s.refreshFromBuffer){var l=s.refreshFromBuffer;E(!0===l?l:l.start,l.end,s.buffer||n),n=A(!0)}i!==a&&(i=s.caret!==a?s.caret:i)}}t!==a&&(t.inputmask._valueSet(n.join("")),i===a||r!==a&&"blur"===r.type?H(t,i,0===n.length):d&&r&&"input"===r.type?setTimeout(function(){G(t,i)},0):G(t,i),!0===o&&(X=!0,e(t).trigger("input")))}function I(t,n,i){if((n=n||x(t).match).placeholder!==a||!0===i)return e.isFunction(n.placeholder)?n.placeholder(c):n.placeholder;if(null===n.fn){if(t>-1&&h().validPositions[t]===a){var r,o=S(t),s=[];if(o.length>1+(""===o[o.length-1].match.def?1:0))for(var l=0;l1&&/[0-9a-bA-Z]/.test(s[0].match.def)))return c.placeholder.charAt(t%c.placeholder.length)}return n.def}return c.placeholder.charAt(t%c.placeholder.length)}function F(t,r,o,s,l){function u(e,t){return-1!==w().slice(e,_(e)).join("").indexOf(t)&&!M(e)&&x(e).match.nativeDef===t.charAt(t.length-1)}var p=s.slice(),f="",d=-1,m=a;if(g(),o||!0===c.autoUnmask)d=_(d);else{var y=w().slice(0,_(-1)).join(""),k=p.join("").match(new RegExp("^"+i.escapeRegex(y),"g"));k&&k.length>0&&(p.splice(0,k.length*y.length),d=_(d))}if(-1===d?(h().p=_(d),d=0):h().p=d,e.each(p,function(n,i){if(i!==a)if(h().validPositions[n]===a&&p[n]===I(n)&&M(n,!0)&&!1===R(n,p[n],!0,a,a,!0))h().p++;else{var r=new e.Event("_checkval");r.which=i.charCodeAt(0),f+=i;var s=v(a,!0),l=h().validPositions[s],y=b(s+1,l?l.locator.slice():a,s);if(!u(d,f)||o||c.autoUnmask){var k=o?n:null==y.match.fn&&y.match.optionality&&s+1e.scrollWidth?p:0,u||!1!==c.insertMode||i!==r||r++,e.setSelectionRange)e.selectionStart=i,e.selectionEnd=r;else if(t.getSelection){if(l=n.createRange(),e.firstChild===a||null===e.firstChild){var f=n.createTextNode("");e.appendChild(f)}l.setStart(e.firstChild,is&&(((i=l[n]).match.optionality||i.match.optionalQuantifier&&i.match.newBlockMarker||p&&(p!==l[n].locator[c.alternation]&&null!=i.match.fn||null===i.match.fn&&i.locator[c.alternation]&&O(i.locator[c.alternation].toString().split(","),p.toString().split(","))&&""!==S(n)[0].def))&&r[n]===I(n,i.match));n--)o--;return t?{l:o,def:l[o]?l[o].match:a}:o}function L(e){for(var t,n=B(),i=e.length,r=h().validPositions[v()];n=0;i--){var s=h().validPositions[i];if(s){if(!0!==s.generatedInput&&/[0-9a-bA-Z]/.test(s.input)&&n.push(s.input),delete h().validPositions[i],s.alternation!==a&&s.locator[s.alternation]!==o.locator[s.alternation])break;o=s}}if(i>-1)for(h().p=_(v(-1,!0));n.length>0;){var l=new e.Event("keypress");l.which=n.pop().charCodeAt(0),ae.keypressEvent.call(t,l,!0,!1,!1,h().p)}else h().validPositions=e.extend(!0,{},r)}}();var u=v(r.begin,!0);if(u=e){var u=e-c,p=i.offsetWidth-e;i.innerHTML=l.charAt(t),t=(u-=i.offsetWidth/3)"):(f=!0,p+="")}function o(a){!0!==a&&d!==t.begin||n.activeElement!==e||(p+="")}var s,l,u,p="",f=!1,d=0;if($!==a){var m=A();if(t===a?t=G(e):t.begin===a&&(t={begin:t,end:t}),!0!==i){var g=v();do{o(),h().validPositions[d]?(l=h().validPositions[d],s=l.match,u=l.locator.slice(),r(),p+=m[d]):(l=b(d,u,d-1),s=l.match,u=l.locator.slice(),(!1===c.jitMasking||dd)&&(r(),p+=I(d,s))),d++}while((Q===a||dd||f);-1===p.indexOf("im-caret")&&o(!0),f&&r()}var y=$.getElementsByTagName("div")[0];y.innerHTML=p,e.inputmask.positionColorMask(e,y)}}s=s||this.maskset,c=c||this.opts;var z,q,Q,$,W=this,Y=this.el,Z=this.isRTL,J=!1,X=!1,ee=!1,te=!1,ne={on:function(t,n,r){var o=function(t){if(this.inputmask===a&&"FORM"!==this.nodeName){var n=e.data(this,"_inputmask_opts");n?new i(n).mask(this):ne.off(this)}else{if("setvalue"===t.type||"FORM"===this.nodeName||!(this.disabled||this.readOnly&&!("keydown"===t.type&&t.ctrlKey&&67===t.keyCode||!1===c.tabThrough&&t.keyCode===i.keyCode.TAB))){switch(t.type){case"input":if(!0===X)return X=!1,t.preventDefault();break;case"keydown":J=!1,X=!1;break;case"keypress":if(!0===J)return t.preventDefault();J=!0;break;case"click":if(p||f){var o=this,s=arguments;return setTimeout(function(){r.apply(o,s)},0),!1}}var l=r.apply(this,arguments);return!1===l&&(t.preventDefault(),t.stopPropagation()),l}t.preventDefault()}};t.inputmask.events[n]=t.inputmask.events[n]||[],t.inputmask.events[n].push(o),-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).on(n,o):e(t).on(n,o)},off:function(t,n){if(t.inputmask&&t.inputmask.events){var a;n?(a=[])[n]=t.inputmask.events[n]:a=t.inputmask.events,e.each(a,function(n,a){for(;a.length>0;){var i=a.pop();-1!==e.inArray(n,["submit","reset"])?null!==t.form&&e(t.form).off(n,i):e(t).off(n,i)}delete t.inputmask.events[n]})}}},ae={keydownEvent:function(t){var a=this,r=e(a),o=t.keyCode,s=G(a);if(o===i.keyCode.BACKSPACE||o===i.keyCode.DELETE||f&&o===i.keyCode.BACKSPACE_SAFARI||t.ctrlKey&&o===i.keyCode.X&&!function(e){var t=n.createElement("input"),a="on"+e,i=a in t;return i||(t.setAttribute(a,"return;"),i="function"==typeof t[a]),t=null,i}("cut"))t.preventDefault(),V(a,o,s),N(a,A(!0),h().p,t,a.inputmask._valueGet()!==A().join("")),a.inputmask._valueGet()===w().join("")?r.trigger("cleared"):!0===U(A())&&r.trigger("complete");else if(o===i.keyCode.END||o===i.keyCode.PAGE_DOWN){t.preventDefault();var l=_(v());c.insertMode||l!==h().maskLength||t.shiftKey||l--,G(a,t.shiftKey?s.begin:l,l,!0)}else o===i.keyCode.HOME&&!t.shiftKey||o===i.keyCode.PAGE_UP?(t.preventDefault(),G(a,0,t.shiftKey?s.begin:0,!0)):(c.undoOnEscape&&o===i.keyCode.ESCAPE||90===o&&t.ctrlKey)&&!0!==t.altKey?(F(a,!0,!1,z.split("")),r.trigger("click")):o!==i.keyCode.INSERT||t.shiftKey||t.ctrlKey?!0===c.tabThrough&&o===i.keyCode.TAB?(!0===t.shiftKey?(null===x(s.begin).match.fn&&(s.begin=_(s.begin)),s.end=D(s.begin,!0),s.begin=D(s.end,!0)):(s.begin=_(s.begin,!0),s.end=_(s.begin,!0),s.endA().length){var i=new e.Event("keypress");return i.which=c.radixPoint.charCodeAt(0),ae.keypressEvent.call(t,i,!0,!0,!1,a.begin-1),!1}}(n,a,r))return!1;if(a=a.replace(new RegExp("("+i.escapeRegex(w().join(""))+")*"),""),!1===function(t,n,a){if(p){var i=n.replace(A().join(""),"");if(1===i.length){var r=new e.Event("keypress");return r.which=i.charCodeAt(0),ae.keypressEvent.call(t,r,!0,!0,!1,h().validPositions[a.begin-1]?a.begin:a.begin-1),!1}}}(n,a,r))return!1;r.begin>a.length&&(G(n,a.length),r=G(n));var o=A().join(""),s=a.substr(0,r.begin),l=a.substr(r.begin),u=o.substr(0,r.begin),f=o.substr(r.begin),d=r,m="",g=!1;if(s!==u){d.begin=0;for(var v=(g=s.length>=u.length)?s.length:u.length,y=0;s.charAt(y)===u.charAt(y)&&yf.length?g&&(d.end=d.begin):l.length0?e.each(m.split(""),function(t,a){var i=new e.Event("keypress");i.which=a.charCodeAt(0),ee=!1,ae.keypressEvent.call(n,i)}):(d.begin===d.end-1&&G(n,D(d.begin+1),d.end),t.keyCode=i.keyCode.DELETE,ae.keydownEvent.call(n,t)),t.preventDefault()}},setValueEvent:function(t){this.inputmask.refreshValue=!1;var n=this,a=n.inputmask._valueGet(!0);e.isFunction(c.onBeforeMask)&&(a=c.onBeforeMask.call(W,a,c)||a),a=a.split(""),F(n,!0,!1,Z?a.reverse():a),z=A().join(""),(c.clearMaskOnLostFocus||c.clearIncomplete)&&n.inputmask._valueGet()===w().join("")&&n.inputmask._valueSet("")},focusEvent:function(e){var t=this,n=t.inputmask._valueGet();c.showMaskOnFocus&&(!c.showMaskOnHover||c.showMaskOnHover&&""===n)&&(t.inputmask._valueGet()!==A().join("")?N(t,A(),_(v())):!1===te&&G(t,_(v()))),!0===c.positionCaretOnTab&&!1===te&&""!==n&&(N(t,A(),G(t)),ae.clickEvent.apply(t,[e,!0])),z=A().join("")},mouseleaveEvent:function(e){var t=this;if(te=!1,c.clearMaskOnLostFocus&&n.activeElement!==t){var a=A().slice(),i=t.inputmask._valueGet();i!==t.getAttribute("placeholder")&&""!==i&&(-1===v()&&i===w().join("")?a=[]:L(a),N(t,a))}},clickEvent:function(t,i){function r(t){if(""!==c.radixPoint){var n=h().validPositions;if(n[t]===a||n[t].input===I(t)){if(t<_(-1))return!0;var i=e.inArray(c.radixPoint,A());if(-1!==i){for(var r in n)if(i=m||s===u)&&(u=m)}G(o,u)}}}},0)},dblclickEvent:function(e){var t=this;setTimeout(function(){G(t,0,_(v()))},0)},cutEvent:function(a){var r=this,o=e(r),s=G(r),l=a.originalEvent||a,c=t.clipboardData||l.clipboardData,u=Z?A().slice(s.end,s.begin):A().slice(s.begin,s.end);c.setData("text",Z?u.reverse().join(""):u.join("")),n.execCommand&&n.execCommand("copy"),V(r,i.keyCode.DELETE,s),N(r,A(),h().p,a,z!==A().join("")),r.inputmask._valueGet()===w().join("")&&o.trigger("cleared")},blurEvent:function(t){var n=e(this),i=this;if(i.inputmask){var r=i.inputmask._valueGet(),o=A().slice();""!==r&&(c.clearMaskOnLostFocus&&(-1===v()&&r===w().join("")?o=[]:L(o)),!1===U(o)&&(setTimeout(function(){n.trigger("incomplete")},0),c.clearIncomplete&&(g(),o=c.clearMaskOnLostFocus?[]:w().slice())),N(i,o,a,t)),z!==A().join("")&&(z=o.join(""),n.trigger("change"))}},mouseenterEvent:function(e){var t=this;te=!0,n.activeElement!==t&&c.showMaskOnHover&&t.inputmask._valueGet()!==A().join("")&&N(t,A())},submitEvent:function(e){z!==A().join("")&&q.trigger("change"),c.clearMaskOnLostFocus&&-1===v()&&Y.inputmask._valueGet&&Y.inputmask._valueGet()===w().join("")&&Y.inputmask._valueSet(""),c.removeMaskOnSubmit&&(Y.inputmask._valueSet(Y.inputmask.unmaskedvalue(),!0),setTimeout(function(){N(Y,A())},0))},resetEvent:function(e){Y.inputmask.refreshValue=!0,setTimeout(function(){q.trigger("setvalue")},0)}};i.prototype.positionColorMask=function(e,t){e.style.left=t.offsetLeft+"px"};var ie;if(r!==a)switch(r.action){case"isComplete":return Y=r.el,U(A());case"unmaskedvalue":return Y!==a&&r.value===a||(ie=r.value,ie=(e.isFunction(c.onBeforeMask)?c.onBeforeMask.call(W,ie,c)||ie:ie).split(""),F(a,!1,!1,Z?ie.reverse():ie),e.isFunction(c.onBeforeWrite)&&c.onBeforeWrite.call(W,a,A(),0,c)),T(Y);case"mask":!function(t){ne.off(t);var i=function(t,i){var r=t.getAttribute("type"),s="INPUT"===t.tagName&&-1!==e.inArray(r,i.supportsInputType)||t.isContentEditable||"TEXTAREA"===t.tagName;if(!s)if("INPUT"===t.tagName){var l=n.createElement("input");l.setAttribute("type",r),s="text"===l.type,l=null}else s="partial";return!1!==s?function(t){function r(){return this.inputmask?this.inputmask.opts.autoUnmask?this.inputmask.unmaskedvalue():-1!==v()||!0!==i.nullable?n.activeElement===this&&i.clearMaskOnLostFocus?(Z?L(A().slice()).reverse():L(A().slice())).join(""):l.call(this):"":l.call(this)}function s(t){c.call(this,t),this.inputmask&&e(this).trigger("setvalue")}var l,c;if(!t.inputmask.__valueGet){if(!0!==i.noValuePatching){if(Object.getOwnPropertyDescriptor){"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="object"===o("test".__proto__)?function(e){return e.__proto__}:function(e){return e.constructor.prototype});var u=Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value"):a;u&&u.get&&u.set?(l=u.get,c=u.set,Object.defineProperty(t,"value",{get:r,set:s,configurable:!0})):"INPUT"!==t.tagName&&(l=function(){return this.textContent},c=function(e){this.textContent=e},Object.defineProperty(t,"value",{get:r,set:s,configurable:!0}))}else n.__lookupGetter__&&t.__lookupGetter__("value")&&(l=t.__lookupGetter__("value"),c=t.__lookupSetter__("value"),t.__defineGetter__("value",r),t.__defineSetter__("value",s));t.inputmask.__valueGet=l,t.inputmask.__valueSet=c}t.inputmask._valueGet=function(e){return Z&&!0!==e?l.call(this.el).split("").reverse().join(""):l.call(this.el)},t.inputmask._valueSet=function(e,t){c.call(this.el,null===e||e===a?"":!0!==t&&Z?e.split("").reverse().join(""):e)},l===a&&(l=function(){return this.value},c=function(e){this.value=e},function(t){if(e.valHooks&&(e.valHooks[t]===a||!0!==e.valHooks[t].inputmaskpatch)){var n=e.valHooks[t]&&e.valHooks[t].get?e.valHooks[t].get:function(e){return e.value},r=e.valHooks[t]&&e.valHooks[t].set?e.valHooks[t].set:function(e,t){return e.value=t,e};e.valHooks[t]={get:function(e){if(e.inputmask){if(e.inputmask.opts.autoUnmask)return e.inputmask.unmaskedvalue();var t=n(e);return-1!==v(a,a,e.inputmask.maskset.validPositions)||!0!==i.nullable?t:""}return n(e)},set:function(t,n){var a,i=e(t);return a=r(t,n),t.inputmask&&i.trigger("setvalue"),a},inputmaskpatch:!0}}}(t.type),function(t){ne.on(t,"mouseenter",function(t){var n=e(this);this.inputmask._valueGet()!==A().join("")&&n.trigger("setvalue")})}(t))}}(t):t.inputmask=a,s}(t,c);if(!1!==i&&(Y=t,q=e(Y),-1===(Q=Y!==a?Y.maxLength:a)&&(Q=a),!0===c.colorMask&&K(Y),d&&(Y.hasOwnProperty("inputmode")&&(Y.inputmode=c.inputmode,Y.setAttribute("inputmode",c.inputmode)),"rtfm"===c.androidHack&&(!0!==c.colorMask&&K(Y),Y.type="password")),!0===i&&(ne.on(Y,"submit",ae.submitEvent),ne.on(Y,"reset",ae.resetEvent),ne.on(Y,"mouseenter",ae.mouseenterEvent),ne.on(Y,"blur",ae.blurEvent),ne.on(Y,"focus",ae.focusEvent),ne.on(Y,"mouseleave",ae.mouseleaveEvent),!0!==c.colorMask&&ne.on(Y,"click",ae.clickEvent),ne.on(Y,"dblclick",ae.dblclickEvent),ne.on(Y,"paste",ae.pasteEvent),ne.on(Y,"dragdrop",ae.pasteEvent),ne.on(Y,"drop",ae.pasteEvent),ne.on(Y,"cut",ae.cutEvent),ne.on(Y,"complete",c.oncomplete),ne.on(Y,"incomplete",c.onincomplete),ne.on(Y,"cleared",c.oncleared),d||!0===c.inputEventOnly?Y.removeAttribute("maxLength"):(ne.on(Y,"keydown",ae.keydownEvent),ne.on(Y,"keypress",ae.keypressEvent)),ne.on(Y,"compositionstart",e.noop),ne.on(Y,"compositionupdate",e.noop),ne.on(Y,"compositionend",e.noop),ne.on(Y,"keyup",e.noop),ne.on(Y,"input",ae.inputFallBackEvent),ne.on(Y,"beforeinput",e.noop)),ne.on(Y,"setvalue",ae.setValueEvent),z=w().join(""),""!==Y.inputmask._valueGet(!0)||!1===c.clearMaskOnLostFocus||n.activeElement===Y)){var r=e.isFunction(c.onBeforeMask)?c.onBeforeMask.call(W,Y.inputmask._valueGet(!0),c)||Y.inputmask._valueGet(!0):Y.inputmask._valueGet(!0);""!==r&&F(Y,!0,!1,Z?r.split("").reverse():r.split(""));var s=A().slice();z=s.join(""),!1===U(s)&&c.clearIncomplete&&g(),c.clearMaskOnLostFocus&&n.activeElement!==Y&&(-1===v()?s=[]:L(s)),N(Y,s),n.activeElement===Y&&G(Y,_(v()))}}(Y);break;case"format":return ie=(e.isFunction(c.onBeforeMask)?c.onBeforeMask.call(W,r.value,c)||r.value:r.value).split(""),F(a,!0,!1,Z?ie.reverse():ie),r.metadata?{value:Z?A().slice().reverse().join(""):A().join(""),metadata:l.call(this,{action:"getmetadata"},s,c)}:Z?A().slice().reverse().join(""):A().join("");case"isValid":r.value?(ie=r.value.split(""),F(a,!0,!0,Z?ie.reverse():ie)):r.value=A().join("");for(var re=A(),oe=B(),se=re.length-1;se>oe&&!M(se);se--);return re.splice(oe,se+1-oe),U(re)&&r.value===A().join("");case"getemptymask":return w().join("");case"remove":if(Y&&Y.inputmask){q=e(Y),Y.inputmask._valueSet(c.autoUnmask?T(Y):Y.inputmask._valueGet(!0)),ne.off(Y);Object.getOwnPropertyDescriptor&&Object.getPrototypeOf?Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Y),"value")&&Y.inputmask.__valueGet&&Object.defineProperty(Y,"value",{get:Y.inputmask.__valueGet,set:Y.inputmask.__valueSet,configurable:!0}):n.__lookupGetter__&&Y.__lookupGetter__("value")&&Y.inputmask.__valueGet&&(Y.__defineGetter__("value",Y.inputmask.__valueGet),Y.__defineSetter__("value",Y.inputmask.__valueSet)),Y.inputmask=a}return Y;case"getmetadata":if(e.isArray(s.metadata)){var le=m(!0,0,!1).join("");return e.each(s.metadata,function(e,t){if(t.mask===le)return le=t,!1}),le}return s.metadata}}var c=navigator.userAgent,u=/mobile/i.test(c),p=/iemobile/i.test(c),f=/iphone/i.test(c)&&!p,d=/android/i.test(c)&&!p;return i.prototype={dataAttribute:"data-inputmask",defaults:{placeholder:"_",optionalmarker:{start:"[",end:"]"},quantifiermarker:{start:"{",end:"}"},groupmarker:{start:"(",end:")"},alternatormarker:"|",escapeChar:"\\",mask:null,regex:null,oncomplete:e.noop,onincomplete:e.noop,oncleared:e.noop,repeat:0,greedy:!0,autoUnmask:!1,removeMaskOnSubmit:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,alias:null,onKeyDown:e.noop,onBeforeMask:null,onBeforePaste:function(t,n){return e.isFunction(n.onBeforeMask)?n.onBeforeMask.call(this,t,n):t},onBeforeWrite:null,onUnMask:null,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:e.noop,skipOptionalPartCharacter:" ",numericInput:!1,rightAlign:!1,undoOnEscape:!0,radixPoint:"",radixPointDefinitionSymbol:a,groupSeparator:"",keepStatic:null,positionCaretOnTab:!0,tabThrough:!1,supportsInputType:["text","tel","password"],ignorables:[8,9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123,0,229],isComplete:null,canClearPosition:e.noop,preValidation:null,postValidation:null,staticDefinitionSymbol:a,jitMasking:!1,nullable:!0,inputEventOnly:!1,noValuePatching:!1,positionCaretOnClick:"lvp",casing:null,inputmode:"verbatim",colorMask:!1,androidHack:!1,importDataAttributes:!0},definitions:{9:{validator:"[0-91-9]",cardinality:1,definitionSymbol:"*"},a:{validator:"[A-Za-zА-яЁёÀ-ÿµ]",cardinality:1,definitionSymbol:"*"},"*":{validator:"[0-91-9A-Za-zА-яЁёÀ-ÿµ]",cardinality:1}},aliases:{},masksCache:{},mask:function(o){function c(n,i,o,s){if(!0===i.importDataAttributes){var l,c,u,p,f=function(e,i){null!==(i=i!==a?i:n.getAttribute(s+"-"+e))&&("string"==typeof i&&(0===e.indexOf("on")?i=t[i]:"false"===i?i=!1:"true"===i&&(i=!0)),o[e]=i)},d=n.getAttribute(s);if(d&&""!==d&&(d=d.replace(new RegExp("'","g"),'"'),c=JSON.parse("{"+d+"}")),c){u=a;for(p in c)if("alias"===p.toLowerCase()){u=c[p];break}}f("alias",u),o.alias&&r(o.alias,o,i);for(l in i){if(c){u=a;for(p in c)if(p.toLowerCase()===l.toLowerCase()){u=c[p];break}}f(l,u)}}return e.extend(!0,i,o),("rtl"===n.dir||i.rightAlign)&&(n.style.textAlign="right"),("rtl"===n.dir||i.numericInput)&&(n.dir="ltr",n.removeAttribute("dir"),i.isRTL=!0),i}var u=this;return"string"==typeof o&&(o=n.getElementById(o)||n.querySelectorAll(o)),o=o.nodeName?[o]:o,e.each(o,function(t,n){var r=e.extend(!0,{},u.opts);c(n,r,e.extend(!0,{},u.userOptions),u.dataAttribute);var o=s(r,u.noMasksCache);o!==a&&(n.inputmask!==a&&(n.inputmask.opts.autoUnmask=!0,n.inputmask.remove()),n.inputmask=new i(a,a,!0),n.inputmask.opts=r,n.inputmask.noMasksCache=u.noMasksCache,n.inputmask.userOptions=e.extend(!0,{},u.userOptions),n.inputmask.isRTL=r.isRTL||r.numericInput,n.inputmask.el=n,n.inputmask.maskset=o,e.data(n,"_inputmask_opts",r),l.call(n.inputmask,{action:"mask"}))}),o&&o[0]?o[0].inputmask||this:this},option:function(t,n){return"string"==typeof t?this.opts[t]:"object"===(void 0===t?"undefined":o(t))?(e.extend(this.userOptions,t),this.el&&!0!==n&&this.mask(this.el),this):void 0},unmaskedvalue:function(e){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"unmaskedvalue",value:e})},remove:function(){return l.call(this,{action:"remove"})},getemptymask:function(){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"getemptymask"})},hasMaskedValue:function(){return!this.opts.autoUnmask},isComplete:function(){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"isComplete"})},getmetadata:function(){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"getmetadata"})},isValid:function(e){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"isValid",value:e})},format:function(e,t){return this.maskset=this.maskset||s(this.opts,this.noMasksCache),l.call(this,{action:"format",value:e,metadata:t})},analyseMask:function(t,n,r){function o(e,t,n,a){this.matches=[],this.openGroup=e||!1,this.alternatorGroup=!1,this.isGroup=e||!1,this.isOptional=t||!1,this.isQuantifier=n||!1,this.isAlternator=a||!1,this.quantifier={min:1,max:1}}function s(t,o,s){s=s!==a?s:t.matches.length;var l=t.matches[s-1];if(n)0===o.indexOf("[")||b&&/\\d|\\s|\\w]/i.test(o)||"."===o?t.matches.splice(s++,0,{fn:new RegExp(o,r.casing?"i":""),cardinality:1,optionality:t.isOptional,newBlockMarker:l===a||l.def!==o,casing:null,def:o,placeholder:a,nativeDef:o}):(b&&(o=o[o.length-1]),e.each(o.split(""),function(e,n){l=t.matches[s-1],t.matches.splice(s++,0,{fn:null,cardinality:0,optionality:t.isOptional,newBlockMarker:l===a||l.def!==n&&null!==l.fn,casing:null,def:r.staticDefinitionSymbol||n,placeholder:r.staticDefinitionSymbol!==a?n:a,nativeDef:n})})),b=!1;else{var c=(r.definitions?r.definitions[o]:a)||i.prototype.definitions[o];if(c&&!b){for(var u=c.prevalidator,p=u?u.length:0,f=1;f=f?u[f-1]:[],m=d.validator,h=d.cardinality;t.matches.splice(s++,0,{fn:m?"string"==typeof m?new RegExp(m,r.casing?"i":""):new function(){this.test=m}:new RegExp("."),cardinality:h||1,optionality:t.isOptional,newBlockMarker:l===a||l.def!==(c.definitionSymbol||o),casing:c.casing,def:c.definitionSymbol||o,placeholder:c.placeholder,nativeDef:o}),l=t.matches[s-1]}t.matches.splice(s++,0,{fn:c.validator?"string"==typeof c.validator?new RegExp(c.validator,r.casing?"i":""):new function(){this.test=c.validator}:new RegExp("."),cardinality:c.cardinality,optionality:t.isOptional,newBlockMarker:l===a||l.def!==(c.definitionSymbol||o),casing:c.casing,def:c.definitionSymbol||o,placeholder:c.placeholder,nativeDef:o})}else t.matches.splice(s++,0,{fn:null,cardinality:0,optionality:t.isOptional,newBlockMarker:l===a||l.def!==o&&null!==l.fn,casing:null,def:r.staticDefinitionSymbol||o,placeholder:r.staticDefinitionSymbol!==a?o:a,nativeDef:o}),b=!1}}function l(t){t&&t.matches&&e.each(t.matches,function(e,i){var o=t.matches[e+1];(o===a||o.matches===a||!1===o.isQuantifier)&&i&&i.isGroup&&(i.isGroup=!1,n||(s(i,r.groupmarker.start,0),!0!==i.openGroup&&s(i,r.groupmarker.end))),l(i)})}function c(){if(P.length>0){if(m=P[P.length-1],s(m,f),m.isAlternator){h=P.pop();for(var e=0;e0?(m=P[P.length-1]).matches.push(h):x.matches.push(h)}}else s(x,f)}function u(e){e.matches=e.matches.reverse();for(var t in e.matches)if(e.matches.hasOwnProperty(t)){var n=parseInt(t);if(e.matches[t].isQuantifier&&e.matches[n+1]&&e.matches[n+1].isGroup){var i=e.matches[t];e.matches.splice(t,1),e.matches.splice(n+1,0,i)}e.matches[t].matches!==a?e.matches[t]=u(e.matches[t]):e.matches[t]=function(e){return e===r.optionalmarker.start?e=r.optionalmarker.end:e===r.optionalmarker.end?e=r.optionalmarker.start:e===r.groupmarker.start?e=r.groupmarker.end:e===r.groupmarker.end&&(e=r.groupmarker.start),e}(e.matches[t])}return e}var p,f,d,m,h,g,v,y=/(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g,k=/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,b=!1,x=new o,P=[],S=[];for(n&&(r.optionalmarker.start=a,r.optionalmarker.end=a);p=n?k.exec(t):y.exec(t);){if(f=p[0],n)switch(f.charAt(0)){case"?":f="{0,1}";break;case"+":case"*":f="{"+f+"}"}if(b)c();else switch(f.charAt(0)){case r.escapeChar:b=!0,n&&c();break;case r.optionalmarker.end:case r.groupmarker.end:if(d=P.pop(),d.openGroup=!1,d!==a)if(P.length>0){if((m=P[P.length-1]).matches.push(d),m.isAlternator){h=P.pop();for(var w=0;w0?(m=P[P.length-1]).matches.push(h):x.matches.push(h)}}else x.matches.push(d);else c();break;case r.optionalmarker.start:P.push(new o(!1,!0));break;case r.groupmarker.start:P.push(new o(!0));break;case r.quantifiermarker.start:var A=new o(!1,!1,!0),E=(f=f.replace(/[{}]/g,"")).split(","),C=isNaN(E[0])?E[0]:parseInt(E[0]),O=1===E.length?C:isNaN(E[1])?E[1]:parseInt(E[1]);if("*"!==O&&"+"!==O||(C="*"===O?0:1),A.quantifier={min:C,max:O},P.length>0){var R=P[P.length-1].matches;(p=R.pop()).isGroup||((v=new o(!0)).matches.push(p),p=v),R.push(p),R.push(A)}else(p=x.matches.pop()).isGroup||(n&&null===p.fn&&"."===p.def&&(p.fn=new RegExp(p.def,r.casing?"i":"")),(v=new o(!0)).matches.push(p),p=v),x.matches.push(p),x.matches.push(A);break;case r.alternatormarker:if(P.length>0){var M=(m=P[P.length-1]).matches[m.matches.length-1];g=m.openGroup&&(M.matches===a||!1===M.isGroup&&!1===M.isAlternator)?P.pop():m.matches.pop()}else g=x.matches.pop();if(g.isAlternator)P.push(g);else if(g.alternatorGroup?(h=P.pop(),g.alternatorGroup=!1):h=new o(!1,!1,!1,!0),h.matches.push(g),P.push(h),g.openGroup){g.openGroup=!1;var _=new o(!0);_.alternatorGroup=!0,P.push(_)}break;default:c()}}for(;P.length>0;)d=P.pop(),x.matches.push(d);return x.matches.length>0&&(l(x),S.push(x)),(r.numericInput||r.isRTL)&&u(S[0]),S}},i.extendDefaults=function(t){e.extend(!0,i.prototype.defaults,t)},i.extendDefinitions=function(t){e.extend(!0,i.prototype.definitions,t)},i.extendAliases=function(t){e.extend(!0,i.prototype.aliases,t)},i.format=function(e,t,n){return i(t).format(e,n)},i.unmask=function(e,t){return i(t).unmaskedvalue(e)},i.isValid=function(e,t){return i(t).isValid(e)},i.remove=function(t){e.each(t,function(e,t){t.inputmask&&t.inputmask.remove()})},i.escapeRegex=function(e){var t=["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^"];return e.replace(new RegExp("(\\"+t.join("|\\")+")","gim"),"\\$1")},i.keyCode={ALT:18,BACKSPACE:8,BACKSPACE_SAFARI:127,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91,X:88},i})},function(e,t){e.exports=jQuery},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}n(4),n(9),n(12),n(13),n(14),n(15);var i=a(n(1)),r=a(n(0)),o=a(n(2));r.default===o.default&&n(16),window.Inputmask=i.default},function(e,t,n){var a=n(5);"string"==typeof a&&(a=[[e.i,a,""]]);var i={hmr:!0};i.transform=void 0;n(7)(a,i);a.locals&&(e.exports=a.locals)},function(e,t,n){(e.exports=n(6)(void 0)).push([e.i,"span.im-caret {\r\n -webkit-animation: 1s blink step-end infinite;\r\n animation: 1s blink step-end infinite;\r\n}\r\n\r\n@keyframes blink {\r\n from, to {\r\n border-right-color: black;\r\n }\r\n 50% {\r\n border-right-color: transparent;\r\n }\r\n}\r\n\r\n@-webkit-keyframes blink {\r\n from, to {\r\n border-right-color: black;\r\n }\r\n 50% {\r\n border-right-color: transparent;\r\n }\r\n}\r\n\r\nspan.im-static {\r\n color: grey;\r\n}\r\n\r\ndiv.im-colormask {\r\n display: inline-block;\r\n border-style: inset;\r\n border-width: 2px;\r\n -webkit-appearance: textfield;\r\n -moz-appearance: textfield;\r\n appearance: textfield;\r\n}\r\n\r\ndiv.im-colormask > input {\r\n position: absolute;\r\n display: inline-block;\r\n background-color: transparent;\r\n color: transparent;\r\n -webkit-appearance: caret;\r\n -moz-appearance: caret;\r\n appearance: caret;\r\n border-style: none;\r\n left: 0; /*calculated*/\r\n}\r\n\r\ndiv.im-colormask > input:focus {\r\n outline: none;\r\n}\r\n\r\ndiv.im-colormask > input::-moz-selection{\r\n background: none;\r\n}\r\n\r\ndiv.im-colormask > input::selection{\r\n background: none;\r\n}\r\ndiv.im-colormask > input::-moz-selection{\r\n background: none;\r\n}\r\n\r\ndiv.im-colormask > div {\r\n color: black;\r\n display: inline-block;\r\n width: 100px; /*calculated*/\r\n}",""])},function(e,t){function n(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var r=a(i),o=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(o).concat([r]).join("\n")}return[n].join("\n")}function a(e){return"/*# "+("sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e)))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var a=n(t,e);return t[2]?"@media "+t[2]+"{"+a+"}":a}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var a={},i=0;i=0&&k.splice(t,1)}function s(e){var t=document.createElement("style");return e.attrs.type="text/css",c(t,e.attrs),r(e,t),t}function l(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",c(t,e.attrs),r(e,t),t}function c(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function u(e,t){var n,a,i,r;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var c=y++;n=v||(v=s(t)),a=p.bind(null,n,c,!1),i=p.bind(null,n,c,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=l(t),a=d.bind(null,n,t),i=function(){o(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),a=f.bind(null,n),i=function(){o(n)});return a(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;a(e=t)}else i()}}function p(e,t,n,a){var i=n?"":a.css;if(e.styleSheet)e.styleSheet.cssText=x(t,i);else{var r=document.createTextNode(i),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(r,o[t]):e.appendChild(r)}}function f(e,t){var n=t.css,a=t.media;if(a&&e.setAttribute("media",a),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function d(e,t,n){var a=n.css,i=n.sourceMap,r=void 0===t.convertToAbsoluteUrls&&i;(t.convertToAbsoluteUrls||r)&&(a=b(a)),i&&(a+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var o=new Blob([a],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(o),s&&URL.revokeObjectURL(s)}var m={},h=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),g=function(e){var t={};return function(n){if(void 0===t[n]){var a=e.call(this,n);if(a instanceof window.HTMLIFrameElement)try{a=a.contentDocument.head}catch(e){a=null}t[n]=a}return t[n]}}(function(e){return document.querySelector(e)}),v=null,y=0,k=[],b=n(8);e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=h()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=i(e,t);return a(n,t),function(e){for(var r=[],o=0;oa)return e;if(to?e:o}if(e<=a&&a<=t){for(var s=a.toString().slice(0,2);t-1&&"."!==t.buffer[n-1]?(e=t.buffer[n-1]+e,e=n-2>-1&&"."!==t.buffer[n-2]?t.buffer[n-2]+e:"0"+e):e="00"+e,new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(e)},cardinality:1}},onUnMask:function(e,t,n){return e},inputmode:"numeric"},email:{mask:"*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",greedy:!1,onBeforePaste:function(e,t){return(e=e.toLowerCase()).replace("mailto:","")},definitions:{"*":{validator:"[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",cardinality:1,casing:"lower"},"-":{validator:"[0-9A-Za-z-]",cardinality:1,casing:"lower"}},onUnMask:function(e,t,n){return e},inputmode:"email"},mac:{mask:"##:##:##:##:##:##"},vin:{mask:"V{13}9{4}",definitions:{V:{validator:"[A-HJ-NPR-Za-hj-npr-z\\d]",cardinality:1,casing:"upper"}},clearIncomplete:!0,autoUnmask:!0}}),t})},function(e,t,n){"use strict";var a,i,r;"function"==typeof Symbol&&Symbol.iterator;!function(o){i=[n(0),n(1)],void 0!==(r="function"==typeof(a=o)?a.apply(t,i):a)&&(e.exports=r)}(function(e,t,n){function a(e,n){for(var a="",i=0;i1&&(e.placeholder=e.placeholder.charAt(0)),"radixFocus"===e.positionCaretOnClick&&""===e.placeholder&&!1===e.integerOptional&&(e.positionCaretOnClick="lvp"),e.definitions[";"]=e.definitions["~"],e.definitions[";"].definitionSymbol="~",!0===e.numericInput&&(e.positionCaretOnClick="radixFocus"===e.positionCaretOnClick?"lvp":e.positionCaretOnClick,e.digitsOptional=!1,isNaN(e.digits)&&(e.digits=2),e.decimalProtect=!1);var r="[+]";if(r+=a(e.prefix,e),!0===e.integerOptional?r+="~{1,"+e.integerDigits+"}":r+="~{"+e.integerDigits+"}",e.digits!==n){e.radixPointDefinitionSymbol=e.decimalProtect?":":e.radixPoint;var o=e.digits.toString().split(",");isFinite(o[0]&&o[1]&&isFinite(o[1]))?r+=e.radixPointDefinitionSymbol+";{"+e.digits+"}":(isNaN(e.digits)||parseInt(e.digits)>0)&&(e.digitsOptional?r+="["+e.radixPointDefinitionSymbol+";{1,"+e.digits+"}]":r+=e.radixPointDefinitionSymbol+";{"+e.digits+"}")}return r+=a(e.suffix,e),r+="[-]",e.greedy=!1,r},placeholder:"",greedy:!1,digits:"*",digitsOptional:!0,enforceDigitsOnBlur:!1,radixPoint:".",positionCaretOnClick:"radixFocus",groupSize:3,groupSeparator:"",autoGroup:!1,allowMinus:!0,negationSymbol:{front:"-",back:""},integerDigits:"+",integerOptional:!0,prefix:"",suffix:"",rightAlign:!0,decimalProtect:!0,min:null,max:null,step:1,insertMode:!0,autoUnmask:!1,unmaskAsNumber:!1,inputmode:"numeric",preValidation:function(t,a,i,r,o){if("-"===i||i===o.negationSymbol.front)return!0===o.allowMinus&&(o.isNegative=o.isNegative===n||!o.isNegative,""===t.join("")||{caret:a,dopost:!0});if(!1===r&&i===o.radixPoint&&o.digits!==n&&(isNaN(o.digits)||parseInt(o.digits)>0)){var s=e.inArray(o.radixPoint,t);if(-1!==s)return!0===o.numericInput?a===s:{caret:s+1}}return!0},postValidation:function(a,i,r){var o=r.suffix.split(""),s=r.prefix.split("");if(i.pos===n&&i.caret!==n&&!0!==i.dopost)return i;var l=i.caret!==n?i.caret:i.pos,c=a.slice();r.numericInput&&(l=c.length-l-1,c=c.reverse());var u=c[l];if(u===r.groupSeparator&&(u=c[l+=1]),l===c.length-r.suffix.length-1&&u===r.radixPoint)return i;u!==n&&u!==r.radixPoint&&u!==r.negationSymbol.front&&u!==r.negationSymbol.back&&(c[l]="?",r.prefix.length>0&&l>=(!1===r.isNegative?1:0)&&l0&&l>=c.length-r.suffix.length-(!1===r.isNegative?1:0)&&(o[l-(c.length-r.suffix.length-(!1===r.isNegative?1:0))]="?")),s=s.join(""),o=o.join("");var p=c.join("").replace(s,"");if(p=p.replace(o,""),p=p.replace(new RegExp(t.escapeRegex(r.groupSeparator),"g"),""),p=p.replace(new RegExp("[-"+t.escapeRegex(r.negationSymbol.front)+"]","g"),""),p=p.replace(new RegExp(t.escapeRegex(r.negationSymbol.back)+"$"),""),isNaN(r.placeholder)&&(p=p.replace(new RegExp(t.escapeRegex(r.placeholder),"g"),"")),p.length>1&&1!==p.indexOf(r.radixPoint)&&("0"===u&&(p=p.replace(/^\?/g,"")),p=p.replace(/^0/g,"")),p.charAt(0)===r.radixPoint&&""!==r.radixPoint&&!0!==r.numericInput&&(p="0"+p),""!==p){if(p=p.split(""),(!r.digitsOptional||r.enforceDigitsOnBlur&&"blur"===i.event)&&isFinite(r.digits)){var f=e.inArray(r.radixPoint,p),d=e.inArray(r.radixPoint,c);-1===f&&(p.push(r.radixPoint),f=p.length-1);for(var m=1;m<=r.digits;m++)r.digitsOptional&&(!r.enforceDigitsOnBlur||"blur"!==i.event)||p[f+m]!==n&&p[f+m]!==r.placeholder.charAt(0)?-1!==d&&c[d+m]!==n&&(p[f+m]=p[f+m]||c[d+m]):p[f+m]=i.placeholder||r.placeholder.charAt(0)}if(!0!==r.autoGroup||""===r.groupSeparator||u===r.radixPoint&&i.pos===n&&!i.dopost)p=p.join("");else{var h=p[p.length-1]===r.radixPoint&&i.c===r.radixPoint;p=t(function(e,t){var n="";if(n+="("+t.groupSeparator+"*{"+t.groupSize+"}){*}",""!==t.radixPoint){var a=e.join("").split(t.radixPoint);a[1]&&(n+=t.radixPoint+"*{"+a[1].match(/^\d*\??\d*/)[0].length+"}")}return n}(p,r),{numericInput:!0,jitMasking:!0,definitions:{"*":{validator:"[0-9?]",cardinality:1}}}).format(p.join("")),h&&(p+=r.radixPoint),p.charAt(0)===r.groupSeparator&&p.substr(1)}}if(r.isNegative&&"blur"===i.event&&(r.isNegative="0"!==p),p=s+p,p+=o,r.isNegative&&(p=r.negationSymbol.front+p,p+=r.negationSymbol.back),p=p.split(""),u!==n)if(u!==r.radixPoint&&u!==r.negationSymbol.front&&u!==r.negationSymbol.back)(l=e.inArray("?",p))>-1?p[l]=u:l=i.caret||0;else if(u===r.radixPoint||u===r.negationSymbol.front||u===r.negationSymbol.back){var g=e.inArray(u,p);-1!==g&&(l=g)}r.numericInput&&(l=p.length-l-1,p=p.reverse());var v={caret:u===n||i.pos!==n?l+(r.numericInput?-1:1):l,buffer:p,refreshFromBuffer:i.dopost||a.join("")!==p.join("")};return v.refreshFromBuffer?v:i},onBeforeWrite:function(a,i,r,o){if(a)switch(a.type){case"keydown":return o.postValidation(i,{caret:r,dopost:!0},o);case"blur":case"checkval":var s;if(function(e){e.parseMinMaxOptions===n&&(null!==e.min&&(e.min=e.min.toString().replace(new RegExp(t.escapeRegex(e.groupSeparator),"g"),""),","===e.radixPoint&&(e.min=e.min.replace(e.radixPoint,".")),e.min=isFinite(e.min)?parseFloat(e.min):NaN,isNaN(e.min)&&(e.min=Number.MIN_VALUE)),null!==e.max&&(e.max=e.max.toString().replace(new RegExp(t.escapeRegex(e.groupSeparator),"g"),""),","===e.radixPoint&&(e.max=e.max.replace(e.radixPoint,".")),e.max=isFinite(e.max)?parseFloat(e.max):NaN,isNaN(e.max)&&(e.max=Number.MAX_VALUE)),e.parseMinMaxOptions="done")}(o),null!==o.min||null!==o.max){if(s=o.onUnMask(i.join(""),n,e.extend({},o,{unmaskAsNumber:!0})),null!==o.min&&so.max)return o.isNegative=o.max<0,o.postValidation(o.max.toString().replace(".",o.radixPoint).split(""),{caret:r,dopost:!0,placeholder:"0"},o)}return o.postValidation(i,{caret:r,placeholder:"0",event:"blur"},o);case"_checkval":return{caret:r}}},regex:{integerPart:function(e,n){return n?new RegExp("["+t.escapeRegex(e.negationSymbol.front)+"+]?"):new RegExp("["+t.escapeRegex(e.negationSymbol.front)+"+]?\\d+")},integerNPart:function(e){return new RegExp("[\\d"+t.escapeRegex(e.groupSeparator)+t.escapeRegex(e.placeholder.charAt(0))+"]+")}},definitions:{"~":{validator:function(e,a,i,r,o,s){var l=r?new RegExp("[0-9"+t.escapeRegex(o.groupSeparator)+"]").test(e):new RegExp("[0-9]").test(e);if(!0===l){if(!0!==o.numericInput&&a.validPositions[i]!==n&&"~"===a.validPositions[i].match.def&&!s){var c=a.buffer.join(""),u=(c=(c=c.replace(new RegExp("[-"+t.escapeRegex(o.negationSymbol.front)+"]","g"),"")).replace(new RegExp(t.escapeRegex(o.negationSymbol.back)+"$"),"")).split(o.radixPoint);u.length>1&&(u[1]=u[1].replace(/0/g,o.placeholder.charAt(0))),"0"===u[0]&&(u[0]=u[0].replace(/0/g,o.placeholder.charAt(0))),c=u[0]+o.radixPoint+u[1]||"";var p=a._buffer.join("");for(c===o.radixPoint&&(c=p);null===c.match(t.escapeRegex(p)+"$");)p=p.slice(1);l=(c=(c=c.replace(p,"")).split(""))[i]===n?{pos:i,remove:i}:{pos:i}}}else r||e!==o.radixPoint||a.validPositions[i-1]!==n||(a.buffer[i]="0",l={pos:i+1});return l},cardinality:1},"+":{validator:function(e,t,n,a,i){return i.allowMinus&&("-"===e||e===i.negationSymbol.front)},cardinality:1,placeholder:""},"-":{validator:function(e,t,n,a,i){return i.allowMinus&&e===i.negationSymbol.back},cardinality:1,placeholder:""},":":{validator:function(e,n,a,i,r){var o="["+t.escapeRegex(r.radixPoint)+"]",s=new RegExp(o).test(e);return s&&n.validPositions[a]&&n.validPositions[a].match.placeholder===r.radixPoint&&(s={caret:a+1}),s},cardinality:1,placeholder:function(e){return e.radixPoint}}},onUnMask:function(e,n,a){if(""===n&&!0===a.nullable)return n;var i=e.replace(a.prefix,"");return i=i.replace(a.suffix,""),i=i.replace(new RegExp(t.escapeRegex(a.groupSeparator),"g"),""),""!==a.placeholder.charAt(0)&&(i=i.replace(new RegExp(a.placeholder.charAt(0),"g"),"0")),a.unmaskAsNumber?(""!==a.radixPoint&&-1!==i.indexOf(a.radixPoint)&&(i=i.replace(t.escapeRegex.call(this,a.radixPoint),".")),i=i.replace(new RegExp("^"+t.escapeRegex(a.negationSymbol.front)),"-"),i=i.replace(new RegExp(t.escapeRegex(a.negationSymbol.back)+"$"),""),Number(i)):i},isComplete:function(e,n){var a=e.join("");if(e.slice().join("")!==a)return!1;var i=a.replace(n.prefix,"");return i=i.replace(n.suffix,""),i=i.replace(new RegExp(t.escapeRegex(n.groupSeparator),"g"),""),","===n.radixPoint&&(i=i.replace(t.escapeRegex(n.radixPoint),".")),isFinite(i)},onBeforeMask:function(e,a){if(a.isNegative=n,e=e.toString().charAt(e.length-1)===a.radixPoint?e.toString().substr(0,e.length-1):e.toString(),""!==a.radixPoint&&isFinite(e)){var i=e.split("."),r=""!==a.groupSeparator?parseInt(a.groupSize):0;2===i.length&&(i[0].length>r||i[1].length>r||i[0].length<=r&&i[1].lengtho.length?(e=e.replace(/\./g,"")).replace(",",a.radixPoint):o.length>s.length?(e=e.replace(/,/g,"")).replace(".",a.radixPoint):e.indexOf(".")=0;l--)o[i=(t=e[l].mask||e[l]).substr(0,1)]=o[i]||[],o[i].unshift(t.substr(1)),e.splice(l,1);for(var c in o)o[c].length>500&&r(o[c].slice(),c,o)}function o(t){var n="",a=[];for(var r in t)e.isArray(t[r])?1===t[r].length?a.push(r+t[r]):a.push(r+i.groupmarker.start+t[r].join(i.groupmarker.end+i.alternatormarker+i.groupmarker.start)+i.groupmarker.end):a.push(r+o(t[r]));return 1===a.length?n+=a[0]:n+=i.groupmarker.start+a.join(i.groupmarker.end+i.alternatormarker+i.groupmarker.start)+i.groupmarker.end,n}var s={};return i.phoneCodes&&(i.phoneCodes&&i.phoneCodes.length>1e3&&(r((t=t.substr(1,t.length-2)).split(i.groupmarker.end+i.alternatormarker+i.groupmarker.start)),t=o(s)),t=t.replace(/9/g,"\\9")),a.call(this,t,n,i)},t.extendAliases({abstractphone:{groupmarker:{start:"<",end:">"},countrycode:"",phoneCodes:[],mask:function(e){return e.definitions={"#":t.prototype.definitions[9]},e.phoneCodes.sort(n)},keepStatic:!0,onBeforeMask:function(e,t){var n=e.replace(/^0{1,2}/,"").replace(/[\s]/g,"");return(n.indexOf(t.countrycode)>1||-1===n.indexOf(t.countrycode))&&(n="+"+t.countrycode+n),n},onUnMask:function(e,t,n){return e.replace(/[()#-]/g,"")},inputmode:"tel"}}),t})},function(e,t,n){"use strict";var a,i,r;"function"==typeof Symbol&&Symbol.iterator;!function(o){i=[n(0),n(1)],void 0!==(r="function"==typeof(a=o)?a.apply(t,i):a)&&(e.exports=r)}(function(e,t){return t.extendAliases({Regex:{mask:"r",greedy:!1,repeat:"*",regex:null,regexTokens:null,tokenizer:/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,quantifierFilter:/[0-9]+[^,]/,isComplete:function(e,t){return new RegExp(t.regex,t.casing?"i":"").test(e.join(""))},definitions:{r:{validator:function(t,n,a,i,r){function o(e,t){this.matches=[],this.isGroup=e||!1,this.isQuantifier=t||!1,this.quantifier={min:1,max:1},this.repeaterPart=void 0}function s(t,n){var a=!1;n&&(p+="(",d++);for(var i=0;ip.length&&!(a=s(u,!0)););(a=a||s(u,!0))&&(o.repeaterPart=p),p=f+o.quantifier.max}else{for(var m=0,h=o.quantifier.max-1;m0?a[a.length-1].matches.push(c):n.matches.push(c);break;case"{":case"+":case"*":var i=new o(!1,!0),s=(t=t.replace(/[{}]/g,"")).split(","),l=isNaN(s[0])?s[0]:parseInt(s[0]),u=1===s.length?l:isNaN(s[1])?s[1]:parseInt(s[1]);if(i.quantifier={min:l,max:u},a.length>0){var p=a[a.length-1].matches;(e=p.pop()).isGroup||((c=new o(!0)).matches.push(e),e=c),p.push(e),p.push(i)}else(e=n.matches.pop()).isGroup||((c=new o(!0)).matches.push(e),e=c),n.matches.push(e),n.matches.push(i);break;default:a.length>0?a[a.length-1].matches.push(t):n.matches.push(t)}n.matches.length>0&&r.regexTokens.push(n)}(),u.splice(a,0,t),l=u.join("");for(var m=0;m 2, + point = this.points[0]; + + if (!canDrawCurve && point) { + this._strokeDraw(point); + } + if (typeof this.onEnd === 'function') { + this.onEnd(event); + } + }; + + SignaturePad.prototype._handleMouseEvents = function () { + this._mouseButtonDown = false; + + this._canvas.addEventListener("mousedown", this._handleMouseDown); + this._canvas.addEventListener("mousemove", this._handleMouseMove); + document.addEventListener("mouseup", this._handleMouseUp); + }; + + SignaturePad.prototype._handleTouchEvents = function () { + // Pass touch events to canvas element on mobile IE11 and Edge. + this._canvas.style.msTouchAction = 'none'; + this._canvas.style.touchAction = 'none'; + + this._canvas.addEventListener("touchstart", this._handleTouchStart); + this._canvas.addEventListener("touchmove", this._handleTouchMove); + document.addEventListener("touchend", this._handleTouchEnd); + }; + + SignaturePad.prototype.on = function () { + this._handleMouseEvents(); + this._handleTouchEvents(); + }; + + SignaturePad.prototype.off = function () { + this._canvas.removeEventListener("mousedown", this._handleMouseDown); + this._canvas.removeEventListener("mousemove", this._handleMouseMove); + document.removeEventListener("mouseup", this._handleMouseUp); + + this._canvas.removeEventListener("touchstart", this._handleTouchStart); + this._canvas.removeEventListener("touchmove", this._handleTouchMove); + document.removeEventListener("touchend", this._handleTouchEnd); + }; + + SignaturePad.prototype.isEmpty = function () { + return this._isEmpty; + }; + + SignaturePad.prototype._reset = function () { + this.points = []; + this._lastVelocity = 0; + this._lastWidth = (this.minWidth + this.maxWidth) / 2; + this._isEmpty = true; + this._ctx.fillStyle = this.penColor; + }; + + SignaturePad.prototype._createPoint = function (event) { + var rect = this._canvas.getBoundingClientRect(); + return new Point( + event.clientX - rect.left, + event.clientY - rect.top + ); + }; + + SignaturePad.prototype._addPoint = function (point) { + var points = this.points, + c2, c3, + curve, tmp; + + points.push(point); + + if (points.length > 2) { + // To reduce the initial lag make it work with 3 points + // by copying the first point to the beginning. + if (points.length === 3) points.unshift(points[0]); + + tmp = this._calculateCurveControlPoints(points[0], points[1], points[2]); + c2 = tmp.c2; + tmp = this._calculateCurveControlPoints(points[1], points[2], points[3]); + c3 = tmp.c1; + curve = new Bezier(points[1], c2, c3, points[2]); + this._addCurve(curve); + + // Remove the first element from the list, + // so that we always have no more than 4 points in points array. + points.shift(); + } + }; + + SignaturePad.prototype._calculateCurveControlPoints = function (s1, s2, s3) { + var dx1 = s1.x - s2.x, dy1 = s1.y - s2.y, + dx2 = s2.x - s3.x, dy2 = s2.y - s3.y, + + m1 = {x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0}, + m2 = {x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0}, + + l1 = Math.sqrt(dx1*dx1 + dy1*dy1), + l2 = Math.sqrt(dx2*dx2 + dy2*dy2), + + dxm = (m1.x - m2.x), + dym = (m1.y - m2.y), + + k = l2 / (l1 + l2), + cm = {x: m2.x + dxm*k, y: m2.y + dym*k}, + + tx = s2.x - cm.x, + ty = s2.y - cm.y; + + return { + c1: new Point(m1.x + tx, m1.y + ty), + c2: new Point(m2.x + tx, m2.y + ty) + }; + }; + + SignaturePad.prototype._addCurve = function (curve) { + var startPoint = curve.startPoint, + endPoint = curve.endPoint, + velocity, newWidth; + + velocity = endPoint.velocityFrom(startPoint); + velocity = this.velocityFilterWeight * velocity + + (1 - this.velocityFilterWeight) * this._lastVelocity; + + newWidth = this._strokeWidth(velocity); + this._drawCurve(curve, this._lastWidth, newWidth); + + this._lastVelocity = velocity; + this._lastWidth = newWidth; + }; + + SignaturePad.prototype._drawPoint = function (x, y, size) { + var ctx = this._ctx; + + ctx.moveTo(x, y); + ctx.arc(x, y, size, 0, 2 * Math.PI, false); + this._isEmpty = false; + }; + + SignaturePad.prototype._drawCurve = function (curve, startWidth, endWidth) { + var ctx = this._ctx, + widthDelta = endWidth - startWidth, + drawSteps, width, i, t, tt, ttt, u, uu, uuu, x, y; + + drawSteps = Math.floor(curve.length()); + ctx.beginPath(); + for (i = 0; i < drawSteps; i++) { + // Calculate the Bezier (x, y) coordinate for this step. + t = i / drawSteps; + tt = t * t; + ttt = tt * t; + u = 1 - t; + uu = u * u; + uuu = uu * u; + + x = uuu * curve.startPoint.x; + x += 3 * uu * t * curve.control1.x; + x += 3 * u * tt * curve.control2.x; + x += ttt * curve.endPoint.x; + + y = uuu * curve.startPoint.y; + y += 3 * uu * t * curve.control1.y; + y += 3 * u * tt * curve.control2.y; + y += ttt * curve.endPoint.y; + + width = startWidth + ttt * widthDelta; + this._drawPoint(x, y, width); + } + ctx.closePath(); + ctx.fill(); + }; + + SignaturePad.prototype._strokeWidth = function (velocity) { + return Math.max(this.maxWidth / (velocity + 1), this.minWidth); + }; + + + var Point = function (x, y, time) { + this.x = x; + this.y = y; + this.time = time || new Date().getTime(); + }; + + Point.prototype.velocityFrom = function (start) { + return (this.time !== start.time) ? this.distanceTo(start) / (this.time - start.time) : 1; + }; + + Point.prototype.distanceTo = function (start) { + return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2)); + }; + + var Bezier = function (startPoint, control1, control2, endPoint) { + this.startPoint = startPoint; + this.control1 = control1; + this.control2 = control2; + this.endPoint = endPoint; + }; + + // Returns approximated length. + Bezier.prototype.length = function () { + var steps = 10, + length = 0, + i, t, cx, cy, px, py, xdiff, ydiff; + + for (i = 0; i <= steps; i++) { + t = i / steps; + cx = this._point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x); + cy = this._point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y); + if (i > 0) { + xdiff = cx - px; + ydiff = cy - py; + length += Math.sqrt(xdiff * xdiff + ydiff * ydiff); + } + px = cx; + py = cy; + } + return length; + }; + + Bezier.prototype._point = function (t, start, c1, c2, end) { + return start * (1.0 - t) * (1.0 - t) * (1.0 - t) + + 3.0 * c1 * (1.0 - t) * (1.0 - t) * t + + 3.0 * c2 * (1.0 - t) * t * t + + end * t * t * t; + }; + + return SignaturePad; +})(document); + +/** + * Version: 1.0 Alpha-1 + * Build Date: 13-Nov-2007 + * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. + * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. + * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ + */ +Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}}; +Date.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;idate)?1:(this=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config=="number"){this._orient=config;return this;} +var x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);} +if(x.second||x.seconds){this.addSeconds(x.second||x.seconds);} +if(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);} +if(x.hour||x.hours){this.addHours(x.hour||x.hours);} +if(x.month||x.months){this.addMonths(x.month||x.months);} +if(x.year||x.years){this.addYears(x.year||x.years);} +if(x.day||x.days){this.addDays(x.day||x.days);} +return this;};Date._validate=function(value,min,max,name){if(typeof value!="number"){throw new TypeError(value+" is not a Number.");}else if(valuemax){throw new RangeError(value+" is not a valid value for "+name+".");} +return true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,"milliseconds");};Date.validateSecond=function(n){return Date._validate(n,0,59,"seconds");};Date.validateMinute=function(n){return Date._validate(n,0,59,"minutes");};Date.validateHour=function(n){return Date._validate(n,0,23,"hours");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),"days");};Date.validateMonth=function(n){return Date._validate(n,0,11,"months");};Date.validateYear=function(n){return Date._validate(n,1,9999,"seconds");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;} +if(!x.second&&x.second!==0){x.second=-1;} +if(!x.minute&&x.minute!==0){x.minute=-1;} +if(!x.hour&&x.hour!==0){x.hour=-1;} +if(!x.day&&x.day!==0){x.day=-1;} +if(!x.month&&x.month!==0){x.month=-1;} +if(!x.year&&x.year!==0){x.year=-1;} +if(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());} +if(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());} +if(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());} +if(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());} +if(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());} +if(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());} +if(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());} +if(x.timezone){this.setTimezone(x.timezone);} +if(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);} +return this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;} +var daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}} +return w;};Date.prototype.isDST=function(){console.log('isDST');return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?"0"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case"hh":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case"h":return self.getHours()<13?self.getHours():(self.getHours()-12);case"HH":return p(self.getHours());case"H":return self.getHours();case"mm":return p(self.getMinutes());case"m":return self.getMinutes();case"ss":return p(self.getSeconds());case"s":return self.getSeconds();case"yyyy":return self.getFullYear();case"yy":return self.getFullYear().toString().substring(2,4);case"dddd":return self.getDayName();case"ddd":return self.getDayName(true);case"dd":return p(self.getDate());case"d":return self.getDate().toString();case"MMMM":return self.getMonthName();case"MMM":return self.getMonthName(true);case"MM":return p((self.getMonth()+1));case"M":return self.getMonth()+1;case"t":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return"";}}):this._toString();}; +Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;} +return this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;} +if(!last&&q[1].length===0){last=true;} +if(!last){var qx=[];for(var j=0;j0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}} +if(rx[1].length1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];} +if(args){for(var i=0,px=args.shift();i2)?n:(n+(((n+2000)Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.");} +var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});} +return r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;} +for(var i=0;i'; + var html = html.replace(/_id_/g,id); + var html = html.replace(/_msg_/g,msg); + var html = html.replace(/_file_group_/g,group); + var html = html.replace(/_user_/g,user); + var html = html.replace(/_file_type_/g,fileType); + + modJs.renderModel('upload',"Upload File",html); + $('#uploadModel').modal('show'); + +} + +function closeUploadDialog(success,error,data){ + var arr = data.split("|"); + var file = arr[0]; + var fileBaseName = arr[1]; + var fileId = arr[2]; + + if(success == 1){ + //popupUpload.close(); + $('#uploadModel').modal('hide'); + if(uploadResultAttr == "url"){ + if(uploadAttr == "val"){ + $('#'+uploadId).val(file); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(file); + }else{ + $('#'+uploadId).attr(uploadAttr,file); + } + + }else if(uploadResultAttr == "name"){ + if(uploadAttr == "val"){ + $('#'+uploadId).val(fileBaseName); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(fileBaseName); + $('#'+uploadId).attr("val",fileBaseName); + }else{ + $('#'+uploadId).attr(uploadAttr,fileBaseName); + } + $('#'+uploadId).show(); + $('#'+uploadId+"_download").show(); + $('#'+uploadId+"_remove").show(); + }else if(uploadResultAttr == "id"){ + if(uploadAttr == "val"){ + $('#'+uploadId).attr(uploadAttr,fileId); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(fileBaseName); + $('#'+uploadId).attr("val",fileId); + }else{ + $('#'+uploadId).attr(uploadAttr,fileId); + } + $('#'+uploadId).show(); + $('#'+uploadId+"_download").show(); + $('#'+uploadId+"_remove").show(); + } + + + }else{ + //popupUpload.close(); + $('#uploadModel').modal('hide'); + } + +} + +function download(name, closeCallback, closeCallbackData){ + + var successCallback = function(data){ + + var link; + var fileParts; + var viewableImages = ["png","jpg","gif","bmp","jpge"]; + var viewableFiles = ["pdf","xml"]; + + $('.modal').modal('hide'); + + if(data['filename'].indexOf("https:") == 0 || data['filename'].indexOf("http:") == 0){ + fileParts = data['filename'].split("?"); + fileParts = fileParts[0].split("."); + + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableFiles ) >= 0) { + var win = window.open(data['filename'], '_blank'); + win.focus(); + }else{ + link = 'Download File '; + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableImages ) >= 0) { + link += '

    '; + } + modJs.showMessage("Download File Attachment",link,closeCallback,closeCallbackData); + } + }else{ + fileParts = data['filename'].split("."); + link = 'Download File '; + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableImages ) >= 0) { + link += '

    '; + } + + modJs.showMessage("Download File Attachment",link,closeCallback,closeCallbackData); + } + + + }; + + var failCallback = function(data){ + modJs.showMessage("Error Downloading File","File not found"); + }; + + modJs.sendCustomRequest("file",{'name':name},successCallback,failCallback); +} + +function randomString(length){ + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''); + + if (! length) { + length = Math.floor(Math.random() * chars.length); + } + + var str = ''; + for (var i = 0; i < length; i++) { + str += chars[Math.floor(Math.random() * chars.length)]; + } + return str; +} + +function verifyInstance(key){ + var object = {}; + object['a'] = "verifyInstance"; + object['key'] = key; + $.post(this.baseUrl, object, function(data) { + if(data.status == "SUCCESS"){ + $("#verifyModel").hide(); + $('body').removeClass('modal-open'); + $('.modal-backdrop').remove(); + alert("Success: Instance Verified"); + }else{ + alert("Error: "+data.message); + } + },"json"); +} + +function nl2br(str, is_xhtml) { + // discuss at: http://phpjs.org/functions/nl2br/ + // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Philip Peterson + // improved by: Onno Marsman + // improved by: Atli ��r + // improved by: Brett Zamir (http://brett-zamir.me) + // improved by: Maximusya + // bugfixed by: Onno Marsman + // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // input by: Brett Zamir (http://brett-zamir.me) + // example 1: nl2br('Kevin\nvan\nZonneveld'); + // returns 1: 'Kevin
    \nvan
    \nZonneveld' + // example 2: nl2br("\nOne\nTwo\n\nThree\n", false); + // returns 2: '
    \nOne
    \nTwo
    \n
    \nThree
    \n' + // example 3: nl2br("\nOne\nTwo\n\nThree\n", true); + // returns 3: '
    \nOne
    \nTwo
    \n
    \nThree
    \n' + + var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
    ' : '
    '; // Adjust comment to avoid issue on phpjs.org display + + return (str + '') + .replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); +} + +function updateLanguage(language) { + var object = {}; + object['a'] = "updateLanguage"; + object['language'] = language; + $.post(this.baseUrl, object, function(data) { + if(data.status == "SUCCESS"){ + location.reload(); + } else { + alert("Error occurred while changing language"); + } + },"json"); +} diff --git a/web/js/bootstrap-colorpicker-2.1.1/css/bootstrap-colorpicker.css b/web/js/bootstrap-colorpicker-2.1.1/css/bootstrap-colorpicker.css index 80175eaf..e055992b 100644 --- a/web/js/bootstrap-colorpicker-2.1.1/css/bootstrap-colorpicker.css +++ b/web/js/bootstrap-colorpicker-2.1.1/css/bootstrap-colorpicker.css @@ -13,7 +13,7 @@ width: 100px; height: 100px; cursor: crosshair; - background-image: url("../img/bootstrap-colorpicker/saturation.png"); + background-image: url("img/bootstrap-colorpicker/saturation.png"); } .colorpicker-saturation i { @@ -64,12 +64,12 @@ } .colorpicker-hue { - background-image: url("../img/bootstrap-colorpicker/hue.png"); + background-image: url("img/bootstrap-colorpicker/hue.png"); } .colorpicker-alpha { display: none; - background-image: url("../img/bootstrap-colorpicker/alpha.png"); + background-image: url("img/bootstrap-colorpicker/alpha.png"); } .colorpicker { @@ -135,7 +135,7 @@ height: 10px; margin-top: 5px; clear: both; - background-image: url("../img/bootstrap-colorpicker/alpha.png"); + background-image: url("img/bootstrap-colorpicker/alpha.png"); background-position: 0 100%; } @@ -197,11 +197,11 @@ } .colorpicker.colorpicker-horizontal .colorpicker-hue { - background-image: url("../img/bootstrap-colorpicker/hue-horizontal.png"); + background-image: url("img/bootstrap-colorpicker/hue-horizontal.png"); } .colorpicker.colorpicker-horizontal .colorpicker-alpha { - background-image: url("../img/bootstrap-colorpicker/alpha-horizontal.png"); + background-image: url("img/bootstrap-colorpicker/alpha-horizontal.png"); } .colorpicker.colorpicker-hidden { diff --git a/web/js/downloadify/images/download.png b/web/js/downloadify/images/download.png deleted file mode 100755 index d2fabbf5..00000000 Binary files a/web/js/downloadify/images/download.png and /dev/null differ diff --git a/web/js/downloadify/js/downloadify.min.js b/web/js/downloadify/js/downloadify.min.js deleted file mode 100755 index faf490c0..00000000 --- a/web/js/downloadify/js/downloadify.min.js +++ /dev/null @@ -1,3 +0,0 @@ -/* Downloadify 0.2 (c) 2009 by Douglas Neiner. Licensed under the MIT license */ -/* See http://github.com/dcneiner/Downloadify for license and more info */ -(function(){Downloadify=window.Downloadify={queue:{},uid:new Date().getTime(),getTextForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getData();return""},getFileNameForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getFilename();return""},getDataTypeForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getDataType();return""},saveComplete:function(a){var b=Downloadify.queue[a];if(b)b.complete();return true},saveCancel:function(a){var b=Downloadify.queue[a];if(b)b.cancel();return true},saveError:function(a){var b=Downloadify.queue[a];if(b)b.error();return true},addToQueue:function(a){Downloadify.queue[a.queue_name]=a},getUID:function(a){if(a.id=="")a.id='downloadify_'+Downloadify.uid++;return a.id}};Downloadify.create=function(a,b){var c=(typeof(a)=="string"?document.getElementById(a):a);return new Downloadify.Container(c,b)};Downloadify.Container=function(d,e){var f=this;f.el=d;f.enabled=true;f.dataCallback=null;f.filenameCallback=null;f.data=null;f.filename=null;var g=function(){f.options=e;if(!f.options.append)f.el.innerHTML="";f.flashContainer=document.createElement('span');f.el.appendChild(f.flashContainer);f.queue_name=Downloadify.getUID(f.flashContainer);if(typeof(f.options.filename)==="function")f.filenameCallback=f.options.filename;else if(f.options.filename)f.filename=f.options.filename;if(typeof(f.options.data)==="function")f.dataCallback=f.options.data;else if(f.options.data)f.data=f.options.data;var a={queue_name:f.queue_name,width:f.options.width,height:f.options.height};var b={allowScriptAccess:'always'};var c={id:f.flashContainer.id,name:f.flashContainer.id};if(f.options.enabled===false)f.enabled=false;if(f.options.transparent===true)b.wmode="transparent";if(f.options.downloadImage)a.downloadImage=f.options.downloadImage;swfobject.embedSWF(f.options.swf,f.flashContainer.id,f.options.width,f.options.height,"10",null,a,b,c);Downloadify.addToQueue(f)};f.enable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(true);f.enabled=true};f.disable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(false);f.enabled=false};f.getData=function(){if(!f.enabled)return"";if(f.dataCallback)return f.dataCallback();else if(f.data)return f.data;else return""};f.getFilename=function(){if(f.filenameCallback)return f.filenameCallback();else if(f.filename)return f.filename;else return""};f.getDataType=function(){if(f.options.dataType)return f.options.dataType;return"string"};f.complete=function(){if(typeof(f.options.onComplete)==="function")f.options.onComplete()};f.cancel=function(){if(typeof(f.options.onCancel)==="function")f.options.onCancel()};f.error=function(){if(typeof(f.options.onError)==="function")f.options.onError()};g()};Downloadify.defaultOptions={swf:'media/downloadify.swf',downloadImage:'images/download.png',width:100,height:30,transparent:true,append:false,dataType:"string"}})();if(typeof(jQuery)!="undefined"){(function($){$.fn.downloadify=function(b){return this.each(function(){b=$.extend({},Downloadify.defaultOptions,b);var a=Downloadify.create(this,b);$(this).data('Downloadify',a)})}})(jQuery)};if(typeof(MooTools)!='undefined'){Element.implement({downloadify:function(a){a=$merge(Downloadify.defaultOptions,a);return this.store('Downloadify',Downloadify.create(this,a))}})}; \ No newline at end of file diff --git a/web/js/downloadify/js/swfobject.js b/web/js/downloadify/js/swfobject.js deleted file mode 100755 index 8eafe9dd..00000000 --- a/web/js/downloadify/js/swfobject.js +++ /dev/null @@ -1,4 +0,0 @@ -/* SWFObject v2.2 - is released under the MIT License -*/ -var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab .select2-chosen { text-decoration: none; border: 0; - background: url('select2.png') right top no-repeat; + background: url(' img/select2/select2.png') right top no-repeat; cursor: pointer; outline: 0; } @@ -218,7 +218,7 @@ html[dir="rtl"] .select2-container .select2-choice .select2-arrow { display: block; width: 100%; height: 100%; - background: url('select2.png') no-repeat 0 1px; + background: url(' img/select2/select2.png') no-repeat 0 1px; } html[dir="rtl"] .select2-container .select2-choice .select2-arrow b { @@ -256,21 +256,21 @@ html[dir="rtl"] .select2-container .select2-choice .select2-arrow b { -webkit-box-shadow: none; box-shadow: none; - background: #fff url('select2.png') no-repeat 100% -22px; - background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); - background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; + background: #fff url(' img/select2/select2.png') no-repeat 100% -22px; + background: url(' img/select2/select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url(' img/select2/select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } html[dir="rtl"] .select2-search input { padding: 4px 5px 4px 20px; - background: #fff url('select2.png') no-repeat -37px -22px; - background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); - background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; + background: #fff url(' img/select2/select2.png') no-repeat -37px -22px; + background: url(' img/select2/select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url(' img/select2/select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } .select2-drop.select2-drop-above .select2-search input { @@ -278,11 +278,11 @@ html[dir="rtl"] .select2-search input { } .select2-search input.select2-active { - background: #fff url('select2-spinner.gif') no-repeat 100%; - background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); - background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); - background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; + background: #fff url(' img/select2/select2-spinner.gif') no-repeat 100%; + background: url(' img/select2/select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); + background: url(' img/select2/select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); + background: url(' img/select2/select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } .select2-container-active .select2-choice, @@ -451,7 +451,7 @@ disabled look for disabled choices in the results dropdown } .select2-more-results.select2-active { - background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%; + background: #f4f4f4 url(' img/select2/select2-spinner.gif') no-repeat 100%; } .select2-results .select2-ajax-error { @@ -551,7 +551,7 @@ html[dir="rtl"] .select2-container-multi .select2-choices li } .select2-container-multi .select2-choices .select2-search-field input.select2-active { - background: #fff url('select2-spinner.gif') no-repeat 100% !important; + background: #fff url(' img/select2/select2-spinner.gif') no-repeat 100% !important; } .select2-default { @@ -610,7 +610,7 @@ html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice font-size: 1px; outline: none; - background: url('select2.png') right top no-repeat; + background: url(' img/select2/select2.png') right top no-repeat; } html[dir="rtl"] .select2-search-choice-close { right: auto; @@ -693,7 +693,7 @@ html[dir="rtl"] .select2-container-multi .select2-search-choice-close { .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b { - background-image: url('select2x2.png') !important; + background-image: url('img/select2/select2x2.png') !important; background-repeat: no-repeat !important; background-size: 60px 40px !important; } diff --git a/web/modules/attendance/lib.js b/web/modules/attendance/lib.js deleted file mode 100644 index c579a27f..00000000 --- a/web/modules/attendance/lib.js +++ /dev/null @@ -1,513 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function AttendanceAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.punch = null; - this.useServerTime = 0; - this.photoTaken = 0; - this.photoAttendance = 0; -} - -AttendanceAdapter.inherits(AdapterBase); - -AttendanceAdapter.method('updatePunchButton', function() { - this.getPunch('changePunchButtonSuccessCallBack'); -}); - -AttendanceAdapter.method('setUseServerTime', function(val) { - this.useServerTime = val; -}); - -AttendanceAdapter.method('setPhotoAttendance', function(val) { - this.photoAttendance = val; -}); - - -AttendanceAdapter.method('getDataMapping', function() { - return [ - "id", - "in_time", - "out_time", - "note" - ]; -}); - -AttendanceAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Time-In" }, - { "sTitle": "Time-Out"}, - { "sTitle": "Note"} - ]; -}); - -AttendanceAdapter.method('getFormFields', function() { - if(this.useServerTime == 0){ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "time", {"label":"Time","type":"datetime"}], - [ "note", {"label":"Note","type":"textarea","validation":"none"}] - ]; - }else{ - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "note", {"label":"Note","type":"textarea","validation":"none"}] - ]; - } - -}); - - -AttendanceAdapter.method('getCustomTableParams', function() { - var that = this; - var dataTableParams = { - "aoColumnDefs": [ - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 1) - } , - "aTargets": [1] - }, - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 2) - } , - "aTargets": [2] - }, - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 3) - } , - "aTargets": [3] - }, - { - "fnRender": that.getActionButtons, - "aTargets": [that.getDataMapping().length] - } - ] - }; - return dataTableParams; -}); - -AttendanceAdapter.method('preProcessRemoteTableData', function(data, cell, id) { - if(id == 1){ - if(cell == '0000-00-00 00:00:00' || cell == "" || cell == undefined || cell == null){ - return ""; - } - return Date.parse(cell).toString('yyyy MMM d HH:mm'); - }else if(id == 2){ - if(cell == '0000-00-00 00:00:00' || cell == "" || cell == undefined || cell == null){ - return ""; - } - return Date.parse(cell).toString('MMM d HH:mm'); - }else if(id == 3){ - if(cell != undefined && cell != null){ - if(cell.length > 20){ - return cell.substring(0,20)+".."; - } - } - return cell; - } - -}); - - -AttendanceAdapter.method('getActionButtonsHtml', function(id,data) { - /* - var html = '
    '; - html = html.replace(/_id_/g,id); - html = html.replace(/_attachment_/g,data[5]); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; - */ - return ""; -}); - -AttendanceAdapter.method('getTableTopButtonHtml', function() { - if(this.punch == null || this.punch == undefined){ - return ''; - }else{ - return ''; - } - -}); - - -AttendanceAdapter.method('save', function() { - var that = this; - var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - if(validator.checkValues()){ - - var msg = this.doCustomValidation(params); - if(msg == null){ - var params = validator.getFormParameters(); - params = this.forceInjectValuesBeforeSave(params); - params['cdate'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); - var reqJson = JSON.stringify(params); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'saveSuccessCallback'; - callBackData['callBackFail'] = 'getPunchFailCallBack'; - - this.customAction('savePunch','modules=attendance',reqJson,callBackData, true); - }else{ - $("#"+this.getTableName()+'Form .label').html(msg); - $("#"+this.getTableName()+'Form .label').show(); - } - } -}); - -AttendanceAdapter.method('saveSuccessCallback', function(callBackData) { - this.punch = callBackData; - this.getPunch('changePunchButtonSuccessCallBack'); - $('#PunchModel').modal('hide'); - this.get([]); -}); - - -AttendanceAdapter.method('cancel', function() { - $('#PunchModel').modal('hide'); -}); - -AttendanceAdapter.method('showPunchDialog', function() { - this.getPunch('showPunchDialogShowPunchSuccessCallBack'); -}); - -AttendanceAdapter.method('getPunch', function(successCallBack) { - var that = this; - var object = {}; - - object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); - object['offset'] = this.getClientGMTOffset(); - var reqJson = JSON.stringify(object); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = successCallBack; - callBackData['callBackFail'] = 'getPunchFailCallBack'; - - this.customAction('getPunch','modules=attendance',reqJson,callBackData); -}); - -AttendanceAdapter.method('postRenderForm', function(object, $tempDomObj) { - $("#Attendance").show(); -}); - - -AttendanceAdapter.method('showPunchDialogShowPunchSuccessCallBack', function(callBackData) { - this.punch = callBackData; - $('#PunchModel').modal('show'); - if(this.punch == null){ - $('#PunchModel').find("h3").html("Punch Time-in"); - modJs.renderForm(); - }else{ - $('#PunchModel').find("h3").html("Punch Time-out"); - modJs.renderForm(this.punch); - } - $('#Attendance').show(); - var picker = $('#time_datetime').data('datetimepicker'); - picker.setLocalDate(new Date()); -}); - -AttendanceAdapter.method('changePunchButtonSuccessCallBack', function(callBackData) { - this.punch = callBackData; - if(this.punch == null){ - $("#punchButton").html('Punch-in '); - }else{ - $("#punchButton").html('Punch-out '); - } -}); - -AttendanceAdapter.method('getPunchFailCallBack', function(callBackData) { - this.showMessage("Error Occured while Time Punch", callBackData); -}); - -AttendanceAdapter.method('getClientDate', function (date) { - - var offset = this.getClientGMTOffset(); - var tzDate = date.addMinutes(offset*60); - return tzDate; - -}); - -AttendanceAdapter.method('getClientGMTOffset', function () { - - var rightNow = new Date(); - var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); - var temp = jan1.toGMTString(); - var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); - var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); - - return std_time_offset; - -}); - -AttendanceAdapter.method('doCustomValidation', function(params) { - if (this.photoAttendance && !this.photoTaken) { - return "Please attach a photo before submitting"; - } - return null; -}); - -AttendanceAdapter.method('forceInjectValuesBeforeSave', function(params) { - if (this.photoAttendance) { - var canvas = document.getElementById('attendnaceCanvas'); - params.image = canvas.toDataURL(); - } - return params; -}); - -AttendanceAdapter.method('postRenderForm', function() { - if (this.photoAttendance == '1') { - $('.photoAttendance').show(); - var video = document.getElementById('attendnaceVideo'); - - // Get access to the camera! - if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { - navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) { - video.src = window.URL.createObjectURL(stream); - video.play(); - }); - } - this.photoTaken = false; - this.configureEvents(); - } else { - $('.photoAttendance').remove(); - } - -}); - -AttendanceAdapter.method('configureEvents', function() { - var that = this; - var canvas = document.getElementById('attendnaceCanvas'); - var context = canvas.getContext('2d'); - var video = document.getElementById('attendnaceVideo'); - $('.attendnaceSnap').click(function() { - context.drawImage(video, 0, 0, 208, 156); - that.photoTaken = true; - return false; - }); -}); - - - - - -function EmployeeAttendanceSheetAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeAttendanceSheetAdapter.inherits(AdapterBase); - -this.currentTimesheetId = null; -this.currentTimesheet = null; - -EmployeeAttendanceSheetAdapter.method('getDataMapping', function() { - return [ - "id", - "date_start", - "date_end", - "total_time", - "status" - ]; -}); - -EmployeeAttendanceSheetAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Start Date"}, - { "sTitle": "End Date"}, - { "sTitle": "Total Time"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeAttendanceSheetAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "date_start", {"label":"TimeSheet Start Date","type":"date","validation":""}], - [ "date_end", {"label":"TimeSheet End Date","type":"date","validation":""}], - [ "details", {"label":"Reason","type":"textarea","validation":"none"}] - ]; -}); - -EmployeeAttendanceSheetAdapter.method('preProcessTableData', function(row) { - row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); - row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); - return row; -}); - -EmployeeAttendanceSheetAdapter.method('renderForm', function(object) { - var formHtml = this.templates['formTemplate']; - var html = ""; - - $("#"+this.getTableName()+'Form').html(formHtml); - $("#"+this.getTableName()+'Form').show(); - $("#"+this.getTableName()).hide(); - - $('#attendnacesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); - $('#attendnacesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); - - this.currentTimesheet = object; - - this.getTimeEntries(); - -}); - - - -EmployeeAttendanceSheetAdapter.method('getTimeEntries', function() { - timesheetId = this.currentId; - var sourceMappingJson = JSON.stringify(modJsList['tabEmployeeTimeEntry'].getSourceMapping()); - object = {"id":timesheetId,"sm":sourceMappingJson}; - - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getTimeEntriesSuccessCallBack'; - callBackData['callBackFail'] = 'getTimeEntriesFailCallBack'; - - this.customAction('getTimeEntries','modules=time_sheets',reqJson,callBackData); -}); - -EmployeeAttendanceSheetAdapter.method('getTimeEntriesSuccessCallBack', function(callBackData) { - var entries = callBackData; - var html = ""; - var temp = '_start__end__duration__project__details_'; - - for(var i=0;i. - - ------------------------------------------------------------------ - - Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] - Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function DashboardAdapter(endPoint) { - this.initAdapter(endPoint); -} - -DashboardAdapter.inherits(AdapterBase); - - - -DashboardAdapter.method('getDataMapping', function() { - return []; -}); - -DashboardAdapter.method('getHeaders', function() { - return []; -}); - -DashboardAdapter.method('getFormFields', function() { - return []; -}); - - -DashboardAdapter.method('get', function(callBackData) { -}); - - -DashboardAdapter.method('getPunch', function() { - var that = this; - var object = {}; - - object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); - object['offset'] = this.getClientGMTOffset(); - var reqJson = JSON.stringify(object); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getPunchSuccessCallBack'; - callBackData['callBackFail'] = 'getPunchFailCallBack'; - - this.customAction('getPunch','modules=attendance',reqJson,callBackData); -}); - - - -DashboardAdapter.method('getPunchSuccessCallBack', function(callBackData) { - var punch = callBackData; - if(punch == null){ - $("#lastPunchTime").html("Not"); - $("#punchTimeText").html("Punched In"); - }else{ - $("#lastPunchTime").html(Date.parse(punch.in_time).toString('h:mm tt')); - $("#punchTimeText").html("Punched In"); - } -}); - -DashboardAdapter.method('getPunchFailCallBack', function(callBackData) { - -}); - -DashboardAdapter.method('getInitData', function() { - var that = this; - var object = {}; - var reqJson = JSON.stringify(object); - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getInitDataSuccessCallBack'; - callBackData['callBackFail'] = 'getInitDataFailCallBack'; - - this.customAction('getInitData','modules=dashboard',reqJson,callBackData); -}); - - - -DashboardAdapter.method('getInitDataSuccessCallBack', function(data) { - - $("#timeSheetHoursWorked").html(data['lastTimeSheetHours']); - $("#numberOfProjects").html(data['activeProjects']); - $("#pendingLeaveCount").html(data['pendingLeaves']); - - $("#numberOfEmployees").html(data['numberOfEmployees']+" Subordinates"); - $("#numberOfCandidates").html(data['numberOfCandidates']+" Candidates"); - $("#numberOfJobs").html(data['numberOfJobs']+" Active"); - $("#numberOfCourses").html(data['numberOfCourses']+" Active"); - -}); - -DashboardAdapter.method('getInitDataFailCallBack', function(callBackData) { - -}); - - -DashboardAdapter.method('getClientDate', function (date) { - - var offset = this.getClientGMTOffset(); - var tzDate = date.addMinutes(offset*60); - return tzDate; - -}); - -DashboardAdapter.method('getClientGMTOffset', function () { - - var rightNow = new Date(); - var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); - var temp = jan1.toGMTString(); - var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); - var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); - - return std_time_offset; - -}); diff --git a/web/modules/dependents/lib.js b/web/modules/dependents/lib.js deleted file mode 100644 index 937b600a..00000000 --- a/web/modules/dependents/lib.js +++ /dev/null @@ -1,64 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - - -/** - * EmployeeDependentAdapter - */ - -function EmployeeDependentAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeDependentAdapter.inherits(AdapterBase); - - - -EmployeeDependentAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "relationship", - "dob", - "id_number" - ]; -}); - -EmployeeDependentAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Relationship"}, - { "sTitle": "Date of Birth"}, - { "sTitle": "Id Number"} - ]; -}); - -EmployeeDependentAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "relationship", {"label":"Relationship","type":"select","source":[["Child","Child"],["Spouse","Spouse"],["Parent","Parent"],["Other","Other"]]}], - [ "dob", {"label":"Date of Birth","type":"date","validation":""}], - [ "id_number", {"label":"Id Number","type":"text","validation":"none"}] - ]; -}); diff --git a/web/modules/dist/attendance.js b/web/modules/dist/attendance.js new file mode 100644 index 00000000..4ecf3210 --- /dev/null +++ b/web/modules/dist/attendance.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(r,s){if(!a[r]){if(!t[r]){var o="function"==typeof require&&require;if(!s&&o)return o(r,!0);if(n)return n(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[r]={exports:{}};t[r][0].call(c.exports,function(e){return i(t[r][1][e]||e)},c,c.exports,e,t,a,l)}return a[r].exports}for(var n="function"==typeof require&&require,r=0;r0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},n=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),n=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(n,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===n||"checkbox"===n)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var r=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],n=this,r="";r=i?"#plainMessageModel":"#messageModel",$(r).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(r).modal({show:!0}),$(r).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(r).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var n=this,r="";r=i?"#dataMessageModel":"#messageModel",$(r).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(r).modal({show:!0}),$(r).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(r).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new r.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var n=$("#"+this.getTableName()+"_submit #id").val();null!=n&&void 0!==n&&""!==n&&(l.id=n),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new r.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,n=void 0,r=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(r="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?r=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=r=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])r=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),n=0;n')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(r=i[c])&&null!=r&&"string"==typeof r&&(r=r.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",r);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(n=$(l)).attr("fieldId",t[0]+"_div"),o.append(n)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var n=0;n');s.attr("id",r),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new r.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(n),n.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&n.sort(e[1]["sort-function"]),i=JSON.stringify(n);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,n=0;nt?(a+=l[n]+"
    ",i=0):a+=l[n]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),n)if(n[e].id===a){t.push(n[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new r.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var n=$("#"+e[0]).val();""===n&&(n="[]");for(var s=JSON.parse(n),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],n=0;n")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=o=(o=o.replace("_id_",r)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=o=(o=o.replace("_id_",r)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;lHH:mm"):2===a?"0000-00-00 00:00:00"===t||""===t||null==t?"":Date.parse(t).toString("MMM d HH:mm"):3===a&&null!=t&&t.length>20?t.substring(0,20)+"..":t}},{key:"getActionButtonsHtml",value:function(e,t){return""}},{key:"getTableTopButtonHtml",value:function(){return null===this.punch||void 0===this.punch?'':''}},{key:"save",value:function(){var e=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=this.doCustomValidation();if(null==t){var a=e.getFormParameters();(a=this.forceInjectValuesBeforeSave(a)).cdate=this.getClientDate(new Date).toISOString().slice(0,19).replace("T"," ");var l=JSON.stringify(a),i=[];i.callBackData=[],i.callBackSuccess="saveSuccessCallback",i.callBackFail="getPunchFailCallBack",this.customAction("savePunch","modules=attendance",l,i,!0)}else $("#"+this.getTableName()+"Form .label").html(t),$("#"+this.getTableName()+"Form .label").show()}}},{key:"saveSuccessCallback",value:function(e){this.punch=e,this.getPunch("changePunchButtonSuccessCallBack"),$("#PunchModel").modal("hide"),this.get([])}},{key:"cancel",value:function(){$("#PunchModel").modal("hide")}},{key:"showPunchDialog",value:function(){this.getPunch("showPunchDialogShowPunchSuccessCallBack")}},{key:"getPunch",value:function(e){var t={};t.date=this.getClientDate(new Date).toISOString().slice(0,19).replace("T"," "),t.offset=this.getClientGMTOffset();var a=JSON.stringify(t),l=[];l.callBackData=[],l.callBackSuccess=e,l.callBackFail="getPunchFailCallBack",this.customAction("getPunch","modules=attendance",a,l)}},{key:"showPunchDialogShowPunchSuccessCallBack",value:function(e){this.punch=e,$("#PunchModel").modal("show"),null===this.punch?($("#PunchModel").find("h3").html("Punch Time-in"),modJs.renderForm()):($("#PunchModel").find("h3").html("Punch Time-out"),modJs.renderForm(this.punch)),$("#Attendance").show(),$("#time_datetime").data("datetimepicker").setLocalDate(new Date)}},{key:"changePunchButtonSuccessCallBack",value:function(e){this.punch=e,null===this.punch?$("#punchButton").html('Punch-in '):$("#punchButton").html('Punch-out ')}},{key:"getPunchFailCallBack",value:function(e){this.showMessage("Error Occured while Time Punch",e)}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"doCustomValidation",value:function(e){return 1!==this.photoAttendance||this.photoTaken?null:"Please attach a photo before submitting"}},{key:"forceInjectValuesBeforeSave",value:function(e){if(1===this.photoAttendance){var t=document.getElementById("attendnaceCanvas");e.image=t.toDataURL()}return e}},{key:"postRenderForm",value:function(){if(1===this.photoAttendance){$(".photoAttendance").show();var e=document.getElementById("attendnaceVideo");navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:!0}).then(function(t){e.src=window.URL.createObjectURL(t),e.play()}),this.photoTaken=!1,this.configureEvents()}else $(".photoAttendance").remove()}},{key:"configureEvents",value:function(){var e=this,t=document.getElementById("attendnaceCanvas").getContext("2d"),a=document.getElementById("attendnaceVideo");$(".attendnaceSnap").click(function(){return t.drawImage(a,0,0,208,156),e.photoTaken=!0,!1})}}]),t}(),d=function(e){function t(e,a,l,i){s(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return n.currentTimesheetId=null,n.currentTimesheet=null,n}return u(t,i.default),l(t,[{key:"getDataMapping",value:function(){return["id","date_start","date_end","total_time","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Start Date"},{sTitle:"End Date"},{sTitle:"Total Time"},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["date_start",{label:"TimeSheet Start Date",type:"date",validation:""}],["date_end",{label:"TimeSheet End Date",type:"date",validation:""}],["details",{label:"Reason",type:"textarea",validation:"none"}]]}},{key:"preProcessTableData",value:function(e){return e[1]=Date.parse(e[1]).toString("MMM d, yyyy (dddd)"),e[2]=Date.parse(e[2]).toString("MMM d, yyyy (dddd)"),e}},{key:"renderForm",value:function(e){var t=this.templates.formTemplate;$("#"+this.getTableName()+"Form").html(t),$("#"+this.getTableName()+"Form").show(),$("#"+this.getTableName()).hide(),$("#attendnacesheet_start").html(Date.parse(e.date_start).toString("MMM d, yyyy (dddd)")),$("#attendnacesheet_end").html(Date.parse(e.date_end).toString("MMM d, yyyy (dddd)")),this.currentTimesheet=e,this.getTimeEntries()}},{key:"getTimeEntries",value:function(){var e=this.currentId,t=JSON.stringify(modJsList.tabEmployeeTimeEntry.getSourceMapping()),a=JSON.stringify({id:e,sm:t}),l=[];l.callBackData=[],l.callBackSuccess="getTimeEntriesSuccessCallBack",l.callBackFail="getTimeEntriesFailCallBack",this.customAction("getTimeEntries","modules=time_sheets",a,l)}},{key:"getTimeEntriesSuccessCallBack",value:function(e){for(var t=e,a="",l=0;l_start__end__duration__project__details_';i=(i=i.replace(/_start_/g,Date.parse(t[l].date_start).toString("MMM d, yyyy [hh:mm tt]"))).replace(/_end_/g,Date.parse(t[l].date_end).toString("MMM d, yyyy [hh:mm tt]"));var n=Date.parse(t[l].date_end)-Date.parse(t[l].date_start),r=Math.round(n/6e4),s=r%60,o=(r-s)/60;i=i.replace(/_duration_/g,"Hours ("+o+") - Min ("+s+")"),a+=i=(i=(i=(i=(i="null"===t[l].project||null===t[l].project||void 0===t[l].project?i.replace(/_project_/g,"None"):i.replace(/_project_/g,t[l].project)).replace(/_project_/g,t[l].project)).replace(/_details_/g,t[l].details)).replace(/_id_/g,t[l].id)).replace(/_BASE_/g,this.baseUrl)}catch(e){}$(".timesheet_entries_table_body").html(a),"SubEmployeeTimeSheetAll"===modJs.getTableName()?($("#submit_sheet").hide(),$("#add_time_sheet_entry").hide()):"Approved"===this.currentElement.status?($("#submit_sheet").hide(),$("#add_time_sheet_entry").hide()):($("#submit_sheet").show(),$("#add_time_sheet_entry").show())}},{key:"getTimeEntriesFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting timesheet entries")}},{key:"createPreviousAttendnacesheet",value:function(e){var t=JSON.stringify({id:e}),a=[];a.callBackData=[],a.callBackSuccess="createPreviousAttendnacesheetSuccessCallBack",a.callBackFail="createPreviousAttendnacesheetFailCallBack",this.customAction("createPreviousAttendnaceSheet","modules=attendnace",t,a)}},{key:"createPreviousAttendnacesheetSuccessCallBack",value:function(e){$(".tooltip").css("display","none"),$(".tooltip").remove(),this.get([])}},{key:"createPreviousAttendnacesheetFailCallBack",value:function(e){this.showMessage("Error",e)}},{key:"getActionButtonsHtml",value:function(e,t){return("EmployeeTimeSheetAll"===this.getTableName()?'
    ':'
    ').replace(/_id_/g,e).replace(/_BASE_/g,this.baseUrl)}},{key:"getCustomTableParams",value:function(){var e=this;return{aoColumnDefs:[{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,1)},aTargets:[1]},{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,2)},aTargets:[2]},{fnRender:e.getActionButtons,aTargets:[e.getDataMapping().length]}]}}},{key:"preProcessRemoteTableData",value:function(e,t,a){return Date.parse(t).toString("MMM d, yyyy (dddd)")}}]),t}();t.exports={AttendanceAdapter:c,EmployeeAttendanceSheetAdapter:d}},{"../../../api/AdapterBase":2,"../../../api/FormValidation":3}]},{},[5]); +//# sourceMappingURL=attendance.js.map diff --git a/web/modules/dist/dashboard.js b/web/modules/dist/dashboard.js new file mode 100644 index 00000000..afd051ae --- /dev/null +++ b/web/modules/dist/dashboard.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;ld)&&(n[s]=d,h.push(s,d),i[s]=o));if(void 0!==a&&void 0===n[a]){var p=["Could not find a path from ",t," to ",a,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var a=[],r=t;r;)a.push(r),e[r],r=e[r];return a.reverse(),a},find_path:function(e,t,a){var i=r.single_source_shortest_paths(e,t,a);return r.extract_shortest_path_from_predecessor_list(i,a)},PriorityQueue:{make:function(e){var t,a=r.PriorityQueue,i={};for(t in e=e||{},a)a.hasOwnProperty(t)&&(i[t]=a[t]);return i.queue=[],i.sorter=e.sorter||a.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var a={value:e,cost:t};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==t&&(t.exports=r)},{}],2:[function(e,t,a){var r=e("./can-promise"),i=e("./core/qrcode"),n=e("./renderer/canvas"),l=e("./renderer/svg-tag.js");function o(e,t,a,n,l){var o=[].slice.call(arguments,1),s=o.length,u="function"==typeof o[s-1];if(!u&&!r())throw new Error("Callback required as last argument");if(!u){if(s<1)throw new Error("Too few arguments provided");return 1===s?(a=t,t=n=void 0):2!==s||t.getContext||(n=a,a=t,t=void 0),new Promise(function(r,l){try{var o=i.create(a,n);r(e(o,t,n))}catch(e){l(e)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(l=a,a=t,t=n=void 0):3===s&&(t.getContext&&void 0===l?(l=n,n=void 0):(l=n,n=a,a=t,t=void 0));try{var c=i.create(a,n);l(null,e(c,t,n))}catch(e){l(e)}}a.create=i.create,a.toCanvas=o.bind(null,n.render),a.toDataURL=o.bind(null,n.renderToDataURL),a.toString=o.bind(null,function(e,t,a){return l.render(e,a)})},{"./can-promise":3,"./core/qrcode":19,"./renderer/canvas":26,"./renderer/svg-tag.js":27}],3:[function(e,t,a){t.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},{}],4:[function(e,t,a){var r=e("./utils").getSymbolSize;a.getRowColCoords=function(e){if(1===e)return[];for(var t=Math.floor(e/7)+2,a=r(e),i=145===a?26:2*Math.ceil((a-13)/(2*t-2)),n=[a-7],l=1;l>>7-e%8&1)},put:function(e,t){for(var a=0;a>>t-a-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=r},{}],7:[function(e,t,a){var r=e("../utils/buffer");function i(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new r(e*e),this.data.fill(0),this.reservedBit=new r(e*e),this.reservedBit.fill(0)}i.prototype.set=function(e,t,a,r){var i=e*this.size+t;this.data[i]=a,r&&(this.reservedBit[i]=!0)},i.prototype.get=function(e,t){return this.data[e*this.size+t]},i.prototype.xor=function(e,t,a){this.data[e*this.size+t]^=a},i.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=i},{"../utils/buffer":29}],8:[function(e,t,a){var r=e("../utils/buffer"),i=e("./mode");function n(e){this.mode=i.BYTE,this.data=new r(e)}n.getBitsLength=function(e){return 8*e},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(e){for(var t=0,a=this.data.length;t=0&&e.bit<4},a.from=function(e,t){if(a.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return a.L;case"m":case"medium":return a.M;case"q":case"quartile":return a.Q;case"h":case"high":return a.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}}},{}],11:[function(e,t,a){var r=e("./utils").getSymbolSize;a.getPositions=function(e){var t=r(e);return[[0,0],[t-7,0],[0,t-7]]}},{"./utils":23}],12:[function(e,t,a){var r=e("./utils"),i=r.getBCHDigit(1335);a.getEncodedBits=function(e,t){for(var a=e.bit<<3|t,n=a<<10;r.getBCHDigit(n)-i>=0;)n^=1335<=33088&&a<=40956)a-=33088;else{if(!(a>=57408&&a<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");a-=49472}a=192*(a>>>8&255)+(255&a),e.put(a,13)}},t.exports=n},{"./mode":16,"./utils":23}],15:[function(e,t,a){a.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var r=3,i=3,n=40,l=10;function o(e,t,r){switch(e){case a.Patterns.PATTERN000:return(t+r)%2==0;case a.Patterns.PATTERN001:return t%2==0;case a.Patterns.PATTERN010:return r%3==0;case a.Patterns.PATTERN011:return(t+r)%3==0;case a.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case a.Patterns.PATTERN101:return t*r%2+t*r%3==0;case a.Patterns.PATTERN110:return(t*r%2+t*r%3)%2==0;case a.Patterns.PATTERN111:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}a.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},a.from=function(e){return a.isValid(e)?parseInt(e,10):void 0},a.getPenaltyN1=function(e){for(var t=e.size,a=0,i=0,n=0,l=null,o=null,s=0;s=5&&(a+=r+(i-5)),l=c,i=1),(c=e.get(u,s))===o?n++:(n>=5&&(a+=r+(n-5)),o=c,n=1)}i>=5&&(a+=r+(i-5)),n>=5&&(a+=r+(n-5))}return a},a.getPenaltyN2=function(e){for(var t=e.size,a=0,r=0;r=10&&(1488===r||93===r)&&a++,i=i<<1&2047|e.get(o,l),o>=10&&(1488===i||93===i)&&a++}return a*n},a.getPenaltyN4=function(e){for(var t=0,a=e.data.length,r=0;r=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]},a.getBestModeForData=function(e){return i.testNumeric(e)?a.NUMERIC:i.testAlphanumeric(e)?a.ALPHANUMERIC:i.testKanji(e)?a.KANJI:a.BYTE},a.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},a.isValid=function(e){return e&&e.bit&&e.ccBits},a.from=function(e,t){if(a.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return a.NUMERIC;case"alphanumeric":return a.ALPHANUMERIC;case"kanji":return a.KANJI;case"byte":return a.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch(e){return t}}},{"./regex":21,"./version-check":24}],17:[function(e,t,a){var r=e("./mode");function i(e){this.mode=r.NUMERIC,this.data=e.toString()}i.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var t,a,r;for(t=0;t+3<=this.data.length;t+=3)a=this.data.substr(t,3),r=parseInt(a,10),e.put(r,10);var i=this.data.length-t;i>0&&(a=this.data.substr(t),r=parseInt(a,10),e.put(r,3*i+1))},t.exports=i},{"./mode":16}],18:[function(e,t,a){var r=e("../utils/buffer"),i=e("./galois-field");a.mul=function(e,t){var a=new r(e.length+t.length-1);a.fill(0);for(var n=0;n=0;){for(var n=a[0],l=0;l>r&1),r<6?e.set(r,8,i,!0):r<8?e.set(r+1,8,i,!0):e.set(n-15+r,8,i,!0),r<8?e.set(8,n-r-1,i,!0):r<9?e.set(8,15-r-1+1,i,!0):e.set(8,15-r-1,i,!0);e.set(n-8,8,1,!0)}function b(e,t,a){var n=new l;a.forEach(function(t){n.put(t.mode.bit,4),n.put(t.getLength(),m.getCharCountIndicator(t.mode,e)),t.write(n)});var o=8*(i.getSymbolTotalCodewords(e)-d.getTotalCodewordsCount(e,t));for(n.getLengthInBits()+4<=o&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(0);for(var s=(o-n.getLengthInBits())/8,u=0;u=0&&o<=6&&(0===s||6===s)||s>=0&&s<=6&&(0===o||6===o)||o>=2&&o<=4&&s>=2&&s<=4?e.set(n+o,l+s,!0,!0):e.set(n+o,l+s,!1,!0))}(_,t),function(e){for(var t=e.size,a=8;a=7&&function(e,t){for(var a,r,i,n=e.size,l=h.getEncodedBits(t),o=0;o<18;o++)a=Math.floor(o/3),r=o%3+n-8-3,i=1==(l>>o&1),e.set(a,r,i,!0),e.set(r,a,i,!0)}(_,t),function(e,t){for(var a=e.size,r=-1,i=a-1,n=7,l=0,o=a-1;o>0;o-=2)for(6===o&&o--;;){for(var s=0;s<2;s++)if(!e.isReserved(i,o-s)){var u=!1;l>>n&1)),e.set(i,o-s,u),-1==--n&&(l++,n=7)}if((i+=r)<0||a<=i){i-=r,r=-r;break}}}(_,p),isNaN(r)&&(r=c.getBestMask(_,y.bind(null,_,a))),c.applyMask(r,_),y(_,a,r),{modules:_,version:t,errorCorrectionLevel:a,maskPattern:r,segments:n}}a.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");var a,r,l=n.M;return void 0!==t&&(l=n.from(t.errorCorrectionLevel,n.M),a=h.from(t.version),r=c.from(t.maskPattern),t.toSJISFunc&&i.setToSJISFunction(t.toSJISFunc)),_(e,a,l,r)}},{"../utils/buffer":29,"./alignment-pattern":4,"./bit-buffer":6,"./bit-matrix":7,"./error-correction-code":9,"./error-correction-level":10,"./finder-pattern":11,"./format-info":12,"./mask-pattern":15,"./mode":16,"./reed-solomon-encoder":20,"./segments":22,"./utils":23,"./version":25,isarray:30}],20:[function(e,t,a){var r=e("../utils/buffer"),i=e("./polynomial");function n(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}n.prototype.initialize=function(e){this.degree=e,this.genPoly=i.generateECPolynomial(this.degree)},n.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");var t=new r(this.degree);t.fill(0);var a=r.concat([e,t],e.length+this.degree),n=i.mod(a,this.genPoly),l=this.degree-n.length;if(l>0){var o=new r(this.degree);return o.fill(0),n.copy(o,l),o}return n},t.exports=n},{"../utils/buffer":29,"./polynomial":18}],21:[function(e,t,a){var r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",i="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";a.KANJI=new RegExp(r,"g"),a.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),a.BYTE=new RegExp(i,"g"),a.NUMERIC=new RegExp("[0-9]+","g"),a.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+r+"$"),l=new RegExp("^[0-9]+$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");a.testKanji=function(e){return n.test(e)},a.testNumeric=function(e){return l.test(e)},a.testAlphanumeric=function(e){return o.test(e)}},{}],22:[function(e,t,a){var r=e("./mode"),i=e("./numeric-data"),n=e("./alphanumeric-data"),l=e("./byte-data"),o=e("./kanji-data"),s=e("./regex"),u=e("./utils"),c=e("dijkstrajs");function d(e){return unescape(encodeURIComponent(e)).length}function f(e,t,a){for(var r,i=[];null!==(r=e.exec(a));)i.push({data:r[0],index:r.index,mode:t,length:r[0].length});return i}function h(e){var t,a,i=f(s.NUMERIC,r.NUMERIC,e),n=f(s.ALPHANUMERIC,r.ALPHANUMERIC,e);return u.isKanjiModeEnabled()?(t=f(s.BYTE,r.BYTE,e),a=f(s.KANJI,r.KANJI,e)):(t=f(s.BYTE_KANJI,r.BYTE,e),a=[]),i.concat(n,t,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function p(e,t){switch(t){case r.NUMERIC:return i.getBitsLength(e);case r.ALPHANUMERIC:return n.getBitsLength(e);case r.KANJI:return o.getBitsLength(e);case r.BYTE:return l.getBitsLength(e)}}function m(e,t){var a,s=r.getBestModeForData(e);if((a=r.from(t,s))!==r.BYTE&&a.bit=0?e[e.length-1]:null;return a&&a.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(l))},a.rawSplit=function(e){return a.fromArray(h(e,u.isKanjiModeEnabled()))}},{"./alphanumeric-data":5,"./byte-data":8,"./kanji-data":14,"./mode":16,"./numeric-data":17,"./regex":21,"./utils":23,dijkstrajs:1}],23:[function(e,t,a){var r,i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];a.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},a.getSymbolTotalCodewords=function(e){return i[e]},a.getBCHDigit=function(e){for(var t=0;0!==e;)t++,e>>>=1;return t},a.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');r=e},a.isKanjiModeEnabled=function(){return void 0!==r},a.toSJIS=function(e){return r(e)}},{}],24:[function(e,t,a){a.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}},{}],25:[function(e,t,a){var r=e("./utils"),i=e("./error-correction-code"),n=e("./error-correction-level"),l=e("./mode"),o=e("./version-check"),s=e("isarray"),u=r.getBCHDigit(7973);function c(e,t){return l.getCharCountIndicator(e,t)+4}function d(e,t){var a=0;return e.forEach(function(e){var r=c(e.mode,t);a+=r+e.getBitsLength()}),a}a.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},a.getCapacity=function(e,t,a){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===a&&(a=l.BYTE);var n=8*(r.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,t));if(a===l.MIXED)return n;var s=n-c(a,e);switch(a){case l.NUMERIC:return Math.floor(s/10*3);case l.ALPHANUMERIC:return Math.floor(s/11*2);case l.KANJI:return Math.floor(s/13);case l.BYTE:default:return Math.floor(s/8)}},a.getBestVersionForData=function(e,t){var r,i=n.from(t,n.M);if(s(e)){if(e.length>1)return function(e,t){for(var r=1;r<=40;r++)if(d(e,r)<=a.getCapacity(r,t,l.MIXED))return r}(e,i);if(0===e.length)return 1;r=e[0]}else r=e;return function(e,t,r){for(var i=1;i<=40;i++)if(t<=a.getCapacity(i,r,e))return i}(r.mode,r.getLength(),i)},a.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");for(var t=e<<12;r.getBCHDigit(t)-u>=0;)t^=7973<':"",d="0&&u>0&&e[s-1]||(r+=l?n("M",u+a,.5+c+a):n("m",i,0),i=0,l=!1),u+1',f='viewBox="0 0 '+u+" "+u+'"',h=''+c+d+"\n";return"function"==typeof a&&a(null,h),h}},{"./utils":28}],28:[function(e,t,a){function r(e){if("string"!=typeof e)throw new Error("Color should be defined as hex string");var t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");var a=parseInt(t.join(""),16);return{r:a>>24&255,g:a>>16&255,b:a>>8&255,a:255&a,hex:"#"+t.slice(0,6).join("")}}a.getOptions=function(e){e||(e={}),e.color||(e.color={});var t=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,a=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:a,scale:a?4:i,margin:t,color:{dark:r(e.color.dark||"#000000ff"),light:r(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},a.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},a.getImageWidth=function(e,t){var r=a.getScale(e,t);return Math.floor((e+2*t.margin)*r)},a.qrToImageData=function(e,t,r){for(var i=t.modules.size,n=t.modules.data,l=a.getScale(i,r),o=Math.floor((i+2*r.margin)*l),s=r.margin*l,u=[r.color.light,r.color.dark],c=0;c=s&&d>=s&&c=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|e}function o(e,t){var a;return n.TYPED_ARRAY_SUPPORT?(a=new Uint8Array(t)).__proto__=n.prototype:(null===(a=e)&&(a=new n(t)),a.length=t),a}function s(e,t){var a=o(e,t<0?0:0|l(t));if(!n.TYPED_ARRAY_SUPPORT)for(var r=0;r55295&&a<57344){if(!i){if(a>56319){(t-=3)>-1&&n.push(239,191,189);continue}if(l+1===r){(t-=3)>-1&&n.push(239,191,189);continue}i=a;continue}if(a<56320){(t-=3)>-1&&n.push(239,191,189),i=a;continue}a=65536+(i-55296<<10|a-56320)}else i&&(t-=3)>-1&&n.push(239,191,189);if(i=null,a<128){if((t-=1)<0)break;n.push(a)}else if(a<2048){if((t-=2)<0)break;n.push(a>>6|192,63&a|128)}else if(a<65536){if((t-=3)<0)break;n.push(a>>12|224,a>>6&63|128,63&a|128)}else{if(!(a<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;n.push(a>>18|240,a>>12&63|128,a>>6&63|128,63&a|128)}}return n}function d(e){return n.isBuffer(e)?e.length:"undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)?e.byteLength:("string"!=typeof e&&(e=""+e),0===e.length?0:c(e).length)}n.TYPED_ARRAY_SUPPORT&&(n.prototype.__proto__=Uint8Array.prototype,n.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&n[Symbol.species]===n&&Object.defineProperty(n,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1})),n.prototype.write=function(e,t,a){void 0===t?(a=this.length,t=0):void 0===a&&"string"==typeof t?(a=this.length,t=0):isFinite(t)&&(t|=0,isFinite(a)?a|=0:a=void 0);var r=this.length-t;if((void 0===a||a>r)&&(a=r),e.length>0&&(a<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");return function(e,t,a,r){return function(e,t,a,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+a]=e[i];return i}(c(t,e.length-a),e,a,r)}(this,e,t,a)},n.prototype.slice=function(e,t){var a,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+a];else if(l<1e3||!n.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,a=void 0===a?this.length:a>>>0,e||(e=0),"number"==typeof e)for(i=t;i0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],32:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var r=function(){function e(e,t){for(var a=0;a0}},n=function(){function e(t,a,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,r),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return r(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),r=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===r||null==r||""===r?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===r||"number"===r?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===r?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,r=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+r+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),n=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(n,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===n||"checkbox"===n)a=$("input[name='"+r+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var l=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var r=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],n=this,l="";l=i?"#plainMessageModel":"#messageModel",$(l).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(l).modal({show:!0}),$(l).on("hidden.bs.modal",function(){a.apply(n,r),$(".modal-backdrop").remove()})):$(l).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,r,i){var n=this,l="";l=i?"#dataMessageModel":"#messageModel",$(l).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(l).modal({show:!0}),$(l).on("hidden.bs.modal",function(){a.apply(n,r),$(".modal-backdrop").remove()})):$(l).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new l.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var r=a.getFormParameters();r=this.forceInjectValuesBeforeSave(r);var i=this.doCustomValidation(r);if(null==i){this.csrfRequired&&(r.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var n=$("#"+this.getTableName()+"_submit #id").val();null!=n&&void 0!==n&&""!==n&&(r.id=n),r=this.makeEmptyDateFieldsNull(r),this.add(r,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new l.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,r=void 0,i=void 0,n=void 0,l=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(l="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?l=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=l=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(r=i.source[0],"NULL"===e[u])l=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,r="",i=this.getFormFields(),n=0;n')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(l=i[c])&&null!=l&&"string"==typeof l&&(l=l.replace(/(?:\r\n|\r|\n)/g,"
    ")),r=r.replace("#_"+c+"_#",l);void 0!==t[1].render&&null!=t[1].render&&(r=r.replace("#_renderFunction_#",t[1].render(i))),(n=$(r)).attr("fieldId",t[0]+"_div"),s.append(n)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,r="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var n=0;n');o.attr("id",l),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new l.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var r=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[r])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;r=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);r.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(n),n.push(r),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&n.sort(e[1]["sort-function"]),i=JSON.stringify(n);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var r=e.split(" "),i=0,n=0;nt?(a+=r[n]+"
    ",i=0):a+=r[n]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var r=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:r+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,r=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);r.each(function(){for(var e in a=$(this).attr("id"),n)if(n[e].id===a){t.push(n[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new l.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var r=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[r]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;r=i.params}if(this.doCustomFilterValidation(r)){var n=$("#"+e[0]).val();""===n&&(n="[]");for(var o=JSON.parse(n),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),r=JSON.parse(a),i=[],n=0;n")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{r=a[i][1].formatter(r)}catch(e){}$(t+" #"+a[i][0]).html(r)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var r=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[r],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var r=[];for(var i in e)r.push(e[i]);!0===t[1].sort&&r.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",l)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var r=[];for(var i in e)r.push([i,e[i]]);"true"===t[1].sort&&r.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",l)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="",i=e;i>0;--i)r+=a[Math.round(Math.random()*(a.length-1))];return r+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),r="";return a.value.lastIndexOf(".")>0&&(r=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),r=r.toLowerCase(),!(t.split(",").indexOf(r)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,r=0;r";if(void 0!==e.customFields&&null!==e.customFields&&Object.keys(e.customFields).length>0){var d=void 0;for(var f in e.customFields){e.customFields[f][1]||(e.customFields[f][1]=this.gt("Other Details"));var h=e.customFields[f][1].toLocaleLowerCase();if(h=h.replace(" ","_"),$("#cont_"+h).length<=0){var p='

    #_section.name_#

    ';p=(p=p.replace("#_section_#",h)).replace("#_section.name_#",e.customFields[f][1]),$("#customFieldsCont").append($(p))}d=(d='
    ').replace("#_label_#",f),d="fileupload"===e.customFields[f][2]?d.replace("#_value_#",""):d.replace("#_value_#",e.customFields[f][0]),$("#cont_"+h).append($(d))}}else $("#customFieldsCont").remove();$("#"+this.getTableName()+" #subordinates").html(u),$("#"+this.getTableName()+" #name").html(e.first_name+" "+e.last_name),this.currentUserId=e.id,$("#"+this.getTableName()+" #profile_image_"+e.id).attr("src",e.image),"No"===this.checkPermission("Upload/Delete Profile Image")&&($("#employeeUploadProfileImage").remove(),$("#employeeDeleteProfileImage").remove()),"No"===this.checkPermission("Edit Employee Details")&&$("#employeeProfileEditInfo").remove(),a!==i&&$("#employeeUpdatePassword").remove(),this.cancel()}},{key:"modEmployeeGetFailCallBack",value:function(e){}},{key:"editEmployee",value:function(){this.edit(this.currentUserId)}},{key:"changePassword",value:function(){$("#adminUsersModel").modal("show"),$("#adminUsersChangePwd #newpwd").val(""),$("#adminUsersChangePwd #conpwd").val("")}},{key:"changePasswordConfirm",value:function(){$("#adminUsersChangePwd_error").hide();var e=$("#adminUsersChangePwd #newpwd").val();if(!(e.length>7))return $("#adminUsersChangePwd_error").html("Password should be longer than 7 characters"),void $("#adminUsersChangePwd_error").show();var t=$("#adminUsersChangePwd #conpwd").val();if(t!==e)return $("#adminUsersChangePwd_error").html("Passwords don't match"),void $("#adminUsersChangePwd_error").show();var a={pwd:t},r=JSON.stringify(a),i=[];i.callBackData=[],i.callBackSuccess="changePasswordSuccessCallBack",i.callBackFail="changePasswordFailCallBack",this.customAction("changePassword","modules=employees",r,i)}},{key:"closeChangePassword",value:function(){$("#adminUsersModel").modal("hide")}},{key:"changePasswordSuccessCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Password Change","Password changed successfully")}},{key:"changePasswordFailCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Error",e)}}]),t}(),f=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,l.default),i(t,[{key:"getDataMapping",value:function(){return["id","title","address","type","country","parent"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Address"},{sTitle:"Type"},{sTitle:"Country",sClass:"center"},{sTitle:"Parent Structure"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden",validation:""}],["title",{label:"Name",type:"text",validation:""}],["description",{label:"Details",type:"textarea",validation:""}],["address",{label:"Address",type:"textarea",validation:"none"}],["type",{label:"Type",type:"select",source:[["Company","Company"],["Head Office","Head Office"],["Regional Office","Regional Office"],["Department","Department"],["Unit","Unit"],["Sub Unit","Sub Unit"],["Other","Other"]]}],["country",{label:"Country",type:"select","remote-source":["Country","code","name"]}],["parent",{label:"Parent Structure",type:"select","allow-null":!0,"remote-source":["CompanyStructure","id","title"]}]]}}]),t}(),h=function(e){function t(e,a,r,i){s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,r,i));return n.nodeIdCounter=0,n}return c(t,f),i(t,[{key:"convertToTree",value:function(e){for(var t={id:-1,title:"",name:"",children:[]},a=null,r=0;r",r.parent=null;break}n[l.id]=1,i=l}}return""===t||(this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:
    "+t),!1)}}]),t}(),p=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,l.default),i(t,[{key:"getDataMapping",value:function(){return[]}},{key:"getHeaders",value:function(){return[]}},{key:"getFormFields",value:function(){return[]}},{key:"setApiUrl",value:function(e){this.apiUrl=e}},{key:"setToken",value:function(e){this.token=e}},{key:"get",value:function(){var e=document.getElementById("apiQRcode");n.default.toCanvas(e,JSON.stringify({key:"IceHrm",url:this.apiUrl,token:this.token}),function(e){e&&console.log(e)})}}]),t}();t.exports={EmployeeAdapter:d,CompanyGraphAdapter:h,ApiAccessAdapter:p}},{"../../../api/AdapterBase":32,qrcode:2}]},{},[35]); +//# sourceMappingURL=employees.js.map diff --git a/web/modules/dist/loans.js b/web/modules/dist/loans.js new file mode 100644 index 00000000..2aac03a7 --- /dev/null +++ b/web/modules/dist/loans.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}}]),t}();t.exports={EmployeeCompanyLoanAdapter:s}},{"../../../api/AdapterBase":2}]},{},[5]); +//# sourceMappingURL=loans.js.map diff --git a/web/modules/dist/overtime.js b/web/modules/dist/overtime.js new file mode 100644 index 00000000..f28f2b24 --- /dev/null +++ b/web/modules/dist/overtime.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,o){if(!a[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=o},{"./LogViewAdapter":7}],5:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a',l='
    _edit__logs__delete_
    ';return l=l.replace("_logs_",''),l=this.showDelete?"Approved"===t[7]?l.replace("_delete_",a):"Pending"===t[7]||"Admin"===this.user.user_level?l.replace("_delete_",''):l.replace("_delete_",""):l.replace("_delete_",""),l=(l=(l=this.showEdit?l.replace("_edit_",''):l.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}}]),t}();a.default=o},{"./LogViewAdapter":7}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=o},{"./AdapterBase":3}],8:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'),a=(a=(a=(a="Processing"===t[this.getStatusFieldPosition()]?a.replace("_status_",''):a.replace("_status_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"getStatusOptionsData",value:function(e){var t={};return"Processing"===e&&(t.Approved="Approved",t.Rejected="Rejected"),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}(),f=function(e){function t(e,a,l,i){s(this,t);var r=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return r.itemName="Overtime",r.itemNameLower="employeeovertime",r.modulePathName="overtime",r}return c(t,o.EmployeeOvertimeAdminAdapter),t}();t.exports={EmployeeOvertimeAdapter:d,EmployeeOvertimeApproverAdapter:h,SubordinateEmployeeOvertimeAdapter:f}},{"../../../admin/src/overtime/lib":1,"../../../api/ApproveModuleAdapter":5}]},{},[9]); +//# sourceMappingURL=overtime.js.map diff --git a/web/modules/dist/projects.js b/web/modules/dist/projects.js new file mode 100644 index 00000000..52ad1398 --- /dev/null +++ b/web/modules/dist/projects.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;dDownload Report ':'Download Report ').replace(/_BASE_/g,this.baseUrl),"PDF"===this.currentReport.output||"JSON"===this.currentReport.output)this.showMessage("Download Report",l);else{if(0===t[1].length)return void this.showMessage("Empty Report","There were no data for selected filters");var i=l+'

    ';$("#tempReportTable").remove(),$("#"+this.table).html(i),$("#"+this.table).show(),$("#"+this.table+"Form").hide();var r=[];for(var n in t[1])r.push({sTitle:t[1][n]});var s={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t[2],aoColumns:r,bSort:!1,iDisplayLength:15,iDisplayStart:0};$("#tempReportTable").dataTable(s),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$(".tableActionButton").tooltip()}}},{key:"fillForm",value:function(e){for(var t=this.getFormFields(),a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'):($("#"+this.getTableName()+"_resetFilters").html("Reset Filters"),$("#"+this.getTableName()+"_resetFilters").hide())),$("#"+this.getTableName()).find(".search-controls").show(),t.length>this.pageSize?(this.hasMoreData=!0,t.pop(),this.loadMoreButton.removeAttr("disabled"),this.loadMoreButton.show()):(this.hasMoreData=!1,this.loadMoreButton.hide()),this.scrollToElementBottom(this.container);for(var l=0;l'.replace("_img_",t)}}}]),t}(),d=function(e){function t(){return o(this,t),s(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,r.default),l(t,[{key:"getDataMapping",value:function(){return["id","image","first_name","last_name","job_title","department","work_phone","work_email","joined_date"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:""},{sTitle:"First Name"},{sTitle:"Last Name"},{sTitle:"Job Title"},{sTitle:"Department"},{sTitle:"Work Phone"},{sTitle:"Work Email"},{sTitle:"Joined Date"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden",validation:""}],["first_name",{label:"First Name",type:"text",validation:""}],["last_name",{label:"Last Name",type:"text",validation:""}],["job_title",{label:"Job Title",type:"select2","remote-source":["JobTitle","id","name"]}],["department",{label:"Department",type:"select2","remote-source":["CompanyStructure","id","title"]}],["work_phone",{label:"Work Phone",type:"text",validation:"none"}],["work_email",{label:"Work Email",type:"placeholder",validation:"emailOrEmpty"}],["joined_date",{label:"Joined Date",type:"date",validation:""}]]}},{key:"addDomEvents",value:function(e){}},{key:"getTemplateName",value:function(){return"element.html"}},{key:"preProcessTableData",value:function(e){var t=e;return t.color=this.getColorByRandomString(t.first_name),t}},{key:"getFilters",value:function(){return[["job_title",{label:"Job Title",type:"select2","allow-null":!0,"null-label":"All Job Titles","remote-source":["JobTitle","id","name"]}],["department",{label:"Department",type:"select2","allow-null":!0,"null-label":"All Departments","remote-source":["CompanyStructure","id","title"]}]]}}]),t}();t.exports={StaffDirectoryAdapter:c,StaffDirectoryObjectAdapter:d}},{"../../../api/AdapterBase":2,"../../../api/ObjectAdapter":5}]},{},[6]); +//# sourceMappingURL=staffdirectory.js.map diff --git a/web/modules/dist/time_sheets.js b/web/modules/dist/time_sheets.js new file mode 100644 index 00000000..890a798a --- /dev/null +++ b/web/modules/dist/time_sheets.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(s,n){if(!a[s]){if(!t[s]){var o="function"==typeof require&&require;if(!n&&o)return o(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var d=a[s]={exports:{}};t[s][0].call(d.exports,function(e){return i(t[s][1][e]||e)},d,d.exports,e,t,a,l)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var s=$("#"+t.formId+" #"+i).select2("data");a=[];for(var n=0;n'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,s="";s=i?"#plainMessageModel":"#messageModel",$(s).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,s="";s=i?"#dataMessageModel":"#messageModel",$(s).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new s.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new s.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,s=void 0,n=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(s="",n=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":n=s=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');o.attr("id",n),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(s=i[d])&&null!=s&&"string"==typeof s&&(s=s.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",s);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');n.attr("id",s),n.html(a),n.find(".datefield").datepicker({viewMode:2}),n.find(".timefield").datetimepicker({language:"en",pickDate:!1}),n.find(".datetimefield").datetimepicker({language:"en"}),n.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+n.attr("id")+" .tinymce",height:"400"}),n.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),n.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),n.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,n,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var n=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(n),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var n=JSON.parse(r),o={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    ';var r=$("#"+e+" .dataTables_paginate .active a").html(),s=0;void 0!==r&&null!=r&&(s=15*parseInt(r,10)-15),$("#"+e).html(i);var n={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t,aoColumns:a,bSort:!1,iDisplayLength:15,iDisplayStart:s},o=this.getCustomTableParams();$.extend(n,o),$("#"+e+" #grid").dataTable(n),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$("#"+e+" #grid").editableTableWidget(),$("#"+e+" #grid .editcell").on("validate",function(e,t){return modJs.validateCellValue($(this),e,t)}),this.afterCreateTable(e)}},{key:"afterCreateTable",value:function(e){}},{key:"addCellDataUpdate",value:function(e,t,a){this.cellDataUpdates[e+"="+t]=[e,t,a]}},{key:"addAdditionalRequestData",value:function(e,t){return t}},{key:"sendCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataSuccessCallBack",a.callBackFail="updateDataFailCallBack",this.showLoader(),this.customAction("updateData",this.modulePath,t,a)}},{key:"updateDataSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.get()}},{key:"updateDataFailCallBack",value:function(e,t){this.hideLoader()}},{key:"sendAllCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateAllData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataAllSuccessCallBack",a.callBackFail="updateDataAllFailCallBack",this.showLoader(),this.customAction("updateAllData",this.modulePath,t,a)}},{key:"updateDataAllSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.getAllData(!0)}},{key:"updateDataAllFailCallBack",value:function(e,t){this.hideLoader()}},{key:"showActionButtons",value:function(){return!1}}]),t}();a.default=n},{"./AdapterBase":2}],6:[function(e,t,a){"use strict";var l=e("./lib");window.EmployeeTimeSheetAdapter=l.EmployeeTimeSheetAdapter,window.SubEmployeeTimeSheetAdapter=l.SubEmployeeTimeSheetAdapter,window.EmployeeTimeEntryAdapter=l.EmployeeTimeEntryAdapter,window.QtsheetAdapter=l.QtsheetAdapter},{"./lib":7}],7:[function(e,t,a){"use strict";var l=function(){function e(e,t){for(var a=0;a_start__end__duration__project__details_';i=(i=i.replace(/_start_/g,Date.parse(t[l].date_start).toString("MMM d, yyyy [hh:mm tt]"))).replace(/_end_/g,Date.parse(t[l].date_end).toString("MMM d, yyyy [hh:mm tt]"));var r=Date.parse(t[l].date_end)-Date.parse(t[l].date_start),s=Math.round(r/6e4),n=s%60,o=(s-n)/60;i=i.replace(/_duration_/g,"Hours ("+o+") - Min ("+n+")"),a+=i=(i=(i=(i=(i="null"===t[l].project||null==t[l].project||void 0===t[l].project?i.replace(/_project_/g,"None"):i.replace(/_project_/g,t[l].project)).replace(/_project_/g,t[l].project)).replace(/_details_/g,t[l].details)).replace(/_id_/g,t[l].id)).replace(/_BASE_/g,this.baseUrl)}catch(e){}$(".timesheet_entries_table_body").html(a),"SubEmployeeTimeSheetAll"===modJs.getTableName()||""+this.needStartEndTime=="0"?($(".submit_sheet").hide(),$(".add_time_sheet_entry").hide()):"Approved"===this.currentElement.status?($(".submit_sheet").hide(),$(".add_time_sheet_entry").hide()):($(".submit_sheet").show(),$(".add_time_sheet_entry").show()),$("#EmployeeTimesheetBlock").fullCalendar("refetchEvents")}},{key:"getTimeEntriesFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting timesheet entries")}},{key:"createPreviousTimesheet",value:function(e){var t={id:e},a=JSON.stringify(t),l=[];l.callBackData=[],l.callBackSuccess="createPreviousTimesheetSuccessCallBack",l.callBackFail="createPreviousTimesheetFailCallBack",this.customAction("createPreviousTimesheet","modules=time_sheets",a,l)}},{key:"createPreviousTimesheetSuccessCallBack",value:function(e){$(".tooltip").css("display","none"),$(".tooltip").remove(),this.get([])}},{key:"createPreviousTimesheetFailCallBack",value:function(e){this.showMessage("Error",e)}},{key:"changeTimeSheetStatusWithId",value:function(e,t){if(""!==t&&null!=t&&void 0!==t){var a={id:e,status:t},l=JSON.stringify(a),i=[];i.callBackData=[],i.callBackSuccess="changeTimeSheetStatusSuccessCallBack",i.callBackFail="changeTimeSheetStatusFailCallBack",this.customAction("changeTimeSheetStatus","modules=time_sheets",l,i)}else this.showMessage("Status Error","Please select a status")}},{key:"changeTimeSheetStatusSuccessCallBack",value:function(e){this.showMessage("Successful","Timesheet status changed successfully"),this.get([])}},{key:"changeTimeSheetStatusFailCallBack",value:function(e){this.showMessage("Error","Error occured while changing Timesheet status")}},{key:"getActionButtonsHtml",value:function(e,t){var a="";if(a=""+this.needStartEndTime=="0"?'
    _redoBtn_
    ':'
    _redoBtn_
    ',"EmployeeTimeSheetAll"===this.getTableName()){a=a.replace(/_redoBtn_/g,'')}else a=a.replace(/_redoBtn_/g,"");return a=(a=(a=(a=(a=a.replace(/_id_/g,e)).replace(/_sdate_/g,t[1])).replace(/_edate_/g,t[2])).replace(/_status_/g,t[4])).replace(/_BASE_/g,this.baseUrl)}},{key:"getCustomTableParams",value:function(){var e=this;return{aoColumnDefs:[{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,1)},aTargets:[1]},{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,2)},aTargets:[2]},{fnRender:e.getActionButtons,aTargets:[e.getDataMapping().length]}]}}},{key:"preProcessRemoteTableData",value:function(e,t,a){return Date.parse(t).toString("MMM d, yyyy (dddd)")}}]),t}(),m=function(e){function t(e,a,l,i){o(this,t);var r=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return r.timeSheetStatusChangeId=null,r}return d(t,h),l(t,[{key:"getDataMapping",value:function(){return["id","employee","date_start","date_end","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee",bSearchable:!0},{sTitle:"Start Date",bSearchable:!0},{sTitle:"End Date",bSearchable:!0},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"select","allow-null":!1,"remote-source":["Employee","id","first_name+last_name"]}],["date_start",{label:"TimeSheet Start Date",type:"date",validation:""}],["date_end",{label:"TimeSheet Start Date",type:"date",validation:""}],["details",{label:"Reason",type:"textarea",validation:"none"}]]}},{key:"isSubProfileTable",value:function(){return!0}},{key:"getCustomSuccessCallBack",value:function(e){for(var t=[],a=this.getDataMapping(),l=0;l':'
    ').replace(/_id_/g,e).replace(/_BASE_/g,this.baseUrl).replace(/_sdate_/g,t[1]).replace(/_edate_/g,t[2]).replace(/_status_/g,t[4])}},{key:"getCustomTableParams",value:function(){var e=this;return{aoColumnDefs:[{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,2)},aTargets:[2]},{fnRender:function(t,a){return e.preProcessRemoteTableData(t,a,3)},aTargets:[3]},{fnRender:e.getActionButtons,aTargets:[e.getDataMapping().length]}]}}},{key:"getFilters",value:function(){return[["employee",{label:"Employee",type:"select2","allow-null":!0,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],["status",{label:"Status",type:"select","allow-null":!0,"null-label":"All",source:[["Submitted","Submitted"],["Pending","Pending"],["Approved","Approved"],["Rejected","Rejected"]]}]]}}]),t}(),f=function(e){function t(e,a,l,i){o(this,t);var r=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return r.timesheetId=null,r.currentTimesheet=null,r.allProjectsAllowed=1,r.employeeProjects=[],r}return d(t,i.default),l(t,[{key:"getDataMapping",value:function(){return["id","project","date_start","time_start","date_end","time_end","details"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Project"},{sTitle:"Start Date"},{sTitle:"Start Time"},{sTitle:"End Date"},{sTitle:"End Time"},{sTitle:"Details"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["project",{label:"Project",type:"select2","allow-null":!1,"remote-source":["Project","id","name","getEmployeeProjects"]}],["date_select",{label:"Date",type:"select",source:[]}],["date_start",{label:"Start Time",type:"time",validation:""}],["date_end",{label:"End Time",type:"time",validation:""}],["details",{label:"Details",type:"textarea",validation:""}]]}},{key:"getDates",value:function(e,t){for(var a=[],l=e;l<=t;)a.push(new Date(l)),l=l.add({days:1});return a}},{key:"renderForm",value:function(e){var t=this.getCustomTemplate("time_entry_form.html");t=t.replace(/modJs/g,"modJsList['tabEmployeeTimeEntry']");for(var a="",l=this.getFormFields(),i=0;i'+u[1]+""}t=(t=t.replace(/_id_/g,this.getTableName()+"_submit")).replace(/_fields_/g,a),$("#"+this.getTableName()+"Form").html(t),$("#"+this.getTableName()+"Form").show(),$("#"+this.getTableName()).hide(),$("#"+this.getTableName()+"Form .datefield").datepicker({viewMode:2}),$("#"+this.getTableName()+"Form .datetimefield").datetimepicker({language:"en"}),$("#"+this.getTableName()+"Form .timefield").datetimepicker({language:"en",pickDate:!1}),$("#"+this.getTableName()+"Form .select2Field").select2(),$("#date_select").html(n),void 0!==e&&null!=e&&this.fillForm(e)}},{key:"fillForm",value:function(e,t,a){var l=t;null!=l&&void 0!==l&&""!==l||(l="#"+this.getTableName()+"Form"),null!=e.id&&void 0!==e.id&&$(l+" #id").val(e.id),null!=e.project&&void 0!==e.project&&$(l+" #project").select2("val",e.project),null!=e.date&&void 0!==e.date&&$(l+" #date_select").val(e.date)}},{key:"cancel",value:function(){$("#TimeEntryModel").modal("hide")}},{key:"setAllProjectsAllowed",value:function(e){this.allProjectsAllowed=e}},{key:"setEmployeeProjects",value:function(e){this.employeeProjects=e}},{key:"save",value:function(){var e=new r.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();t.timesheet=this.timesheetId,t.time_start=t.date_start,t.time_end=t.date_end,t.date_start=t.date_select+" "+t.date_start,t.date_end=t.date_select+" "+t.date_end;var a=this.doCustomValidation(t);if(null==a){var l=$("#"+this.getTableName()+"_submit #id").val();null!=l&&void 0!==l&&""!==l&&(t.id=l),this.add(t,[]),this.cancel()}else $("#"+this.getTableName()+"Form .label").html(a),$("#"+this.getTableName()+"Form .label").show()}}},{key:"doCustomValidation",value:function(e){var t=Date.parse(e.date_start),a=Date.parse(e.date_end);return-1!==t.compareTo(a)?"Start time should be less than End time":null}},{key:"addSuccessCallBack",value:function(e,t){this.get(e),modJs.getTimeEntries()}},{key:"deleteRow",value:function(e){this.deleteObj(e,[])}},{key:"deleteSuccessCallBack",value:function(e,t){modJs.getTimeEntries()}}]),t}(),p=function(e){function t(e,a,l,i){o(this,t);var r=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return r.cellDataUpdates={},r.currentId=null,r}return d(t,s.default),l(t,[{key:"validateCellValue",value:function(e,t,a){if(!c.float(a))return!1;var l=parseFloat(a);if(l<0||l>24)return!1;var i=this.columnIDMap[e.data("colId")]+2,r=0,s=0;return $("#"+this.getTableName()+" tr td:nth-child("+i+")").each(function(){var t=$(this).data("rowId"),l="";l=e.data("rowId")===t?a:$(this).html(),-1!==t?c.float(l)&&(r+=parseFloat(l),e.data("rowId")!==t&&(s+=parseFloat(l))):r>24?$(this).html(s):$(this).html(r)}),!(r>24)&&(modJs.addCellDataUpdate(e.data("colId"),e.data("rowId"),a),!0)}},{key:"setCurrentTimeSheetId",value:function(e){this.currentId=e,this.cellDataUpdates={}}},{key:"addAdditionalRequestData",value:function(e,t){return"updateData"===e?t.currentId=this.currentId:"updateAllData"===e?t.currentId=this.currentId:"getAllData"===e&&(t.currentId=this.currentId),t}},{key:"modifyCSVHeader",value:function(e){return e.unshift(""),e}},{key:"getCSVData",value:function(){for(var e="",t=0;t
    ';var r=$("#"+e+" .dataTables_paginate .active a").html(),s=0;null!=r&&(s=100*parseInt(r,10)-100),$("#"+e).html(i);var n={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t,aoColumns:a,bSort:!1,iDisplayLength:100,iDisplayStart:s},o=this.getCustomTableParams();$.extend(n,o),$("#"+e+" #grid").dataTable(n),$("#"+e+" #grid tr:last").find("td").removeClass("editcell"),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$("#"+e+" #grid").editableTableWidget(),$("#"+e+" #grid .editcell").on("validate",function(e,t){return modJs.validateCellValue($(this),e,t)})}}]),t}();t.exports={EmployeeTimeSheetAdapter:h,SubEmployeeTimeSheetAdapter:m,EmployeeTimeEntryAdapter:f,QtsheetAdapter:p}},{"../../../api/AdapterBase":2,"../../../api/FormValidation":3,"../../../api/TableEditAdapter":5}]},{},[6]); +//# sourceMappingURL=time_sheets.js.map diff --git a/web/modules/dist/travel.js b/web/modules/dist/travel.js new file mode 100644 index 00000000..c15dcbec --- /dev/null +++ b/web/modules/dist/travel.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,o){if(!a[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=o},{"./LogViewAdapter":8}],5:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a',l='
    _edit__logs__delete_
    ';return l=l.replace("_logs_",''),l=this.showDelete?"Approved"===t[7]?l.replace("_delete_",a):"Pending"===t[7]||"Admin"===this.user.user_level?l.replace("_delete_",''):l.replace("_delete_",""):l.replace("_delete_",""),l=(l=(l=this.showEdit?l.replace("_edit_",''):l.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}}]),t}();a.default=o},{"./LogViewAdapter":8}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a
    #_delete_##_edit_##_label_#:#_value_#
    ',validation:"none"}],["display_order",{label:"Priority",type:"text",validation:"number"}],["display_section",{label:"Display Section",type:"text",validation:"none"}]]}},{key:"setTableType",value:function(e){this.tableType=e}},{key:"doCustomValidation",value:function(e){var t;return null!=(t=e.name)&&/^[a-z][a-z0-9._]+$/.test(t)?null:"Invalid name for custom field"}},{key:"forceInjectValuesBeforeSave",value:function(e){var t=[e.name],a=[],l=void 0;if(t.push({}),t[1].label=e.field_label,t[1].type=e.field_type,t[1].validation=e.field_validation,["select","select2","select2multi"].indexOf(e.field_type)>=0){for(var i in l=""===e.field_options||void 0===e.field_options?[]:JSON.parse(e.field_options))a.push([l[i].value,l[i].label]);t[1].source=a}return null!=e.field_validation&&void 0!==e.field_validation||(e.field_validation=""),e.data=JSON.stringify(t),e.type=this.tableType,e}}]),t}();a.default=o},{"./AdapterBase":3}],7:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=o},{"./AdapterBase":3}],9:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'),a=(a=(a=(a="Processing"===t[this.getStatusFieldPosition()]?a.replace("_status_",''):a.replace("_status_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"getStatusOptionsData",value:function(e){var t={};return"Processing"===e&&(t.Approved="Approved",t.Rejected="Rejected"),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}(),h=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,n.EmployeeTravelRecordAdminAdapter),t}();t.exports={EmployeeImmigrationAdapter:d,EmployeeTravelRecordAdapter:p,EmployeeTravelRecordApproverAdapter:f,SubordinateEmployeeTravelRecordAdapter:h}},{"../../../admin/src/travel/lib":1,"../../../api/AdapterBase":3,"../../../api/ApproveModuleAdapter":5}]},{},[10]); +//# sourceMappingURL=travel.js.map diff --git a/web/modules/emergency_contact/lib.js b/web/modules/emergency_contact/lib.js deleted file mode 100644 index 3d485d93..00000000 --- a/web/modules/emergency_contact/lib.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - - -function EmergencyContactAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmergencyContactAdapter.inherits(AdapterBase); - - - -EmergencyContactAdapter.method('getDataMapping', function() { - return [ - "id", - "name", - "relationship", - "home_phone", - "work_phone", - "mobile_phone" - ]; -}); - -EmergencyContactAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Name" }, - { "sTitle": "Relationship"}, - { "sTitle": "Home Phone"}, - { "sTitle": "Work Phone"}, - { "sTitle": "Mobile Phone"} - ]; -}); - -EmergencyContactAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "name", {"label":"Name","type":"text","validation":""}], - [ "relationship", {"label":"Relationship","type":"text","validation":"none"}], - [ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}], - [ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}], - [ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}] - ]; -}); diff --git a/web/modules/employees/lib.js b/web/modules/employees/lib.js deleted file mode 100644 index 290a633f..00000000 --- a/web/modules/employees/lib.js +++ /dev/null @@ -1,730 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeAdapter(endPoint) { - this.initAdapter(endPoint); - this.fieldNameMap = {}; - this.hiddenFields = {}; - this.tableFields = {}; - this.formOnlyFields = {}; -} - -EmployeeAdapter.inherits(AdapterBase); - -this.currentUserId = null; - -EmployeeAdapter.method('setFieldNameMap', function(fields) { - var field; - for(var i=0;i 0) { - - - var ct = '
    '; - - var sectionTemplate = '

    #_section.name_#

    '; - var customFieldHtml; - for (index in data.customFields) { - - if(!data.customFields[index][1]){ - data.customFields[index][1] = this.gt('Other Details'); - } - - sectionId = data.customFields[index][1].toLocaleLowerCase(); - sectionId = sectionId.replace(' ','_'); - - if($("#cont_"+sectionId).length <= 0){ - //Add section - sectionHtml = sectionTemplate; - sectionHtml = sectionHtml.replace('#_section_#', sectionId); - sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); - $("#customFieldsCont").append($(sectionHtml)); - } - - customFieldHtml = ct; - customFieldHtml = customFieldHtml.replace('#_label_#', index); - if (data.customFields[index][2] === 'fileupload') { - customFieldHtml = customFieldHtml.replace( - '#_value_#', - '' - ); - } else { - customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); - } - $("#cont_"+sectionId).append($(customFieldHtml)); - } - }else{ - $("#customFieldsCont").remove(); - } - - $("#"+this.getTableName()+" #subordinates").html(subordinates); - - - $("#"+this.getTableName()+" #name").html(data.first_name + " " + data.last_name); - this.currentUserId = data.id; - - $("#"+this.getTableName()+" #profile_image_"+data.id).attr('src',data.image); - - if(this.checkPermission("Upload/Delete Profile Image") == "No"){ - $("#employeeUploadProfileImage").remove(); - $("#employeeDeleteProfileImage").remove(); - } - - if(this.checkPermission("Edit Employee Details") == "No"){ - $("#employeeProfileEditInfo").remove(); - } - - if(currentEmpId != userEmpId){ - $("#employeeUpdatePassword").remove(); - } - - this.cancel(); -}); - -EmployeeAdapter.method('modEmployeeGetFailCallBack' , function(data) { - -}); - -EmployeeAdapter.method('editEmployee' , function() { - this.edit(this.currentUserId); -}); - -EmployeeAdapter.method('changePassword', function() { - $('#adminUsersModel').modal('show'); - $('#adminUsersChangePwd #newpwd').val(''); - $('#adminUsersChangePwd #conpwd').val(''); -}); - -EmployeeAdapter.method('changePasswordConfirm', function() { - $('#adminUsersChangePwd_error').hide(); - - var passwordValidation = function (str) { - return str.length > 7; - }; - - var password = $('#adminUsersChangePwd #newpwd').val(); - - if(!passwordValidation(password)){ - $('#adminUsersChangePwd_error').html("Password should be longer than 7 characters"); - $('#adminUsersChangePwd_error').show(); - return; - } - - var conPassword = $('#adminUsersChangePwd #conpwd').val(); - - if(conPassword != password){ - $('#adminUsersChangePwd_error').html("Passwords don't match"); - $('#adminUsersChangePwd_error').show(); - return; - } - - var req = {"pwd":conPassword}; - var reqJson = JSON.stringify(req); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'changePasswordSuccessCallBack'; - callBackData['callBackFail'] = 'changePasswordFailCallBack'; - - this.customAction('changePassword','modules=employees',reqJson,callBackData); - -}); - -EmployeeAdapter.method('closeChangePassword', function() { - $('#adminUsersModel').modal('hide'); -}); - -EmployeeAdapter.method('changePasswordSuccessCallBack', function(callBackData,serverData) { - this.closeChangePassword(); - this.showMessage("Password Change","Password changed successfully"); -}); - -EmployeeAdapter.method('changePasswordFailCallBack', function(callBackData,serverData) { - this.closeChangePassword(); - this.showMessage("Error",callBackData); -}); - - - - -/* - * Company Graph - */ - -function CompanyStructureAdapter(endPoint) { - this.initAdapter(endPoint); -} - -CompanyStructureAdapter.inherits(AdapterBase); - - - -CompanyStructureAdapter.method('getDataMapping', function() { - return [ - "id", - "title", - "address", - "type", - "country", - "parent" - ]; -}); - -CompanyStructureAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false }, - { "sTitle": "Name" }, - { "sTitle": "Address"}, - { "sTitle": "Type"}, - { "sTitle": "Country", "sClass": "center" }, - { "sTitle": "Parent Structure"} - ]; -}); - -CompanyStructureAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden","validation":""}], - [ "title", {"label":"Name","type":"text","validation":""}], - [ "description", {"label":"Details","type":"textarea","validation":""}], - [ "address", {"label":"Address","type":"textarea","validation":"none"}], - [ "type", {"label":"Type","type":"select","source":[["Company","Company"],["Head Office","Head Office"],["Regional Office","Regional Office"],["Department","Department"],["Unit","Unit"],["Sub Unit","Sub Unit"],["Other","Other"]]}], - [ "country", {"label":"Country","type":"select","remote-source":["Country","code","name"]}], - [ "parent", {"label":"Parent Structure","type":"select","allow-null":true,"remote-source":["CompanyStructure","id","title"]}] - ]; -}); - - - -function CompanyGraphAdapter(endPoint) { - this.initAdapter(endPoint); - this.nodeIdCounter = 0; -} - -CompanyGraphAdapter.inherits(CompanyStructureAdapter); - - -CompanyGraphAdapter.method('convertToTree', function(data) { - var ice = {}; - ice['id'] = -1; - ice['title'] = ''; - ice['name'] = ''; - ice['children'] = []; - - var parent = null; - - var added = {}; - - - for(var i=0;i"; - obj.parent = null; - break; - } - parentIdArr[parent.id] = 1; - curObj = parent; - } - } - - if(errorMsg != ""){ - this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:
    "+errorMsg); - return false; - } - - return true; - -}); - - - -/* - * Api Access - */ - -function ApiAccessAdapter(endPoint) { - this.initAdapter(endPoint); -} - -ApiAccessAdapter.inherits(AdapterBase); - - - -ApiAccessAdapter.method('getDataMapping', function() { - return [ - ]; -}); - -ApiAccessAdapter.method('getHeaders', function() { - return [ - - ]; -}); - -ApiAccessAdapter.method('getFormFields', function() { - return [ - ]; -}); - -ApiAccessAdapter.method('get', function() { - -}); diff --git a/web/modules/loans/lib.js b/web/modules/loans/lib.js deleted file mode 100644 index 148449f3..00000000 --- a/web/modules/loans/lib.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeCompanyLoanAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeCompanyLoanAdapter.inherits(AdapterBase); - - - -EmployeeCompanyLoanAdapter.method('getDataMapping', function() { - return [ - "id", - "loan", - "start_date", - "period_months", - "currency", - "amount", - "status" - ]; -}); - -EmployeeCompanyLoanAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Loan Type" }, - { "sTitle": "Loan Start Date"}, - { "sTitle": "Loan Period (Months)"}, - { "sTitle": "Currency"}, - { "sTitle": "Amount"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeCompanyLoanAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "loan", {"label":"Loan Type","type":"placeholder","remote-source":["CompanyLoan","id","name"]}], - [ "start_date", {"label":"Loan Start Date","type":"placeholder","validation":""}], - [ "last_installment_date", {"label":"Last Installment Date","type":"placeholder","validation":"none"}], - [ "period_months", {"label":"Loan Period (Months)","type":"placeholder","validation":"number"}], - [ "currency", {"label":"Currency","type":"placeholder","remote-source":["CurrencyType","id","name"]}], - [ "amount", {"label":"Loan Amount","type":"placeholder","validation":"float"}], - [ "monthly_installment", {"label":"Monthly Installment","type":"placeholder","validation":"float"}], - [ "status", {"label":"Status","type":"placeholder","source":[["Approved","Approved"],["Paid","Paid"],["Suspended","Suspended"]]}], - [ "details", {"label":"Details","type":"placeholder","validation":"none"}] - ]; -}); - - -EmployeeCompanyLoanAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var html = '
    _edit__delete_
    '; - - if(this.showDelete){ - html = html.replace('_delete_',deleteButton); - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); diff --git a/web/modules/overtime/lib.js b/web/modules/overtime/lib.js deleted file mode 100644 index 07af1c42..00000000 --- a/web/modules/overtime/lib.js +++ /dev/null @@ -1,120 +0,0 @@ -/* -This file is part of iCE Hrm. - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - - -function EmployeeOvertimeAdapter(endPoint) { - this.initAdapter(endPoint); - this.itemName = 'Overtime'; - this.itemNameLower = 'employeeovertime'; - this.modulePathName = 'overtime'; -} - -EmployeeOvertimeAdapter.inherits(ApproveModuleAdapter); - - - -EmployeeOvertimeAdapter.method('getDataMapping', function() { - return [ - "id", - "category", - "start_time", - "end_time", - "project", - "status" - ]; -}); - -EmployeeOvertimeAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Category" }, - { "sTitle": "Start Time" }, - { "sTitle": "End Time"}, - { "sTitle": "Project"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeOvertimeAdapter.method('getFormFields', function() { - return [ - ["id", {"label": "ID", "type": "hidden"}], - ["category", {"label": "Category", "type": "select2", "allow-null":false, "remote-source": ["OvertimeCategory", "id", "name"]}], - ["start_time", {"label": "Start Time", "type": "datetime", "validation": ""}], - ["end_time", {"label": "End Time", "type": "datetime", "validation": ""}], - ["project", {"label": "Project", "type": "select2", "allow-null":true,"null=label":"none","remote-source": ["Project", "id", "name"]}], - ["notes", {"label": "Notes", "type": "textarea", "validation": "none"}] - ]; -}); - - -/* - EmployeeOvertimeApproverAdapter - */ - -function EmployeeOvertimeApproverAdapter(endPoint) { - this.initAdapter(endPoint); - this.itemName = 'Overtime'; - this.itemNameLower = 'employeeovertime'; - this.modulePathName = 'overtime'; -} - -EmployeeOvertimeApproverAdapter.inherits(EmployeeOvertimeAdminAdapter); - -EmployeeOvertimeApproverAdapter.method('getActionButtonsHtml', function(id,data) { - var statusChangeButton = ''; - var viewLogsButton = ''; - - var html = '
    _status__logs_
    '; - - - html = html.replace('_logs_',viewLogsButton); - - - if(data[this.getStatusFieldPosition()] == 'Processing'){ - html = html.replace('_status_',statusChangeButton); - - }else{ - html = html.replace('_status_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - html = html.replace(/_cstatus_/g,data[this.getStatusFieldPosition()]); - return html; -}); - -EmployeeOvertimeApproverAdapter.method('getStatusOptionsData', function(currentStatus) { - var data = {}; - if(currentStatus != 'Processing'){ - - }else{ - data["Approved"] = "Approved"; - data["Rejected"] = "Rejected"; - - } - - return data; -}); - -EmployeeOvertimeApproverAdapter.method('getStatusOptions', function(currentStatus) { - return this.generateOptions(this.getStatusOptionsData(currentStatus)); -}); - - -/* - EmployeeOvertimeAdapter - */ - -function SubordinateEmployeeOvertimeAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.itemName = 'Overtime'; - this.itemNameLower = 'employeeovertime'; - this.modulePathName = 'overtime'; -} - -SubordinateEmployeeOvertimeAdapter.inherits(EmployeeOvertimeAdminAdapter); - diff --git a/web/modules/projects/lib.js b/web/modules/projects/lib.js deleted file mode 100644 index 1de245b1..00000000 --- a/web/modules/projects/lib.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeProjectAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeProjectAdapter.inherits(AdapterBase); - - - -EmployeeProjectAdapter.method('getDataMapping', function() { - return [ - "id", - "project" - ]; -}); - -EmployeeProjectAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Project" } - ]; -}); - -EmployeeProjectAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "project", {"label":"Project","type":"select2","remote-source":["Project","id","name"]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); diff --git a/web/modules/qualifications/lib.js b/web/modules/qualifications/lib.js deleted file mode 100644 index bff3966a..00000000 --- a/web/modules/qualifications/lib.js +++ /dev/null @@ -1,200 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeSkillAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeSkillAdapter.inherits(AdapterBase); - - - -EmployeeSkillAdapter.method('getDataMapping', function() { - return [ - "id", - "skill_id", - "details" - ]; -}); - -EmployeeSkillAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Skill" }, - { "sTitle": "Details"} - ]; -}); - -EmployeeSkillAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "skill_id", {"label":"Skill","type":"select2","allow-null":true,"remote-source":["Skill","id","name"]}], - [ "details", {"label":"Details","type":"textarea","validation":""}] - ]; -}); - - - - - -/** - * EmployeeEducationAdapter - */ - -function EmployeeEducationAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeEducationAdapter.inherits(AdapterBase); - - - -EmployeeEducationAdapter.method('getDataMapping', function() { - return [ - "id", - "education_id", - "institute", - "date_start", - "date_end" - ]; -}); - -EmployeeEducationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID", "bVisible":false}, - { "sTitle": "Qualification" }, - { "sTitle": "Institute"}, - { "sTitle": "Start Date"}, - { "sTitle": "Completed On"}, - ]; -}); - -EmployeeEducationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "education_id", {"label":"Qualification","type":"select2","allow-null":false,"remote-source":["Education","id","name"]}], - [ "institute", {"label":"Institute","type":"text","validation":""}], - [ "date_start", {"label":"Start Date","type":"date","validation":"none"}], - [ "date_end", {"label":"Completed On","type":"date","validation":"none"}] - ]; -}); - - - - - -/** - * EmployeeCertificationAdapter - */ - -function EmployeeCertificationAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeCertificationAdapter.inherits(AdapterBase); - - - -EmployeeCertificationAdapter.method('getDataMapping', function() { - return [ - "id", - "certification_id", - "institute", - "date_start", - "date_start" - ]; -}); - -EmployeeCertificationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID","bVisible":false}, - { "sTitle": "Certification" }, - { "sTitle": "Institute"}, - { "sTitle": "Granted On"}, - { "sTitle": "Valid Thru"}, - ]; -}); - -EmployeeCertificationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "certification_id", {"label":"Certification","type":"select2","allow-null":false,"remote-source":["Certification","id","name"]}], - [ "institute", {"label":"Institute","type":"text","validation":""}], - [ "date_start", {"label":"Granted On","type":"date","validation":"none"}], - [ "date_end", {"label":"Valid Thru","type":"date","validation":"none"}] - ]; -}); - - - -/** - * EmployeeLanguageAdapter - */ - -function EmployeeLanguageAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeLanguageAdapter.inherits(AdapterBase); - - - -EmployeeLanguageAdapter.method('getDataMapping', function() { - return [ - "id", - "language_id", - "reading", - "speaking", - "writing", - "understanding" - ]; -}); - -EmployeeLanguageAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID", "bVisible":false }, - { "sTitle": "Language" }, - { "sTitle": "Reading"}, - { "sTitle": "Speaking"}, - { "sTitle": "Writing"}, - { "sTitle": "Understanding"} - ]; -}); - -EmployeeLanguageAdapter.method('getFormFields', function() { - - var compArray = [["Elementary Proficiency","Elementary Proficiency"], - ["Limited Working Proficiency","Limited Working Proficiency"], - ["Professional Working Proficiency","Professional Working Proficiency"], - ["Full Professional Proficiency","Full Professional Proficiency"], - ["Native or Bilingual Proficiency","Native or Bilingual Proficiency"]]; - - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "language_id", {"label":"Language","type":"select2","allow-null":false,"remote-source":["Language","id","description"]}], - [ "reading", {"label":"Reading","type":"select","source":compArray}], - [ "speaking", {"label":"Speaking","type":"select","source":compArray}], - [ "writing", {"label":"Writing","type":"select","source":compArray}], - [ "understanding", {"label":"Understanding","type":"select","source":compArray}] - ]; -}); - diff --git a/web/modules/reports/lib.js b/web/modules/reports/lib.js deleted file mode 100644 index 31cc5d42..00000000 --- a/web/modules/reports/lib.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Author: Thilina Hasantha - */ - - -/** - * UserReportAdapter - */ - - -function UserReportAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this._construct(); -} - -UserReportAdapter.inherits(ReportAdapter); - -UserReportAdapter.method('renderForm', function(object) { - var that = this; - this.processFormFieldsWithObject(object); - if(this.remoteFieldsExists){ - var cb = function(){ - that.renderFormNew(object); - }; - this.initFieldMasterData(cb); - }else{ - this.initFieldMasterData(); - that.renderFormNew(object); - } - - this.currentReport = object; - -}); - diff --git a/web/modules/salary/lib.js b/web/modules/salary/lib.js deleted file mode 100644 index ab7b93f2..00000000 --- a/web/modules/salary/lib.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeSalaryAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeSalaryAdapter.inherits(AdapterBase); - - - -EmployeeSalaryAdapter.method('getDataMapping', function() { - return [ - "id", - "component", - "amount", - "details" - ]; -}); - -EmployeeSalaryAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Salary Component" }, - { "sTitle": "Amount"}, - { "sTitle": "Details"} - ]; -}); - -EmployeeSalaryAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "component", {"label":"Salary Component","type":"select2","remote-source":["SalaryComponent","id","name"]}], - [ "amount", {"label":"Amount","type":"text","validation":"float"}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}] - ]; -}); diff --git a/web/modules/src/attendance/index.js b/web/modules/src/attendance/index.js new file mode 100644 index 00000000..be716fdb --- /dev/null +++ b/web/modules/src/attendance/index.js @@ -0,0 +1,7 @@ +import { + AttendanceAdapter, + EmployeeAttendanceSheetAdapter, +} from './lib'; + +window.AttendanceAdapter = AttendanceAdapter; +window.EmployeeAttendanceSheetAdapter = EmployeeAttendanceSheetAdapter; diff --git a/web/modules/src/attendance/lib.js b/web/modules/src/attendance/lib.js new file mode 100644 index 00000000..15ef0a64 --- /dev/null +++ b/web/modules/src/attendance/lib.js @@ -0,0 +1,468 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/* global modJs, modJsList */ + +import AdapterBase from '../../../api/AdapterBase'; +import FormValidation from '../../../api/FormValidation'; + +class AttendanceAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.punch = null; + this.useServerTime = 0; + this.photoTaken = 0; + this.photoAttendance = 0; + } + + updatePunchButton() { + this.getPunch('changePunchButtonSuccessCallBack'); + } + + setUseServerTime(val) { + this.useServerTime = val; + } + + setPhotoAttendance(val) { + this.photoAttendance = parseInt(val, 10); + } + + + getDataMapping() { + return [ + 'id', + 'in_time', + 'out_time', + 'note', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Time-In' }, + { sTitle: 'Time-Out' }, + { sTitle: 'Note' }, + ]; + } + + getFormFields() { + if (this.useServerTime === 0) { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['time', { label: 'Time', type: 'datetime' }], + ['note', { label: 'Note', type: 'textarea', validation: 'none' }], + ]; + } + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['note', { label: 'Note', type: 'textarea', validation: 'none' }], + ]; + } + + + getCustomTableParams() { + const that = this; + const dataTableParams = { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 1); + }, + aTargets: [1], + }, + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 2); + }, + aTargets: [2], + }, + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 3); + }, + aTargets: [3], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + return dataTableParams; + } + + preProcessRemoteTableData(data, cell, id) { + if (id === 1) { + if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { + return ''; + } + return Date.parse(cell).toString('yyyy MMM d HH:mm'); + } if (id === 2) { + if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { + return ''; + } + return Date.parse(cell).toString('MMM d HH:mm'); + } if (id === 3) { + if (cell !== undefined && cell !== null) { + if (cell.length > 20) { + return `${cell.substring(0, 20)}..`; + } + } + return cell; + } + return cell; + } + + + getActionButtonsHtml(id, data) { + return ''; + } + + getTableTopButtonHtml() { + if (this.punch === null || this.punch === undefined) { + return ''; + } + return ''; + } + + + save() { + const that = this; + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const msg = this.doCustomValidation(); + if (msg == null) { + let params = validator.getFormParameters(); + params = this.forceInjectValuesBeforeSave(params); + params.cdate = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'saveSuccessCallback'; + callBackData.callBackFail = 'getPunchFailCallBack'; + + this.customAction('savePunch', 'modules=attendance', reqJson, callBackData, true); + } else { + $(`#${this.getTableName()}Form .label`).html(msg); + $(`#${this.getTableName()}Form .label`).show(); + } + } + } + + saveSuccessCallback(callBackData) { + this.punch = callBackData; + this.getPunch('changePunchButtonSuccessCallBack'); + $('#PunchModel').modal('hide'); + this.get([]); + } + + + cancel() { + $('#PunchModel').modal('hide'); + } + + showPunchDialog() { + this.getPunch('showPunchDialogShowPunchSuccessCallBack'); + } + + getPunch(successCallBack) { + const that = this; + const object = {}; + + object.date = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); + object.offset = this.getClientGMTOffset(); + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = successCallBack; + callBackData.callBackFail = 'getPunchFailCallBack'; + + this.customAction('getPunch', 'modules=attendance', reqJson, callBackData); + } + + + showPunchDialogShowPunchSuccessCallBack(callBackData) { + this.punch = callBackData; + $('#PunchModel').modal('show'); + if (this.punch === null) { + $('#PunchModel').find('h3').html('Punch Time-in'); + modJs.renderForm(); + } else { + $('#PunchModel').find('h3').html('Punch Time-out'); + modJs.renderForm(this.punch); + } + $('#Attendance').show(); + const picker = $('#time_datetime').data('datetimepicker'); + picker.setLocalDate(new Date()); + } + + changePunchButtonSuccessCallBack(callBackData) { + this.punch = callBackData; + if (this.punch === null) { + $('#punchButton').html('Punch-in '); + } else { + $('#punchButton').html('Punch-out '); + } + } + + getPunchFailCallBack(callBackData) { + this.showMessage('Error Occured while Time Punch', callBackData); + } + + getClientDate(date) { + const offset = this.getClientGMTOffset(); + const tzDate = date.addMinutes(offset * 60); + return tzDate; + } + + getClientGMTOffset() { + const rightNow = new Date(); + const jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); + const temp = jan1.toGMTString(); + const jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); + return (jan1 - jan2) / (1000 * 60 * 60); + } + + doCustomValidation(params) { + if (this.photoAttendance === 1 && !this.photoTaken) { + return 'Please attach a photo before submitting'; + } + return null; + } + + forceInjectValuesBeforeSave(params) { + if (this.photoAttendance === 1) { + const canvas = document.getElementById('attendnaceCanvas'); + params.image = canvas.toDataURL(); + } + return params; + } + + postRenderForm() { + if (this.photoAttendance === 1) { + $('.photoAttendance').show(); + const video = document.getElementById('attendnaceVideo'); + + // Get access to the camera! + if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { + navigator.mediaDevices.getUserMedia({ video: true }).then((stream) => { + video.src = window.URL.createObjectURL(stream); + video.play(); + }); + } + this.photoTaken = false; + this.configureEvents(); + } else { + $('.photoAttendance').remove(); + } + } + + configureEvents() { + const that = this; + const canvas = document.getElementById('attendnaceCanvas'); + const context = canvas.getContext('2d'); + const video = document.getElementById('attendnaceVideo'); + $('.attendnaceSnap').click(() => { + context.drawImage(video, 0, 0, 208, 156); + that.photoTaken = true; + return false; + }); + } +} + + +class EmployeeAttendanceSheetAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.currentTimesheetId = null; + this.currentTimesheet = null; + } + + getDataMapping() { + return [ + 'id', + 'date_start', + 'date_end', + 'total_time', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Start Date' }, + { sTitle: 'End Date' }, + { sTitle: 'Total Time' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], + ['date_end', { label: 'TimeSheet End Date', type: 'date', validation: '' }], + ['details', { label: 'Reason', type: 'textarea', validation: 'none' }], + ]; + } + + preProcessTableData(row) { + row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); + row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); + return row; + } + + renderForm(object) { + const formHtml = this.templates.formTemplate; + const html = ''; + + $(`#${this.getTableName()}Form`).html(formHtml); + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + $('#attendnacesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); + $('#attendnacesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); + + this.currentTimesheet = object; + + this.getTimeEntries(); + } + + + getTimeEntries() { + const timesheetId = this.currentId; + const sourceMappingJson = JSON.stringify(modJsList.tabEmployeeTimeEntry.getSourceMapping()); + + const reqJson = JSON.stringify({ id: timesheetId, sm: sourceMappingJson }); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getTimeEntriesSuccessCallBack'; + callBackData.callBackFail = 'getTimeEntriesFailCallBack'; + + this.customAction('getTimeEntries', 'modules=time_sheets', reqJson, callBackData); + } + + getTimeEntriesSuccessCallBack(callBackData) { + const entries = callBackData; + let html = ''; + const temp = '_start__end__duration__project__details_'; + + for (let i = 0; i < entries.length; i++) { + try { + let t = temp; + t = t.replace(/_start_/g, Date.parse(entries[i].date_start).toString('MMM d, yyyy [hh:mm tt]')); + t = t.replace(/_end_/g, Date.parse(entries[i].date_end).toString('MMM d, yyyy [hh:mm tt]')); + + const mili = Date.parse(entries[i].date_end) - Date.parse(entries[i].date_start); + const minutes = Math.round(mili / 60000); + const hourMinutes = (minutes % 60); + const hours = (minutes - hourMinutes) / 60; + + t = t.replace(/_duration_/g, `Hours (${hours}) - Min (${hourMinutes})`); + if (entries[i].project === 'null' || entries[i].project === null || entries[i].project === undefined) { + t = t.replace(/_project_/g, 'None'); + } else { + t = t.replace(/_project_/g, entries[i].project); + } + t = t.replace(/_project_/g, entries[i].project); + t = t.replace(/_details_/g, entries[i].details); + t = t.replace(/_id_/g, entries[i].id); + t = t.replace(/_BASE_/g, this.baseUrl); + html += t; + } catch (e) { + // DN + } + } + + $('.timesheet_entries_table_body').html(html); + if (modJs.getTableName() === 'SubEmployeeTimeSheetAll') { + $('#submit_sheet').hide(); + $('#add_time_sheet_entry').hide(); + } else if (this.currentElement.status === 'Approved') { + $('#submit_sheet').hide(); + $('#add_time_sheet_entry').hide(); + } else { + $('#submit_sheet').show(); + $('#add_time_sheet_entry').show(); + } + } + + getTimeEntriesFailCallBack(callBackData) { + this.showMessage('Error', 'Error occured while getting timesheet entries'); + } + + + createPreviousAttendnacesheet(id) { + const reqJson = JSON.stringify({ id }); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'createPreviousAttendnacesheetSuccessCallBack'; + callBackData.callBackFail = 'createPreviousAttendnacesheetFailCallBack'; + + this.customAction('createPreviousAttendnaceSheet', 'modules=attendnace', reqJson, callBackData); + } + + createPreviousAttendnacesheetSuccessCallBack(callBackData) { + $('.tooltip').css('display', 'none'); + $('.tooltip').remove(); + // this.showMessage("Success", "Previous Timesheet created"); + this.get([]); + } + + createPreviousAttendnacesheetFailCallBack(callBackData) { + this.showMessage('Error', callBackData); + } + + + getActionButtonsHtml(id, data) { + let html = ''; + if (this.getTableName() === 'EmployeeTimeSheetAll') { + html = '
    '; + } else { + html = '
    '; + } + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getCustomTableParams() { + const that = this; + const dataTableParams = { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 1); + }, + aTargets: [1], + }, + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 2); + }, + aTargets: [2], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + return dataTableParams; + } + + preProcessRemoteTableData(data, cell, id) { + return Date.parse(cell).toString('MMM d, yyyy (dddd)'); + } +} + +module.exports = { + AttendanceAdapter, + EmployeeAttendanceSheetAdapter, +}; diff --git a/web/modules/src/dashboard/index.js b/web/modules/src/dashboard/index.js new file mode 100644 index 00000000..636c6706 --- /dev/null +++ b/web/modules/src/dashboard/index.js @@ -0,0 +1,3 @@ +import { DashboardAdapter } from './lib'; + +window.DashboardAdapter = DashboardAdapter; diff --git a/web/modules/src/dashboard/lib.js b/web/modules/src/dashboard/lib.js new file mode 100644 index 00000000..3eb820ef --- /dev/null +++ b/web/modules/src/dashboard/lib.js @@ -0,0 +1,99 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +class DashboardAdapter extends AdapterBase { + getDataMapping() { + return []; + } + + getHeaders() { + return []; + } + + getFormFields() { + return []; + } + + + get(callBackData) { + } + + + getPunch() { + const that = this; + const object = {}; + + object.date = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); + object.offset = this.getClientGMTOffset(); + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getPunchSuccessCallBack'; + callBackData.callBackFail = 'getPunchFailCallBack'; + + this.customAction('getPunch', 'modules=attendance', reqJson, callBackData); + } + + + getPunchSuccessCallBack(callBackData) { + const punch = callBackData; + if (punch == null) { + $('#lastPunchTime').html('Not'); + $('#punchTimeText').html('Punched In'); + } else { + $('#lastPunchTime').html(Date.parse(punch.in_time).toString('h:mm tt')); + $('#punchTimeText').html('Punched In'); + } + } + + getPunchFailCallBack(callBackData) { + + } + + getInitData() { + const that = this; + const object = {}; + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; + callBackData.callBackFail = 'getInitDataFailCallBack'; + + this.customAction('getInitData', 'modules=dashboard', reqJson, callBackData); + } + + getInitDataSuccessCallBack(data) { + $('#timeSheetHoursWorked').html(data.lastTimeSheetHours); + $('#numberOfProjects').html(data.activeProjects); + $('#pendingLeaveCount').html(data.pendingLeaves); + + $('#numberOfEmployees').html(`${data.numberOfEmployees} Subordinates`); + $('#numberOfCandidates').html(`${data.numberOfCandidates} Candidates`); + $('#numberOfJobs').html(`${data.numberOfJobs} Active`); + $('#numberOfCourses').html(`${data.numberOfCourses} Active`); + } + + getInitDataFailCallBack(callBackData) { + + } + + + getClientDate(date) { + const offset = this.getClientGMTOffset(); + const tzDate = date.addMinutes(offset * 60); + return tzDate; + } + + getClientGMTOffset() { + const rightNow = new Date(); + const jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); + const temp = jan1.toGMTString(); + const jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); + return (jan1 - jan2) / (1000 * 60 * 60); + } +} + +module.exports = { DashboardAdapter }; diff --git a/web/modules/src/dependents/index.js b/web/modules/src/dependents/index.js new file mode 100644 index 00000000..f06043bb --- /dev/null +++ b/web/modules/src/dependents/index.js @@ -0,0 +1,3 @@ +import { EmployeeDependentAdapter } from './lib'; + +window.EmployeeDependentAdapter = EmployeeDependentAdapter; diff --git a/web/modules/src/dependents/lib.js b/web/modules/src/dependents/lib.js new file mode 100644 index 00000000..78029a71 --- /dev/null +++ b/web/modules/src/dependents/lib.js @@ -0,0 +1,44 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * EmployeeDependentAdapter + */ + +class EmployeeDependentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'relationship', + 'dob', + 'id_number', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Date of Birth' }, + { sTitle: 'Id Number' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], + ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], + ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }], + ]; + } +} + +module.exports = { EmployeeDependentAdapter }; diff --git a/web/modules/src/emergency_contact/index.js b/web/modules/src/emergency_contact/index.js new file mode 100644 index 00000000..2b57b87e --- /dev/null +++ b/web/modules/src/emergency_contact/index.js @@ -0,0 +1,3 @@ +import { EmergencyContactAdapter } from './lib'; + +window.EmergencyContactAdapter = EmergencyContactAdapter; diff --git a/web/modules/src/emergency_contact/lib.js b/web/modules/src/emergency_contact/lib.js new file mode 100644 index 00000000..cae1dae5 --- /dev/null +++ b/web/modules/src/emergency_contact/lib.js @@ -0,0 +1,44 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + + +class EmergencyContactAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'relationship', + 'home_phone', + 'work_phone', + 'mobile_phone', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Home Phone' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Mobile Phone' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ]; + } +} + +module.exports = { EmergencyContactAdapter }; diff --git a/web/modules/src/employees/index.js b/web/modules/src/employees/index.js new file mode 100644 index 00000000..b39df74a --- /dev/null +++ b/web/modules/src/employees/index.js @@ -0,0 +1,9 @@ +import { + EmployeeAdapter, + CompanyGraphAdapter, + ApiAccessAdapter, +} from './lib'; + +window.EmployeeAdapter = EmployeeAdapter; +window.CompanyGraphAdapter = CompanyGraphAdapter; +window.ApiAccessAdapter = ApiAccessAdapter; diff --git a/web/modules/src/employees/lib.js b/web/modules/src/employees/lib.js new file mode 100644 index 00000000..889056af --- /dev/null +++ b/web/modules/src/employees/lib.js @@ -0,0 +1,724 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/* eslint-disable camelcase,no-underscore-dangle */ + +/* global d3 */ + +import QRCode from 'qrcode'; +import AdapterBase from '../../../api/AdapterBase'; + + +class EmployeeAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.fieldNameMap = {}; + this.hiddenFields = {}; + this.tableFields = {}; + this.formOnlyFields = {}; + this.currentUserId = null; + } + + setFieldNameMap(fields) { + let field; + for (let i = 0; i < fields.length; i++) { + field = fields[i]; + this.fieldNameMap[field.name] = field; + if (field.display === 'Hidden') { + this.hiddenFields[field.name] = field; + } else if (field.display === 'Table and Form') { + this.tableFields[field.name] = field; + } else { + this.formOnlyFields[field.name] = field; + } + } + } + + getDataMapping() { + return [ + 'id', + 'employee_id', + 'first_name', + 'last_name', + 'mobile_phone', + 'department', + 'gender', + 'supervisor', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'Employee Number' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Mobile' }, + { sTitle: 'Department' }, + { sTitle: 'Gender' }, + { sTitle: 'Supervisor' }, + ]; + } + + getFormFields() { + const newFields = []; + let employee_id; let ssn_num; let employment_status; let job_title; let pay_grade; let joined_date; let department; let work_email; let + country; + + if (this.checkPermission('Edit Employee Number') === 'Yes') { + employee_id = ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }]; + } else { + employee_id = ['employee_id', { label: 'Employee Number', type: 'placeholder', validation: '' }]; + } + + if (this.checkPermission('Edit EPF/CPF Number') === 'Yes') { + ssn_num = ['ssn_num', { label: 'EPF/CPF/SS No', type: 'text', validation: 'none' }]; + } else { + ssn_num = ['ssn_num', { label: 'EPF/CPF/SS No', type: 'placeholder', validation: 'none' }]; + } + + if (this.checkPermission('Edit Employment Status') === 'Yes') { + employment_status = ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }]; + } else { + employment_status = ['employment_status', { label: 'Employment Status', type: 'placeholder', 'remote-source': ['EmploymentStatus', 'id', 'name'] }]; + } + + if (this.checkPermission('Edit Job Title') === 'Yes') { + job_title = ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }]; + } else { + job_title = ['job_title', { label: 'Job Title', type: 'placeholder', 'remote-source': ['JobTitle', 'id', 'name'] }]; + } + + if (this.checkPermission('Edit Pay Grade') === 'Yes') { + pay_grade = ['pay_grade', { + label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }]; + } else { + pay_grade = ['pay_grade', { + label: 'Pay Grade', type: 'placeholder', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }]; + } + + if (this.checkPermission('Edit Joined Date') === 'Yes') { + joined_date = ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }]; + } else { + joined_date = ['joined_date', { label: 'Joined Date', type: 'placeholder', validation: '' }]; + } + + if (this.checkPermission('Edit Department') === 'Yes') { + department = ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }]; + } else { + department = ['department', { label: 'Department', type: 'placeholder', 'remote-source': ['CompanyStructure', 'id', 'title'] }]; + } + + if (this.checkPermission('Edit Work Email') === 'Yes') { + work_email = ['work_email', { label: 'Work Email', type: 'text', validation: 'email' }]; + } else { + work_email = ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }]; + } + + if (this.checkPermission('Edit Country') === 'Yes') { + country = ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }]; + } else { + country = ['country', { label: 'Country', type: 'placeholder', 'remote-source': ['Country', 'code', 'name'] }]; + } + + const fields = [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + employee_id, + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], + ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], + ssn_num, + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + employment_status, + job_title, + pay_grade, + ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], + ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], + ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], + ['city', { label: 'City', type: 'text', validation: 'none' }], + country, + ['province', { + label: 'Province', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'], + }], + ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + work_email, + ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], + joined_date, + department, + ]; + + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + + for (let i = 0; i < fields.length; i++) { + const tempField = fields[i]; + if (this.hiddenFields[tempField[0]] === undefined || this.hiddenFields[tempField[0]] === null) { + if (this.fieldNameMap[tempField[0]] !== undefined && this.fieldNameMap[tempField[0]] !== null) { + const title = this.fieldNameMap[tempField[0]].textMapped; + tempField[1].label = title; + } + newFields.push(tempField); + } + } + + return newFields; + } + + getSourceMapping() { + const k = this.sourceMapping; + k.supervisor = ['Employee', 'id', 'first_name+last_name']; + return k; + } + + + get() { + const sourceMappingJson = JSON.stringify(this.getSourceMapping()); + + const req = { map: sourceMappingJson }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'modEmployeeGetSuccessCallBack'; + callBackData.callBackFail = 'modEmployeeGetFailCallBack'; + + this.customAction('get', 'modules=employees', reqJson, callBackData); + } + + deleteProfileImage(empId) { + const req = { id: empId }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'modEmployeeDeleteProfileImageCallBack'; + callBackData.callBackFail = 'modEmployeeDeleteProfileImageCallBack'; + + this.customAction('deleteProfileImage', 'modules=employees', reqJson, callBackData); + } + + modEmployeeDeleteProfileImageCallBack(data) { + // eslint-disable-next-line no-restricted-globals + top.location.href = top.location.href; + } + + modEmployeeGetSuccessCallBack(data) { + const fields = this.getFormFields(); + const currentEmpId = data[1]; + const userEmpId = data[2]; + [data] = data; + let html = this.getCustomTemplate('myDetails.html'); + + for (let i = 0; i < fields.length; i++) { + if (this.fieldNameMap[fields[i][0]] !== undefined && this.fieldNameMap[fields[i][0]] !== null) { + const title = this.fieldNameMap[fields[i][0]].textMapped; + html = html.replace(`#_label_${fields[i][0]}_#`, this.gt(title)); + } + } + + html = html.replace(/#_.+_#/gi, ''); + + html = html.replace(/_id_/g, data.id); + + $(`#${this.getTableName()}`).html(html); + + for (let i = 0; i < fields.length; i++) { + $(`#${this.getTableName()} #${fields[i][0]}`).html(data[fields[i][0]]); + $(`#${this.getTableName()} #${fields[i][0]}_Name`).html(data[`${fields[i][0]}_Name`]); + } + + $(`#${this.getTableName()} #supervisor_Name`).html(data.supervisor_Name); + + let subordinates = ''; + for (let i = 0; i < data.subordinates.length; i++) { + if (data.subordinates[i].first_name !== undefined && data.subordinates[i].first_name !== null) { + subordinates += `${data.subordinates[i].first_name} `; + } + + if (data.subordinates[i].middle_name !== undefined && data.subordinates[i].middle_name !== null && data.subordinates[i].middle_name !== '') { + subordinates += `${data.subordinates[i].middle_name} `; + } + + if (data.subordinates[i].last_name !== undefined && data.subordinates[i].last_name !== null && data.subordinates[i].last_name !== '') { + subordinates += data.subordinates[i].last_name; + } + subordinates += '
    '; + } + + // Add custom fields + if (data.customFields !== undefined && data.customFields !== null && Object.keys(data.customFields).length > 0) { + const ct = '
    '; + + const sectionTemplate = '

    #_section.name_#

    '; + let customFieldHtml; + for (const index in data.customFields) { + if (!data.customFields[index][1]) { + data.customFields[index][1] = this.gt('Other Details'); + } + + let sectionId = data.customFields[index][1].toLocaleLowerCase(); + sectionId = sectionId.replace(' ', '_'); + + if ($(`#cont_${sectionId}`).length <= 0) { + // Add section + let sectionHtml = sectionTemplate; + sectionHtml = sectionHtml.replace('#_section_#', sectionId); + sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); + $('#customFieldsCont').append($(sectionHtml)); + } + + customFieldHtml = ct; + customFieldHtml = customFieldHtml.replace('#_label_#', index); + if (data.customFields[index][2] === 'fileupload') { + customFieldHtml = customFieldHtml.replace( + '#_value_#', + ``, + ); + } else { + customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); + } + $(`#cont_${sectionId}`).append($(customFieldHtml)); + } + } else { + $('#customFieldsCont').remove(); + } + + $(`#${this.getTableName()} #subordinates`).html(subordinates); + + + $(`#${this.getTableName()} #name`).html(`${data.first_name} ${data.last_name}`); + this.currentUserId = data.id; + + $(`#${this.getTableName()} #profile_image_${data.id}`).attr('src', data.image); + + if (this.checkPermission('Upload/Delete Profile Image') === 'No') { + $('#employeeUploadProfileImage').remove(); + $('#employeeDeleteProfileImage').remove(); + } + + if (this.checkPermission('Edit Employee Details') === 'No') { + $('#employeeProfileEditInfo').remove(); + } + + if (currentEmpId !== userEmpId) { + $('#employeeUpdatePassword').remove(); + } + + this.cancel(); + } + + modEmployeeGetFailCallBack(data) { + + } + + editEmployee() { + this.edit(this.currentUserId); + } + + changePassword() { + $('#adminUsersModel').modal('show'); + $('#adminUsersChangePwd #newpwd').val(''); + $('#adminUsersChangePwd #conpwd').val(''); + } + + changePasswordConfirm() { + $('#adminUsersChangePwd_error').hide(); + + const passwordValidation = function (str) { + return str.length > 7; + }; + + const password = $('#adminUsersChangePwd #newpwd').val(); + + if (!passwordValidation(password)) { + $('#adminUsersChangePwd_error').html('Password should be longer than 7 characters'); + $('#adminUsersChangePwd_error').show(); + return; + } + + const conPassword = $('#adminUsersChangePwd #conpwd').val(); + + if (conPassword !== password) { + $('#adminUsersChangePwd_error').html("Passwords don't match"); + $('#adminUsersChangePwd_error').show(); + return; + } + + const req = { pwd: conPassword }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'changePasswordSuccessCallBack'; + callBackData.callBackFail = 'changePasswordFailCallBack'; + + this.customAction('changePassword', 'modules=employees', reqJson, callBackData); + } + + closeChangePassword() { + $('#adminUsersModel').modal('hide'); + } + + changePasswordSuccessCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Password Change', 'Password changed successfully'); + } + + changePasswordFailCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Error', callBackData); + } +} + + +/* + * Company Graph + */ + +class CompanyStructureAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'title', + 'address', + 'type', + 'country', + 'parent', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Address' }, + { sTitle: 'Type' }, + { sTitle: 'Country', sClass: 'center' }, + { sTitle: 'Parent Structure' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['title', { label: 'Name', type: 'text', validation: '' }], + ['description', { label: 'Details', type: 'textarea', validation: '' }], + ['address', { label: 'Address', type: 'textarea', validation: 'none' }], + ['type', { label: 'Type', type: 'select', source: [['Company', 'Company'], ['Head Office', 'Head Office'], ['Regional Office', 'Regional Office'], ['Department', 'Department'], ['Unit', 'Unit'], ['Sub Unit', 'Sub Unit'], ['Other', 'Other']] }], + ['country', { label: 'Country', type: 'select', 'remote-source': ['Country', 'code', 'name'] }], + ['parent', { + label: 'Parent Structure', type: 'select', 'allow-null': true, 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ]; + } +} + + +class CompanyGraphAdapter extends CompanyStructureAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.nodeIdCounter = 0; + } + + convertToTree(data) { + const ice = {}; + ice.id = -1; + ice.title = ''; + ice.name = ''; + ice.children = []; + + let parent = null; + + const added = {}; + + + for (let i = 0; i < data.length; i++) { + data[i].name = data[i].title; + + if (data[i].parent !== null && data[i].parent !== undefined) { + parent = this.findParent(data, data[i].parent); + if (parent !== null) { + if (parent.children === undefined || parent.children === null) { + parent.children = []; + } + parent.children.push(data[i]); + } + } + } + + for (let i = 0; i < data.length; i++) { + if (data[i].parent === null || data[i].parent === undefined) { + ice.children.push(data[i]); + } + } + + return ice; + } + + + findParent(data, parent) { + for (let i = 0; i < data.length; i++) { + if (data[i].title === parent || data[i].title === parent) { + return data[i]; + } + } + return null; + } + + + createTable(elementId) { + $('#tabPageCompanyGraph').html(''); + const that = this; + // eslint-disable-next-line prefer-destructuring + const sourceData = this.sourceData; + + // this.fixCyclicParent(sourceData); + const treeData = this.convertToTree(sourceData); + + const m = [20, 120, 20, 120]; + + + const w = 5000 - m[1] - m[3]; + + + const h = 1000 - m[0] - m[2]; + + const tree = d3.layout.tree() + .size([h, w]); + + this.diagonal = d3.svg.diagonal() + .projection(d => [d.y, d.x]); + + this.vis = d3.select('#tabPageCompanyGraph').append('svg:svg') + .attr('width', w + m[1] + m[3]) + .attr('height', h + m[0] + m[2]) + .append('svg:g') + .attr('transform', `translate(${m[3]},${m[0]})`); + + const root = treeData; + root.x0 = h / 2; + root.y0 = 0; + + function toggleAll(d) { + if (d.children) { + console.log(d.name); + d.children.forEach(toggleAll); + that.toggle(d); + } + } + this.update(root, tree, root); + } + + update(source, tree, root) { + const that = this; + const duration = d3.event && d3.event.altKey ? 5000 : 500; + + // Compute the new tree layout. + const nodes = tree.nodes(root).reverse(); + + // Normalize for fixed-depth. + nodes.forEach((d) => { d.y = d.depth * 180; }); + + // Update the nodes� + const node = that.vis.selectAll('g.node') + // eslint-disable-next-line no-return-assign + .data(nodes, d => d.id || (d.id = ++that.nodeIdCounter)); + + // Enter any new nodes at the parent's previous position. + const nodeEnter = node.enter().append('svg:g') + .attr('class', 'node') + .attr('transform', d => `translate(${source.y0},${source.x0})`) + .on('click', (d) => { that.toggle(d); that.update(d, tree, root); }); + + nodeEnter.append('svg:circle') + .attr('r', 1e-6) + // eslint-disable-next-line no-underscore-dangle + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeEnter.append('svg:text') + .attr('x', d => (d.children || d._children ? -10 : 10)) + .attr('dy', '.35em') + .attr('text-anchor', d => (d.children || d._children ? 'end' : 'start')) + .text(d => d.name) + .style('fill-opacity', 1e-6); + + // Transition nodes to their new position. + const nodeUpdate = node.transition() + .duration(duration) + .attr('transform', d => `translate(${d.y},${d.x})`); + + nodeUpdate.select('circle') + .attr('r', 4.5) + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeUpdate.select('text') + .style('fill-opacity', 1); + + // Transition exiting nodes to the parent's new position. + const nodeExit = node.exit().transition() + .duration(duration) + .attr('transform', d => `translate(${source.y},${source.x})`) + .remove(); + + nodeExit.select('circle') + .attr('r', 1e-6); + + nodeExit.select('text') + .style('fill-opacity', 1e-6); + + // Update the links� + const link = that.vis.selectAll('path.link') + .data(tree.links(nodes), d => d.target.id); + + // Enter any new links at the parent's previous position. + link.enter().insert('svg:path', 'g') + .attr('class', 'link') + .attr('d', (d) => { + const o = { x: source.x0, y: source.y0 }; + return that.diagonal({ source: o, target: o }); + }) + .transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition links to their new position. + link.transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition exiting nodes to the parent's new position. + link.exit().transition() + .duration(duration) + .attr('d', (d) => { + const o = { x: source.x, y: source.y }; + return that.diagonal({ source: o, target: o }); + }) + .remove(); + + // Stash the old positions for transition. + nodes.forEach((d) => { + d.x0 = d.x; + d.y0 = d.y; + }); + } + + // Toggle children. + toggle(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + } + + + getSourceDataById(id) { + for (let i = 0; i < this.sourceData.length; i++) { + if (this.sourceData[i].id === id) { + return this.sourceData[i]; + } + } + + return null; + } + + fixCyclicParent(sourceData) { + let errorMsg = ''; + for (let i = 0; i < sourceData.length; i++) { + const obj = sourceData[i]; + + + let curObj = obj; + const parentIdArr = {}; + parentIdArr[curObj.id] = 1; + + while (curObj.parent != null && curObj.parent !== undefined) { + const parent = this.getSourceDataById(curObj.parent); + if (parent == null) { + break; + } else if (parentIdArr[parent.id] === 1) { + errorMsg = `${obj.title}'s parent structure set to ${parent.title}
    `; + obj.parent = null; + break; + } + parentIdArr[parent.id] = 1; + curObj = parent; + } + } + + if (errorMsg !== '') { + this.showMessage('Company Structure is having a cyclic dependency', `We found a cyclic dependency due to following reasons:
    ${errorMsg}`); + return false; + } + + return true; + } +} + + +/* + * Api Access + */ + +class ApiAccessAdapter extends AdapterBase { + getDataMapping() { + return [ + ]; + } + + getHeaders() { + return [ + + ]; + } + + getFormFields() { + return [ + ]; + } + + setApiUrl(apiUrl) { + this.apiUrl = apiUrl;`` + } + + setToken(token) { + this.token = token; + } + + get() { + const canvas = document.getElementById('apiQRcode'); + QRCode.toCanvas(canvas, JSON.stringify({ + key: 'IceHrm', + url: this.apiUrl, + token: this.token, + }), (error) => { + if (error) { + console.log(error); + } + }); + } +} + + +module.exports = { + EmployeeAdapter, + CompanyGraphAdapter, + ApiAccessAdapter, +}; diff --git a/web/modules/src/loans/index.js b/web/modules/src/loans/index.js new file mode 100644 index 00000000..57ce87e4 --- /dev/null +++ b/web/modules/src/loans/index.js @@ -0,0 +1,5 @@ +import { + EmployeeCompanyLoanAdapter, +} from './lib'; + +window.EmployeeCompanyLoanAdapter = EmployeeCompanyLoanAdapter; diff --git a/web/modules/src/loans/lib.js b/web/modules/src/loans/lib.js new file mode 100644 index 00000000..fc9b3a9f --- /dev/null +++ b/web/modules/src/loans/lib.js @@ -0,0 +1,89 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +class EmployeeCompanyLoanAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'loan', + 'start_date', + 'period_months', + 'currency', + 'amount', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Loan Type' }, + { sTitle: 'Loan Start Date' }, + { sTitle: 'Loan Period (Months)' }, + { sTitle: 'Currency' }, + { sTitle: 'Amount' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['loan', { label: 'Loan Type', type: 'placeholder', 'remote-source': ['CompanyLoan', 'id', 'name'] }], + ['start_date', { label: 'Loan Start Date', type: 'placeholder', validation: '' }], + ['last_installment_date', { label: 'Last Installment Date', type: 'placeholder', validation: 'none' }], + ['period_months', { label: 'Loan Period (Months)', type: 'placeholder', validation: 'number' }], + ['currency', { label: 'Currency', type: 'placeholder', 'remote-source': ['CurrencyType', 'id', 'name'] }], + ['amount', { label: 'Loan Amount', type: 'placeholder', validation: 'float' }], + ['monthly_installment', { label: 'Monthly Installment', type: 'placeholder', validation: 'float' }], + ['status', + { + label: 'Status', + type: 'placeholder', + source: [['Approved', 'Approved'], ['Paid', 'Paid'], ['Suspended', 'Suspended']], + }, + ], + ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], + ]; + } + + + // eslint-disable-next-line no-unused-vars + getActionButtonsHtml(id, data) { + const editButton = '' + + ''; + + const deleteButton = '' + + ''; + let html = '
    _edit__delete_
    '; + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + +module.exports = { EmployeeCompanyLoanAdapter }; diff --git a/web/modules/src/overtime/index.js b/web/modules/src/overtime/index.js new file mode 100644 index 00000000..b65af806 --- /dev/null +++ b/web/modules/src/overtime/index.js @@ -0,0 +1,9 @@ +import { + EmployeeOvertimeAdapter, + EmployeeOvertimeApproverAdapter, + SubordinateEmployeeOvertimeAdapter, +} from './lib'; + +window.EmployeeOvertimeAdapter = EmployeeOvertimeAdapter; +window.EmployeeOvertimeApproverAdapter = EmployeeOvertimeApproverAdapter; +window.SubordinateEmployeeOvertimeAdapter = SubordinateEmployeeOvertimeAdapter; diff --git a/web/modules/src/overtime/lib.js b/web/modules/src/overtime/lib.js new file mode 100644 index 00000000..dc43a9bf --- /dev/null +++ b/web/modules/src/overtime/lib.js @@ -0,0 +1,134 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import ApproveModuleAdapter from '../../../api/ApproveModuleAdapter'; + +import { + EmployeeOvertimeAdminAdapter, +} from '../../../admin/src/overtime/lib'; + + +class EmployeeOvertimeAdapter extends ApproveModuleAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'Overtime'; + this.itemNameLower = 'employeeovertime'; + this.modulePathName = 'overtime'; + } + + getDataMapping() { + return [ + 'id', + 'category', + 'start_time', + 'end_time', + 'project', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Category' }, + { sTitle: 'Start Time' }, + { sTitle: 'End Time' }, + { sTitle: 'Project' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['category', { + label: 'Category', type: 'select2', 'allow-null': false, 'remote-source': ['OvertimeCategory', 'id', 'name'], + }], + ['start_time', { label: 'Start Time', type: 'datetime', validation: '' }], + ['end_time', { label: 'End Time', type: 'datetime', validation: '' }], + ['project', { + label: 'Project', + type: 'select2', + 'allow-null': true, + 'null=label': 'none', + 'remote-source': ['Project', 'id', 'name'], + }], + ['notes', { label: 'Notes', type: 'textarea', validation: 'none' }], + ]; + } +} + +/* + EmployeeOvertimeApproverAdapter + */ + +class EmployeeOvertimeApproverAdapter extends EmployeeOvertimeAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'Overtime'; + this.itemNameLower = 'employeeovertime'; + this.modulePathName = 'overtime'; + } + + getActionButtonsHtml(id, data) { + const statusChangeButton = '' + + ''; + + const viewLogsButton = ''; + + let html = '
    _status__logs_
    '; + + + html = html.replace('_logs_', viewLogsButton); + + + if (data[this.getStatusFieldPosition()] === 'Processing') { + html = html.replace('_status_', statusChangeButton); + } else { + html = html.replace('_status_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); + return html; + } + + getStatusOptionsData(currentStatus) { + const data = {}; + if (currentStatus === 'Processing') { + data.Approved = 'Approved'; + data.Rejected = 'Rejected'; + } + + return data; + } + + getStatusOptions(currentStatus) { + return this.generateOptions(this.getStatusOptionsData(currentStatus)); + } +} + + +/* + EmployeeOvertimeAdapter + */ + +class SubordinateEmployeeOvertimeAdapter extends EmployeeOvertimeAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'Overtime'; + this.itemNameLower = 'employeeovertime'; + this.modulePathName = 'overtime'; + } +} + +module.exports = { + EmployeeOvertimeAdapter, + EmployeeOvertimeApproverAdapter, + SubordinateEmployeeOvertimeAdapter, +}; diff --git a/web/modules/src/projects/index.js b/web/modules/src/projects/index.js new file mode 100644 index 00000000..ba5c00ad --- /dev/null +++ b/web/modules/src/projects/index.js @@ -0,0 +1,5 @@ +import { + EmployeeProjectAdapter, +} from './lib'; + +window.EmployeeProjectAdapter = EmployeeProjectAdapter; diff --git a/web/modules/src/projects/lib.js b/web/modules/src/projects/lib.js new file mode 100644 index 00000000..a0d50644 --- /dev/null +++ b/web/modules/src/projects/lib.js @@ -0,0 +1,32 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +class EmployeeProjectAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'project', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Project' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['project', { label: 'Project', type: 'select2', 'remote-source': ['Project', 'id', 'name'] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + +module.exports = { EmployeeProjectAdapter }; diff --git a/web/modules/src/qualifications/index.js b/web/modules/src/qualifications/index.js new file mode 100644 index 00000000..4617ab6a --- /dev/null +++ b/web/modules/src/qualifications/index.js @@ -0,0 +1,11 @@ +import { + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, +} from './lib'; + +window.EmployeeSkillAdapter = EmployeeSkillAdapter; +window.EmployeeEducationAdapter = EmployeeEducationAdapter; +window.EmployeeCertificationAdapter = EmployeeCertificationAdapter; +window.EmployeeLanguageAdapter = EmployeeLanguageAdapter; diff --git a/web/modules/src/qualifications/lib.js b/web/modules/src/qualifications/lib.js new file mode 100644 index 00000000..36945e6f --- /dev/null +++ b/web/modules/src/qualifications/lib.js @@ -0,0 +1,160 @@ +import AdapterBase from '../../../api/AdapterBase'; + +class EmployeeSkillAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'skill_id', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Skill' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } +} + +/** + * EmployeeEducationAdapter + */ + +class EmployeeEducationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'education_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Qualification' }, + { sTitle: 'Institute' }, + { sTitle: 'Start Date' }, + { sTitle: 'Completed On' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], + ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }], + ]; + } +} + +/** + * EmployeeCertificationAdapter + */ + +class EmployeeCertificationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'certification_id', + 'institute', + 'date_start', + 'date_start', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Certification' }, + { sTitle: 'Institute' }, + { sTitle: 'Granted On' }, + { sTitle: 'Valid Thru' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], + ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }], + ]; + } +} + + +/** + * EmployeeLanguageAdapter + */ + +class EmployeeLanguageAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'language_id', + 'reading', + 'speaking', + 'writing', + 'understanding', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Language' }, + { sTitle: 'Reading' }, + { sTitle: 'Speaking' }, + { sTitle: 'Writing' }, + { sTitle: 'Understanding' }, + ]; + } + + getFormFields() { + const compArray = [['Elementary Proficiency', 'Elementary Proficiency'], + ['Limited Working Proficiency', 'Limited Working Proficiency'], + ['Professional Working Proficiency', 'Professional Working Proficiency'], + ['Full Professional Proficiency', 'Full Professional Proficiency'], + ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'description'], + }], + ['reading', { label: 'Reading', type: 'select', source: compArray }], + ['speaking', { label: 'Speaking', type: 'select', source: compArray }], + ['writing', { label: 'Writing', type: 'select', source: compArray }], + ['understanding', { label: 'Understanding', type: 'select', source: compArray }], + ]; + } +} + +module.exports = { + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, +}; diff --git a/web/modules/src/reports/index.js b/web/modules/src/reports/index.js new file mode 100644 index 00000000..2fad18f8 --- /dev/null +++ b/web/modules/src/reports/index.js @@ -0,0 +1,5 @@ +import { + UserReportAdapter, +} from './lib'; + +window.UserReportAdapter = UserReportAdapter; diff --git a/web/modules/src/reports/lib.js b/web/modules/src/reports/lib.js new file mode 100644 index 00000000..8f4ce10a --- /dev/null +++ b/web/modules/src/reports/lib.js @@ -0,0 +1,32 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import { + ReportAdapter, +} from '../../../admin/src/reports/lib'; + + +/** + * UserReportAdapter + */ + +class UserReportAdapter extends ReportAdapter { + renderForm(object) { + const that = this; + this.processFormFieldsWithObject(object); + if (this.remoteFieldsExists) { + const cb = function () { + that.renderFormNew(object); + }; + this.initFieldMasterData(cb); + } else { + this.initFieldMasterData(); + that.renderFormNew(object); + } + + this.currentReport = object; + } +} + +module.exports = { UserReportAdapter }; diff --git a/web/modules/src/salary/index.js b/web/modules/src/salary/index.js new file mode 100644 index 00000000..da61ae36 --- /dev/null +++ b/web/modules/src/salary/index.js @@ -0,0 +1,5 @@ +import { + EmployeeSalaryAdapter, +} from './lib'; + +window.EmployeeSalaryAdapter = EmployeeSalaryAdapter; diff --git a/web/modules/src/salary/lib.js b/web/modules/src/salary/lib.js new file mode 100644 index 00000000..4c7850cf --- /dev/null +++ b/web/modules/src/salary/lib.js @@ -0,0 +1,36 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +class EmployeeSalaryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'component', + 'amount', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Salary Component' }, + { sTitle: 'Amount' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['component', { label: 'Salary Component', type: 'select2', 'remote-source': ['SalaryComponent', 'id', 'name'] }], + ['amount', { label: 'Amount', type: 'text', validation: 'float' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + +module.exports = { EmployeeSalaryAdapter }; diff --git a/web/modules/src/staffdirectory/index.js b/web/modules/src/staffdirectory/index.js new file mode 100644 index 00000000..63adbbd1 --- /dev/null +++ b/web/modules/src/staffdirectory/index.js @@ -0,0 +1,7 @@ +import { + StaffDirectoryAdapter, + StaffDirectoryObjectAdapter, +} from './lib'; + +window.StaffDirectoryAdapter = StaffDirectoryAdapter; +window.StaffDirectoryObjectAdapter = StaffDirectoryObjectAdapter; diff --git a/web/modules/src/staffdirectory/lib.js b/web/modules/src/staffdirectory/lib.js new file mode 100644 index 00000000..bcdda526 --- /dev/null +++ b/web/modules/src/staffdirectory/lib.js @@ -0,0 +1,173 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; +import ObjectAdapter from '../../../api/ObjectAdapter'; + +class StaffDirectoryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'image', + 'first_name', + 'last_name', + 'job_title', + 'department', + 'work_phone', + 'work_email', + 'joined_date', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Job Title' }, + { sTitle: 'Department' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Work Email' }, + { sTitle: 'Joined Date' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ]; + } + + showActionButtons() { + return false; + } + + + getCustomTableParams() { + const that = this; + const dataTableParams = { + aoColumnDefs: [ + { + fnRender(data, cell) { + try { + return that.preProcessRemoteTableData(data, cell, 1); + } catch (e) { return cell; } + }, + aTargets: [1], + }, + { + fnRender(data, cell) { + try { + return that.preProcessRemoteTableData(data, cell, 8); + } catch (e) { return cell; } + }, + aTargets: [8], + }, + ], + }; + return dataTableParams; + } + + // eslint-disable-next-line consistent-return + preProcessRemoteTableData(data, cell, id) { + if (id === 8) { + if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { + return ''; + } + return Date.parse(cell).toString('yyyy MMM d'); + } if (id === 1) { + const tmp = 'User Image'; + return tmp.replace('_img_', cell); + } + } +} + + +/* + StaffDirectoryObjectAdapter + */ + + +class StaffDirectoryObjectAdapter extends ObjectAdapter { + getDataMapping() { + return [ + 'id', + 'image', + 'first_name', + 'last_name', + 'job_title', + 'department', + 'work_phone', + 'work_email', + 'joined_date', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Job Title' }, + { sTitle: 'Department' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Work Email' }, + { sTitle: 'Joined Date' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ]; + } + + // eslint-disable-next-line no-unused-vars + addDomEvents(object) { + + } + + getTemplateName() { + return 'element.html'; + } + + preProcessTableData(_row) { + const row = _row; + row.color = this.getColorByRandomString(row.first_name); + return row; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ]; + } +} + + +module.exports = { + StaffDirectoryAdapter, + StaffDirectoryObjectAdapter, +}; diff --git a/web/modules/src/time_sheets/index.js b/web/modules/src/time_sheets/index.js new file mode 100644 index 00000000..bd00308f --- /dev/null +++ b/web/modules/src/time_sheets/index.js @@ -0,0 +1,11 @@ +import { + EmployeeTimeSheetAdapter, + SubEmployeeTimeSheetAdapter, + EmployeeTimeEntryAdapter, + QtsheetAdapter, +} from './lib'; + +window.EmployeeTimeSheetAdapter = EmployeeTimeSheetAdapter; +window.SubEmployeeTimeSheetAdapter = SubEmployeeTimeSheetAdapter; +window.EmployeeTimeEntryAdapter = EmployeeTimeEntryAdapter; +window.QtsheetAdapter = QtsheetAdapter; diff --git a/web/modules/src/time_sheets/lib.js b/web/modules/src/time_sheets/lib.js new file mode 100644 index 00000000..df98052a --- /dev/null +++ b/web/modules/src/time_sheets/lib.js @@ -0,0 +1,948 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/* global modJs, modJsList, moment */ +import AdapterBase from '../../../api/AdapterBase'; +import FormValidation from '../../../api/FormValidation'; +import TableEditAdapter from '../../../api/TableEditAdapter'; + +const ValidationRules = FormValidation.getValidationRules(); + +class EmployeeTimeSheetAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.currentTimesheetId = null; + this.currentTimesheet = null; + this.needStartEndTime = false; + } + + getDataMapping() { + return [ + 'id', + 'date_start', + 'date_end', + 'total_time', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Start Date' }, + { sTitle: 'End Date' }, + { sTitle: 'Total Time' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], + ['date_end', { label: 'TimeSheet End Date', type: 'date', validation: '' }], + ['details', { label: 'Reason', type: 'textarea', validation: 'none' }], + ]; + } + + preProcessTableData(_row) { + const row = _row; + row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); + row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); + return row; + } + + setNeedStartEndTime(status) { + this.needStartEndTime = status; + } + + renderForm(object) { + const formHtml = this.templates.formTemplate; + + $('#EmployeeTimesheetBlock').remove(); + $(`#${this.getTableName()}Form`).html(formHtml); + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + $('.timesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); + $('.timesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); + + this.currentTimesheet = object; + + this.getTimeEntries(); + + const st = Date.parse(object.date_start); + + $('#EmployeeTimesheetBlock').fullCalendar({ + header: { + // left: 'prev,next today', + left: false, + // center: 'title', + center: false, + // right: 'month,agendaWeek,agendaDay' + right: false, + }, + year: st.toString('yyyy'), + month: st.toString('M'), + date: st.toString('d'), + + defaultView: 'basicWeek', + height: 200, + editable: false, + + events: modJs.getScheduleJsonUrl(this.currentTimesheet.employee), + + loading(bool) { + if (bool) $('#loadingBlock').show(); + else $('#loadingBlock').hide(); + }, + + // eslint-disable-next-line no-unused-vars + dayClick(date, jsEvent, view, resourceObj) { + modJs.renderFormByDate(date.format()); + }, + + // eslint-disable-next-line no-unused-vars + eventClick(calEvent, jsEvent, view) { + modJs.renderFormTimeEntryCalender(calEvent.id); + }, + eventRender(event, element) { + element.find('.fc-time').remove(); + }, + }); + + $('#EmployeeTimesheetBlock').fullCalendar('gotoDate', st); + + $('.fc-toolbar').hide(); + } + + + quickEdit(id, status, sdate, edate) { + $('#Qtsheet').data('lastActiveTab', modJs.tab); + // eslint-disable-next-line no-global-assign + modJs = modJsList.tabQtsheet; + modJs.setCurrentTimeSheetId(id); + + $('.timesheet_start').html(sdate); + $('.timesheet_end').html(edate); + + $('#timesheetTabs').find('.active').find('.reviewBlock.reviewBlockTable').hide(); + $('#QtsheetHeader').show(); + $('#Qtsheet').show(); + $('#QtsheetDataButtons').show(); + + if (status === 'Submitted' || status === 'Approved') { + $('.completeBtnTable').hide(); + $('.saveBtnTable').hide(); + } else { + $('.completeBtnTable').show(); + $('.saveBtnTable').show(); + } + + modJs.get([]); + } + + + getScheduleJsonUrl(employeeId) { + const url = `${this.moduleRelativeURL}?a=ca&sa=getEmployeeTimeEntries&t=${this.table}&mod=modules%3Dtime_sheets&e=${employeeId}`; + return url; + } + + + renderFormByDate(_date) { + let date = _date; + + if (date.indexOf('T') < 0) { + const s1 = moment(); + date = `${date} ${s1.format('HH:mm:ss')}`; + } + + const start = date.replace('T', ' '); + const m1 = moment(start); + m1.add(1, 'h'); + const end = m1.format('YYYY-MM-DD HH:mm:ss'); + + const obj = {}; + obj.date = _date; + obj.date_start = start; + obj.date_end = end; + + this.renderFormTimeEntryCalender(obj); + } + + + renderFormTimeEntryCalender(object) { + if (`${this.needStartEndTime}` === '0') { + return; + } + this.openTimeEntryDialog(object); + if (object.id !== undefined && object.id != null) { + const cid = object.id; + $('.deleteBtnWorkSchedule').show(); + $('.deleteBtnWorkSchedule').off().on('click', () => { + modJs.deleteRow(cid); + return false; + }); + } else { + $('.deleteBtnWorkSchedule').remove(); + } + } + + + openTimeEntryDialog(object) { + this.currentTimesheetId = this.currentId; + const obj = modJsList.tabEmployeeTimeEntry; + $('#TimeEntryModel').modal({ + backdrop: 'static', + keyboard: false, + }); + obj.currentTimesheet = this.currentTimesheet; + obj.renderForm(object); + obj.timesheetId = this.currentId; + } + + closeTimeEntryDialog() { + $('#TimeEntryModel').modal('hide'); + } + + + getTimeEntries() { + const timesheetId = this.currentId; + const sourceMappingJson = JSON.stringify(modJsList.tabEmployeeTimeEntry.getSourceMapping()); + const object = { id: timesheetId, sm: sourceMappingJson }; + + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getTimeEntriesSuccessCallBack'; + callBackData.callBackFail = 'getTimeEntriesFailCallBack'; + + this.customAction('getTimeEntries', 'modules=time_sheets', reqJson, callBackData); + } + + getTimeEntriesSuccessCallBack(callBackData) { + const entries = callBackData; + let html = ''; + const temp = '_start__end__duration__project__details_'; + + for (let i = 0; i < entries.length; i++) { + try { + let t = temp; + t = t.replace(/_start_/g, Date.parse(entries[i].date_start).toString('MMM d, yyyy [hh:mm tt]')); + t = t.replace(/_end_/g, Date.parse(entries[i].date_end).toString('MMM d, yyyy [hh:mm tt]')); + + const mili = Date.parse(entries[i].date_end) - Date.parse(entries[i].date_start); + const minutes = Math.round(mili / 60000); + const hourMinutes = (minutes % 60); + const hours = (minutes - hourMinutes) / 60; + + t = t.replace(/_duration_/g, `Hours (${hours}) - Min (${hourMinutes})`); + if (entries[i].project === 'null' || entries[i].project == null || entries[i].project === undefined) { + t = t.replace(/_project_/g, 'None'); + } else { + t = t.replace(/_project_/g, entries[i].project); + } + t = t.replace(/_project_/g, entries[i].project); + t = t.replace(/_details_/g, entries[i].details); + t = t.replace(/_id_/g, entries[i].id); + t = t.replace(/_BASE_/g, this.baseUrl); + html += t; + } catch (e) { + // Do nothing + } + } + + $('.timesheet_entries_table_body').html(html); + if (modJs.getTableName() === 'SubEmployeeTimeSheetAll' || `${this.needStartEndTime}` === '0') { + $('.submit_sheet').hide(); + $('.add_time_sheet_entry').hide(); + } else if (this.currentElement.status === 'Approved') { + $('.submit_sheet').hide(); + $('.add_time_sheet_entry').hide(); + } else { + $('.submit_sheet').show(); + $('.add_time_sheet_entry').show(); + } + + $('#EmployeeTimesheetBlock').fullCalendar('refetchEvents'); + } + + // eslint-disable-next-line no-unused-vars + getTimeEntriesFailCallBack(callBackData) { + this.showMessage('Error', 'Error occured while getting timesheet entries'); + } + + + createPreviousTimesheet(id) { + const object = { id }; + + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'createPreviousTimesheetSuccessCallBack'; + callBackData.callBackFail = 'createPreviousTimesheetFailCallBack'; + + this.customAction('createPreviousTimesheet', 'modules=time_sheets', reqJson, callBackData); + } + + // eslint-disable-next-line no-unused-vars + createPreviousTimesheetSuccessCallBack(callBackData) { + $('.tooltip').css('display', 'none'); + $('.tooltip').remove(); + // this.showMessage("Success", "Previous Timesheet created"); + this.get([]); + } + + createPreviousTimesheetFailCallBack(callBackData) { + this.showMessage('Error', callBackData); + } + + changeTimeSheetStatusWithId(id, status) { + if (status === '' || status == null || status === undefined) { + this.showMessage('Status Error', 'Please select a status'); + return; + } + + const object = { id, status }; + + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'changeTimeSheetStatusSuccessCallBack'; + callBackData.callBackFail = 'changeTimeSheetStatusFailCallBack'; + + this.customAction('changeTimeSheetStatus', 'modules=time_sheets', reqJson, callBackData); + } + + // eslint-disable-next-line no-unused-vars + changeTimeSheetStatusSuccessCallBack(callBackData) { + this.showMessage('Successful', 'Timesheet status changed successfully'); + this.get([]); + } + + // eslint-disable-next-line no-unused-vars + changeTimeSheetStatusFailCallBack(callBackData) { + this.showMessage('Error', 'Error occured while changing Timesheet status'); + } + + + getActionButtonsHtml(id, data) { + let html = ''; + if (`${this.needStartEndTime}` === '0') { + html = '
    ' + + '' + + '' + + '_redoBtn_' + + '
    '; + } else { + html = '
    ' + + '' + + '_redoBtn_' + + '
    '; + } + + if (this.getTableName() === 'EmployeeTimeSheetAll') { + const redoBtn = ''; + html = html.replace(/_redoBtn_/g, redoBtn); + } else { + html = html.replace(/_redoBtn_/g, ''); + } + html = html.replace(/_id_/g, id); + html = html.replace(/_sdate_/g, data[1]); + html = html.replace(/_edate_/g, data[2]); + html = html.replace(/_status_/g, data[4]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getCustomTableParams() { + const that = this; + const dataTableParams = { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 1); + }, + aTargets: [1], + }, + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 2); + }, + aTargets: [2], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + return dataTableParams; + } + + // eslint-disable-next-line no-unused-vars + preProcessRemoteTableData(data, cell, id) { + return Date.parse(cell).toString('MMM d, yyyy (dddd)'); + } +} + + +/* + * Subordinate TimeSheets + */ + +class SubEmployeeTimeSheetAdapter extends EmployeeTimeSheetAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.timeSheetStatusChangeId = null; + } + + getDataMapping() { + return [ + 'id', + 'employee', + 'date_start', + 'date_end', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee', bSearchable: true }, + { sTitle: 'Start Date', bSearchable: true }, + { sTitle: 'End Date', bSearchable: true }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', type: 'select', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], + ['date_end', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], + ['details', { label: 'Reason', type: 'textarea', validation: 'none' }], + ]; + } + + + isSubProfileTable() { + return true; + } + + getCustomSuccessCallBack(serverData) { + const data = []; + const mapping = this.getDataMapping(); + for (let i = 0; i < serverData.length; i++) { + const row = []; + for (let j = 0; j < mapping.length; j++) { + row[j] = serverData[i][mapping[j]]; + } + data.push(this.preProcessTableData(row)); + } + + this.tableData = data; + + this.createTable(this.getTableName()); + $(`#${this.getTableName()}Form`).hide(); + $(`#${this.getTableName()}`).show(); + } + + preProcessTableData(_row) { + const row = _row; + row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); + row[3] = Date.parse(row[3]).toString('MMM d, yyyy (dddd)'); + return row; + } + + openTimeSheetStatus(timeSheetId, status) { + this.currentTimesheetId = timeSheetId; + $('#TimeSheetStatusModel').modal('show'); + $('#timesheet_status').val(status); + this.timeSheetStatusChangeId = timeSheetId; + } + + closeTimeSheetStatus() { + $('#TimeSheetStatusModel').modal('hide'); + } + + changeTimeSheetStatus() { + const timeSheetStatus = $('#timesheet_status').val(); + + this.changeTimeSheetStatusWithId(this.timeSheetStatusChangeId, timeSheetStatus); + + this.closeTimeSheetStatus(); + this.timeSheetStatusChangeId = null; + } + + + getActionButtonsHtml(id, data) { + let html; + + + if (`${this.needStartEndTime}` === '0') { + html = '
    ' + + '' + + '' + + '' + + '
    '; + } else { + html = '
    ' + + '' + + '' + + '
    '; + } + + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + html = html.replace(/_sdate_/g, data[1]); + html = html.replace(/_edate_/g, data[2]); + html = html.replace(/_status_/g, data[4]); + return html; + } + + + getCustomTableParams() { + const that = this; + const dataTableParams = { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 2); + }, + aTargets: [2], + }, + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 3); + }, + aTargets: [3], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + return dataTableParams; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': true, 'null-label': 'All Employees', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['status', { + label: 'Status', type: 'select', 'allow-null': true, 'null-label': 'All', source: [['Submitted', 'Submitted'], ['Pending', 'Pending'], ['Approved', 'Approved'], ['Rejected', 'Rejected']], + }], + ]; + } +} + + +/** + * EmployeeTimeEntryAdapter + */ + +class EmployeeTimeEntryAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.timesheetId = null; + this.currentTimesheet = null; + this.allProjectsAllowed = 1; + this.employeeProjects = []; + } + + getDataMapping() { + return [ + 'id', + 'project', + 'date_start', + 'time_start', + 'date_end', + 'time_end', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Project' }, + { sTitle: 'Start Date' }, + { sTitle: 'Start Time' }, + { sTitle: 'End Date' }, + { sTitle: 'End Time' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['project', { + label: 'Project', type: 'select2', 'allow-null': false, 'remote-source': ['Project', 'id', 'name', 'getEmployeeProjects'], + }], + ['date_select', { label: 'Date', type: 'select', source: [] }], + ['date_start', { label: 'Start Time', type: 'time', validation: '' }], + ['date_end', { label: 'End Time', type: 'time', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } + + + getDates(startDate, stopDate) { + const dateArray = []; + let currentDate = startDate; + while (currentDate <= stopDate) { + dateArray.push(new Date(currentDate)); + currentDate = currentDate.add({ days: 1 }); + } + return dateArray; + } + + + renderForm(object) { + let formHtml = this.getCustomTemplate('time_entry_form.html'); + formHtml = formHtml.replace(/modJs/g, "modJsList['tabEmployeeTimeEntry']"); + let html = ''; + const fields = this.getFormFields(); + + for (let i = 0; i < fields.length; i++) { + const metaField = this.getMetaFieldForRendering(fields[i][0]); + if (metaField === '' || metaField === undefined) { + html += this.renderFormField(fields[i]); + } else { + const metaVal = object[metaField]; + if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { + html += this.renderFormField(JSON.parse(metaVal)); + } else { + html += this.renderFormField(fields[i]); + } + } + } + + // append dates + + // var dateStart = new Date(this.currentTimesheet.date_start); + // var dateStop = new Date(this.currentTimesheet.date_end); + + // var datesArray = this.getDates(dateStart, dateStop); + + let optionList = ''; + for (let i = 0; i < this.currentTimesheet.days.length; i++) { + const k = this.currentTimesheet.days[i]; + // optionList += ''; + optionList += ``; + } + + + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_submit`); + formHtml = formHtml.replace(/_fields_/g, html); + $(`#${this.getTableName()}Form`).html(formHtml); + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + $(`#${this.getTableName()}Form .datefield`).datepicker({ viewMode: 2 }); + $(`#${this.getTableName()}Form .datetimefield`).datetimepicker({ + language: 'en', + }); + $(`#${this.getTableName()}Form .timefield`).datetimepicker({ + language: 'en', + pickDate: false, + }); + + $(`#${this.getTableName()}Form .select2Field`).select2(); + + $('#date_select').html(optionList); + + + if (object !== undefined && object != null) { + this.fillForm(object); + } + } + + + // eslint-disable-next-line no-unused-vars + fillForm(object, _formId, fields) { + let formId = _formId; + if (formId == null || formId === undefined || formId === '') { + formId = `#${this.getTableName()}Form`; + } + + if (object.id != null && object.id !== undefined) { + $(`${formId} #id`).val(object.id); + } + + if (object.project != null && object.project !== undefined) { + $(`${formId} #project`).select2('val', object.project); + } + + if (object.date != null && object.date !== undefined) { + $(`${formId} #date_select`).val(object.date); + } + } + + + cancel() { + $('#TimeEntryModel').modal('hide'); + } + + setAllProjectsAllowed(allProjectsAllowed) { + this.allProjectsAllowed = allProjectsAllowed; + } + + setEmployeeProjects(employeeProjects) { + this.employeeProjects = employeeProjects; + } + + + save() { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + + if (validator.checkValues()) { + const params = validator.getFormParameters(); + params.timesheet = this.timesheetId; + + params.time_start = params.date_start; + params.time_end = params.date_end; + + params.date_start = `${params.date_select} ${params.date_start}`; + params.date_end = `${params.date_select} ${params.date_end}`; + + + const msg = this.doCustomValidation(params); + + if (msg == null) { + const id = $(`#${this.getTableName()}_submit #id`).val(); + if (id != null && id !== undefined && id !== '') { + params.id = id; + } + this.add(params, []); + this.cancel(); + } else { + $(`#${this.getTableName()}Form .label`).html(msg); + $(`#${this.getTableName()}Form .label`).show(); + } + } + } + + doCustomValidation(params) { + const st = Date.parse(params.date_start); + const et = Date.parse(params.date_end); + if (st.compareTo(et) !== -1) { + return 'Start time should be less than End time'; + } + /* + var sd = Date.parse(this.currentTimesheet.date_start); + var ed = Date.parse(this.currentTimesheet.date_end).addDays(1); + + if(sd.compareTo(et) != -1 || sd.compareTo(st) > 0 || st.compareTo(ed) != -1 || et.compareTo(ed) != -1){ + return "Start time and end time shoud be with in " + sd.toString('MMM d, yyyy (dddd)') + " and " + ed.toString('MMM d, yyyy (dddd)'); + } + */ + return null; + } + + // eslint-disable-next-line no-unused-vars + addSuccessCallBack(callBackData, serverData) { + this.get(callBackData); + modJs.getTimeEntries(); + } + + deleteRow(id) { + this.deleteObj(id, []); + } + + // eslint-disable-next-line no-unused-vars + deleteSuccessCallBack(callBackData, serverData) { + modJs.getTimeEntries(); + } +} + + +/** + * QtsheetAdapter + */ + +class QtsheetAdapter extends TableEditAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.cellDataUpdates = {}; + this.currentId = null; + } + + validateCellValue(element, evt, newValue) { + if (!ValidationRules.float(newValue)) { + return false; + } + const val = parseFloat(newValue); + if (val < 0 || val > 24) { + return false; + } + + // Update total + // Find current column number + // Adding 2 because nth child is based on 1 and we are adding a virtual column for row names + const coldNum = this.columnIDMap[element.data('colId')] + 2; + let columnTotal = 0; + let columnTotalWithoutCurrent = 0; + $(`#${this.getTableName()} tr td:nth-child(${coldNum})`).each(function () { + const rowId = $(this).data('rowId'); + let tval = ''; + if (element.data('rowId') === rowId) { + tval = newValue; + } else { + tval = $(this).html(); + } + + if (rowId !== -1) { + if (ValidationRules.float(tval)) { + columnTotal += parseFloat(tval); + if (element.data('rowId') !== rowId) { + columnTotalWithoutCurrent += parseFloat(tval); + } + } + } else if (columnTotal > 24) { + $(this).html(columnTotalWithoutCurrent); + } else { + $(this).html(columnTotal); + } + }); + + if (columnTotal > 24) { + return false; + } + + modJs.addCellDataUpdate(element.data('colId'), element.data('rowId'), newValue); + return true; + } + + setCurrentTimeSheetId(val) { + this.currentId = val; + this.cellDataUpdates = {}; + } + + + addAdditionalRequestData(type, req) { + if (type === 'updateData') { + req.currentId = this.currentId; + } else if (type === 'updateAllData') { + req.currentId = this.currentId; + } else if (type === 'getAllData') { + req.currentId = this.currentId; + } + + return req; + } + + modifyCSVHeader(header) { + header.unshift(''); + return header; + } + + getCSVData() { + let csv = ''; + + for (let i = 0; i < this.csvData.length; i++) { + csv += this.csvData[i].join(','); + if (i < this.csvData.length - 1) { + csv += '\r\n'; + } + } + + return csv; + } + + downloadTimesheet() { + const element = document.createElement('a'); + element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(this.getCSVData())}`); + element.setAttribute('download', `timesheet_${this.currentId}.csv`); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + + createTable(elementId) { + const data = this.getTableData(); + const headers = this.getHeaders(); + + if (this.showActionButtons()) { + headers.push({ sTitle: '', sClass: 'center' }); + } + + + if (this.showActionButtons()) { + for (let i = 0; i < data.length; i++) { + data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); + } + } + let html = ''; + html = `${this.getTableTopButtonHtml()}
    `; + + // Find current page + const activePage = $(`#${elementId} .dataTables_paginate .active a`).html(); + let start = 0; + if (activePage !== undefined && activePage !== null) { + start = parseInt(activePage, 10) * 100 - 100; + } + + $(`#${elementId}`).html(html); + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + aaData: data, + aoColumns: headers, + bSort: false, + iDisplayLength: 100, + iDisplayStart: start, + }; + + + const customTableParams = this.getCustomTableParams(); + + $.extend(dataTableParams, customTableParams); + + $(`#${elementId} #grid`).dataTable(dataTableParams); + + $(`#${elementId} #grid tr:last`).find('td').removeClass('editcell'); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + // $('.tableActionButton').tooltip(); + $(`#${elementId} #grid`).editableTableWidget(); + + $(`#${elementId} #grid .editcell`).on('validate', function (evt, newValue) { + return modJs.validateCellValue($(this), evt, newValue); + }); + } +} + + +module.exports = { + EmployeeTimeSheetAdapter, + SubEmployeeTimeSheetAdapter, + EmployeeTimeEntryAdapter, + QtsheetAdapter, +}; diff --git a/web/modules/src/travel/index.js b/web/modules/src/travel/index.js new file mode 100644 index 00000000..8f017412 --- /dev/null +++ b/web/modules/src/travel/index.js @@ -0,0 +1,11 @@ +import { + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdapter, + EmployeeTravelRecordApproverAdapter, + SubordinateEmployeeTravelRecordAdapter, +} from './lib'; + +window.EmployeeImmigrationAdapter = EmployeeImmigrationAdapter; +window.EmployeeTravelRecordAdapter = EmployeeTravelRecordAdapter; +window.EmployeeTravelRecordApproverAdapter = EmployeeTravelRecordApproverAdapter; +window.SubordinateEmployeeTravelRecordAdapter = SubordinateEmployeeTravelRecordAdapter; diff --git a/web/modules/src/travel/lib.js b/web/modules/src/travel/lib.js new file mode 100644 index 00000000..da4fb613 --- /dev/null +++ b/web/modules/src/travel/lib.js @@ -0,0 +1,181 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import ApproveModuleAdapter from '../../../api/ApproveModuleAdapter'; + +import { + EmployeeTravelRecordAdminAdapter, +} from '../../../admin/src/travel/lib'; + +class EmployeeImmigrationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'document', + 'documentname', + 'valid_until', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Document' }, + { sTitle: 'Document Id' }, + { sTitle: 'Valid Until' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['ImmigrationDocument', 'id', 'name'] }], + ['documentname', { label: 'Document Id', type: 'text', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment1', { label: 'Attachment 1', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment 2', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment 3', type: 'fileupload', validation: 'none' }], + ]; + } +} + + +class EmployeeTravelRecordAdapter extends ApproveModuleAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'Travel'; + this.itemNameLower = 'employeetravelrecord'; + this.modulePathName = 'travel'; + } + + getDataMapping() { + return [ + 'id', + 'type', + 'purpose', + 'travel_from', + 'travel_to', + 'travel_date', + 'return_date', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Travel Type' }, + { sTitle: 'Purpose' }, + { sTitle: 'From' }, + { sTitle: 'To' }, + { sTitle: 'Travel Date' }, + { sTitle: 'Return Date' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return this.addCustomFields([ + ['id', { label: 'ID', type: 'hidden' }], + ['type', { + label: 'Means of Transportation', + type: 'select', + source: [ + ['Plane', 'Plane'], + ['Rail', 'Rail'], + ['Taxi', 'Taxi'], + ['Own Vehicle', 'Own Vehicle'], + ['Rented Vehicle', 'Rented Vehicle'], + ['Other', 'Other'], + ], + }], + ['purpose', { label: 'Purpose of Travel', type: 'textarea', validation: '' }], + ['travel_from', { label: 'Travel From', type: 'text', validation: '' }], + ['travel_to', { label: 'Travel To', type: 'text', validation: '' }], + ['travel_date', { label: 'Travel Date', type: 'datetime', validation: '' }], + ['return_date', { label: 'Return Date', type: 'datetime', validation: '' }], + ['details', { label: 'Notes', type: 'textarea', validation: 'none' }], + ['currency', { + label: 'Currency', type: 'select2', 'allow-null': false, 'remote-source': ['CurrencyType', 'id', 'code'], + }], + ['funding', { + label: 'Total Funding Proposed', type: 'text', validation: 'float', default: '0.00', mask: '9{0,10}.99', + }], + ['attachment1', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]); + } +} + + +/* + EmployeeTravelRecordApproverAdapter + */ + +class EmployeeTravelRecordApproverAdapter extends EmployeeTravelRecordAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'Travel'; + this.itemNameLower = 'employeetravelrecord'; + this.modulePathName = 'travel'; + } + + getActionButtonsHtml(id, data) { + const statusChangeButton = ''; + const viewLogsButton = ''; + + let html = '
    _status__logs_
    '; + + + html = html.replace('_logs_', viewLogsButton); + + + if (data[this.getStatusFieldPosition()] === 'Processing') { + html = html.replace('_status_', statusChangeButton); + } else { + html = html.replace('_status_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); + return html; + } + + getStatusOptionsData(currentStatus) { + const data = {}; + if (currentStatus === 'Processing') { + data.Approved = 'Approved'; + data.Rejected = 'Rejected'; + } + + return data; + } + + getStatusOptions(currentStatus) { + return this.generateOptions(this.getStatusOptionsData(currentStatus)); + } +} + +/* + SubordinateExpenseModuleAdapter + */ + +class SubordinateEmployeeTravelRecordAdapter extends EmployeeTravelRecordAdminAdapter { + +} + +module.exports = { + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdapter, + EmployeeTravelRecordApproverAdapter, + SubordinateEmployeeTravelRecordAdapter, +}; diff --git a/web/modules/time_sheets/lib.js b/web/modules/time_sheets/lib.js deleted file mode 100644 index 6d62f9ca..00000000 --- a/web/modules/time_sheets/lib.js +++ /dev/null @@ -1,966 +0,0 @@ -/* -This file is part of iCE Hrm. - -iCE Hrm is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -iCE Hrm is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with iCE Hrm. If not, see . - ------------------------------------------------------------------- - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeTimeSheetAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeTimeSheetAdapter.inherits(AdapterBase); - -this.currentTimesheetId = null; -this.currentTimesheet = null; -this.needStartEndTime = false; - -EmployeeTimeSheetAdapter.method('getDataMapping', function() { - return [ - "id", - "date_start", - "date_end", - "total_time", - "status" - ]; -}); - -EmployeeTimeSheetAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Start Date"}, - { "sTitle": "End Date"}, - { "sTitle": "Total Time"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeTimeSheetAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "date_start", {"label":"TimeSheet Start Date","type":"date","validation":""}], - [ "date_end", {"label":"TimeSheet End Date","type":"date","validation":""}], - [ "details", {"label":"Reason","type":"textarea","validation":"none"}] - ]; -}); - -EmployeeTimeSheetAdapter.method('preProcessTableData', function(row) { - row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); - row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); - return row; -}); - -EmployeeTimeSheetAdapter.method('setNeedStartEndTime', function(status) { - this.needStartEndTime = status; -}); - -EmployeeTimeSheetAdapter.method('renderForm', function(object) { - var formHtml = this.templates['formTemplate']; - - $('#EmployeeTimesheetBlock').remove(); - $("#"+this.getTableName()+'Form').html(formHtml); - $("#"+this.getTableName()+'Form').show(); - $("#"+this.getTableName()).hide(); - - $('.timesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); - $('.timesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); - - this.currentTimesheet = object; - - this.getTimeEntries(); - - var st = Date.parse(object.date_start); - - $('#EmployeeTimesheetBlock').fullCalendar({ - header: { - //left: 'prev,next today', - left: false, - //center: 'title', - center: false, - //right: 'month,agendaWeek,agendaDay' - right: false - }, - year: st.toString('yyyy'), - month: st.toString('M'), - date: st.toString('d'), - - defaultView: 'basicWeek', - height:200, - editable: false, - - events: modJs.getScheduleJsonUrl(this.currentTimesheet.employee), - - loading: function(bool) { - if (bool) $('#loadingBlock').show(); - else $('#loadingBlock').hide(); - }, - - dayClick: function(date, jsEvent, view, resourceObj) { - - modJs.renderFormByDate(date.format()); - - }, - - eventClick: function(calEvent, jsEvent, view) { - - modJs.renderFormTimeEntryCalender(calEvent.id); - - }, - eventRender: function(event, element) { - element.find(".fc-time").remove(); - } - }); - - $('#EmployeeTimesheetBlock').fullCalendar('gotoDate', st); - - $('.fc-toolbar').hide(); - -}); - - -EmployeeTimeSheetAdapter.method('quickEdit', function(id, status, sdate, edate) { - $('#Qtsheet').data('lastActiveTab', modJs.tab); - modJs = modJsList['tabQtsheet']; - modJs.setCurrentTimeSheetId(id); - - $('.timesheet_start').html(sdate); - $('.timesheet_end').html(edate); - - $("#timesheetTabs").find('.active').find('.reviewBlock.reviewBlockTable').hide(); - $("#QtsheetHeader").show(); - $("#Qtsheet").show(); - $("#QtsheetDataButtons").show(); - - if(status == 'Submitted' || status == 'Approved'){ - $(".completeBtnTable").hide(); - $(".saveBtnTable").hide(); - }else{ - $(".completeBtnTable").show(); - $(".saveBtnTable").show(); - } - - modJs.get([]); -}); - - -EmployeeTimeSheetAdapter.method('getScheduleJsonUrl', function(employeeId) { - var url = this.moduleRelativeURL+"?a=ca&sa=getEmployeeTimeEntries&t="+this.table+"&mod=modules%3Dtime_sheets&e="+employeeId; - return url; -}); - - -EmployeeTimeSheetAdapter.method('renderFormByDate', function (date) { - var start, end; - var origDate = date; - if(date.indexOf('T') < 0){ - var s1 = moment(); - date = date + " " + s1.format("HH:mm:ss"); - } - - start = date.replace('T',' '); - var m1 = moment(start); - m1.add(1,'h'); - end = m1.format('YYYY-MM-DD HH:mm:ss'); - - var obj = {}; - obj.date = origDate; - obj.date_start = start; - obj.date_end = end; - - this.renderFormTimeEntryCalender(obj); - -}); - - - -EmployeeTimeSheetAdapter.method('renderFormTimeEntryCalender', function(object) { - - if (this.needStartEndTime+'' == '0') { - return; - } - this.openTimeEntryDialog(object); - if(object.id != undefined && object.id != null){ - var cid = object.id; - $('.deleteBtnWorkSchedule').show(); - $('.deleteBtnWorkSchedule').off().on('click',function(){ - modJs.deleteRow(cid); - return false; - }); - }else{ - $('.deleteBtnWorkSchedule').remove(); - } - - -}); - - -EmployeeTimeSheetAdapter.method('openTimeEntryDialog', function(object) { - this.currentTimesheetId = this.currentId; - var obj = modJsList['tabEmployeeTimeEntry']; - $('#TimeEntryModel').modal({ - backdrop: 'static', - keyboard: false - }); - obj.currentTimesheet = this.currentTimesheet; - obj.renderForm(object); - obj.timesheetId = this.currentId; - -}); - -EmployeeTimeSheetAdapter.method('closeTimeEntryDialog', function() { - $('#TimeEntryModel').modal('hide'); -}); - - -EmployeeTimeSheetAdapter.method('getTimeEntries', function() { - timesheetId = this.currentId; - var sourceMappingJson = JSON.stringify(modJsList['tabEmployeeTimeEntry'].getSourceMapping()); - object = {"id":timesheetId,"sm":sourceMappingJson}; - - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'getTimeEntriesSuccessCallBack'; - callBackData['callBackFail'] = 'getTimeEntriesFailCallBack'; - - this.customAction('getTimeEntries','modules=time_sheets',reqJson,callBackData); -}); - -EmployeeTimeSheetAdapter.method('getTimeEntriesSuccessCallBack', function(callBackData) { - var entries = callBackData; - var html = ""; - var temp = '_start__end__duration__project__details_'; - - for(var i=0;i' + - '' + - '_redoBtn_'+ - ''; - }else{ - html = '
    ' + - '' + - '_redoBtn_'+ - '
    '; - } - - if(this.getTableName() == "EmployeeTimeSheetAll"){ - var redoBtn = ''; - html = html.replace(/_redoBtn_/g,redoBtn); - } else { - html = html.replace(/_redoBtn_/g,''); - } - html = html.replace(/_id_/g,id); - html = html.replace(/_sdate_/g,data[1]); - html = html.replace(/_edate_/g,data[2]); - html = html.replace(/_status_/g,data[4]); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -EmployeeTimeSheetAdapter.method('getCustomTableParams', function() { - var that = this; - var dataTableParams = { - "aoColumnDefs": [ - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 1) - } , - "aTargets": [1] - }, - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 2) - } , - "aTargets": [2] - }, - { - "fnRender": that.getActionButtons, - "aTargets": [that.getDataMapping().length] - } - ] - }; - return dataTableParams; -}); - -EmployeeTimeSheetAdapter.method('preProcessRemoteTableData', function(data, cell, id) { - return Date.parse(cell).toString('MMM d, yyyy (dddd)'); -}); - - -/* - * Subordinate TimeSheets - */ - -function SubEmployeeTimeSheetAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -this.timeSheetStatusChangeId = null; - -SubEmployeeTimeSheetAdapter.inherits(EmployeeTimeSheetAdapter); - -SubEmployeeTimeSheetAdapter.method('getDataMapping', function() { - return [ - "id", - "employee", - "date_start", - "date_end", - "status" - ]; -}); - -SubEmployeeTimeSheetAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Employee","bSearchable":true}, - { "sTitle": "Start Date","bSearchable":true}, - { "sTitle": "End Date","bSearchable":true}, - { "sTitle": "Status"} - ]; -}); - -SubEmployeeTimeSheetAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "employee", {"label":"Employee","type":"select","allow-null":false,"remote-source":["Employee","id","first_name+last_name"]}], - [ "date_start", {"label":"TimeSheet Start Date","type":"date","validation":""}], - [ "date_end", {"label":"TimeSheet Start Date","type":"date","validation":""}], - [ "details", {"label":"Reason","type":"textarea","validation":"none"}] - ]; -}); - - -SubEmployeeTimeSheetAdapter.method('isSubProfileTable', function() { - return true; -}); - -SubEmployeeTimeSheetAdapter.method('getCustomSuccessCallBack', function(serverData) { - var data = []; - var mapping = this.getDataMapping(); - for(var i=0;i' + - '' + - '' + - ''; - }else{ - - html = '
    ' + - '' + - '' + - '
    '; - } - - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - html = html.replace(/_sdate_/g,data[1]); - html = html.replace(/_edate_/g,data[2]); - html = html.replace(/_status_/g,data[4]); - return html; -}); - - -SubEmployeeTimeSheetAdapter.method('getCustomTableParams', function() { - var that = this; - var dataTableParams = { - "aoColumnDefs": [ - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 2) - } , - "aTargets": [2] - }, - { - "fnRender": function(data, cell){ - return that.preProcessRemoteTableData(data, cell, 3) - } , - "aTargets": [3] - }, - { - "fnRender": that.getActionButtons, - "aTargets": [that.getDataMapping().length] - } - ] - }; - return dataTableParams; -}); - -SubEmployeeTimeSheetAdapter.method('getFilters', function() { - return [ - [ "employee", {"label":"Employee","type":"select2","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}], - [ "status", {"label":"Status","type":"select","allow-null":true,"null-label":"All","source":[["Submitted","Submitted"],["Pending","Pending"],["Approved","Approved"], ["Rejected","Rejected"]]}], - ]; -}); - - -/** - * EmployeeTimeEntryAdapter - */ - -function EmployeeTimeEntryAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); -} - -EmployeeTimeEntryAdapter.inherits(AdapterBase); - -this.timesheetId = null; -this.currentTimesheet = null; -this.allProjectsAllowed = 1; -this.employeeProjects = []; - -EmployeeTimeEntryAdapter.method('getDataMapping', function() { - return [ - "id", - "project", - "date_start", - "time_start", - "date_end", - "time_end", - "details" - ]; -}); - -EmployeeTimeEntryAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Project"}, - { "sTitle": "Start Date"}, - { "sTitle": "Start Time"}, - { "sTitle": "End Date"}, - { "sTitle": "End Time"}, - { "sTitle": "Details"} - ]; -}); - -EmployeeTimeEntryAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "project", {"label":"Project","type":"select2","allow-null":false,"remote-source":["Project","id","name","getEmployeeProjects"]}], - [ "date_select", {"label":"Date","type":"select","source":[]}], - [ "date_start", {"label":"Start Time","type":"time","validation":""}], - [ "date_end", {"label":"End Time","type":"time","validation":""}], - [ "details", {"label":"Details","type":"textarea","validation":""}] - ]; -}); - - -EmployeeTimeEntryAdapter.method('getDates', function(startDate, stopDate) { - - var dateArray = new Array(); - var currentDate = startDate; - while (currentDate <= stopDate) { - dateArray.push( new Date (currentDate) ); - currentDate = currentDate.add({ days: 1 }); - } - return dateArray; -}); - - -EmployeeTimeEntryAdapter.method('renderForm', function(object) { - var formHtml = this.getCustomTemplate('time_entry_form.html'); - formHtml = formHtml.replace(/modJs/g,"modJsList['tabEmployeeTimeEntry']"); - var html = ""; - var fields = this.getFormFields(); - - for(var i=0;i'+k.toUTCString().slice(0, -13)+''; - optionList += ''; - } - - - - formHtml = formHtml.replace(/_id_/g,this.getTableName()+"_submit"); - formHtml = formHtml.replace(/_fields_/g,html); - $("#"+this.getTableName()+'Form').html(formHtml); - $("#"+this.getTableName()+'Form').show(); - $("#"+this.getTableName()).hide(); - - $("#"+this.getTableName()+'Form .datefield').datepicker({'viewMode':2}); - $("#"+this.getTableName()+'Form .datetimefield').datetimepicker({ - language: 'en' - }); - $("#"+this.getTableName()+'Form .timefield').datetimepicker({ - language: 'en', - pickDate: false - }); - - $("#"+this.getTableName()+'Form .select2Field').select2(); - - $("#date_select").html(optionList); - - - if(object != undefined && object != null){ - this.fillForm(object); - } -}); - - -EmployeeTimeEntryAdapter.method('fillForm', function(object, formId, fields) { - - if(formId == null || formId == undefined || formId == ""){ - formId = "#"+this.getTableName()+'Form'; - } - - if(object.id != null && object.id != undefined){ - $(formId + ' #id').val(object.id); - } - - if(object.project != null && object.project != undefined){ - $(formId + ' #project').select2('val',object.project); - } - - if(object.date != null && object.date != undefined){ - $(formId + ' #date_select').val(object.date); - } -}); - - - -EmployeeTimeEntryAdapter.method('cancel', function() { - $('#TimeEntryModel').modal('hide'); -}); - -EmployeeTimeEntryAdapter.method('setAllProjectsAllowed', function(allProjectsAllowed) { - this.allProjectsAllowed = allProjectsAllowed; -}); - -EmployeeTimeEntryAdapter.method('setEmployeeProjects', function(employeeProjects) { - this.employeeProjects = employeeProjects; -}); - - -EmployeeTimeEntryAdapter.method('save', function() { - var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"}); - - if(validator.checkValues()){ - var params = validator.getFormParameters(); - $(params).attr('timesheet',this.timesheetId); - - params.time_start = params.date_start; - params.time_end = params.date_end; - - params.date_start = params.date_select+" "+params.date_start; - params.date_end = params.date_select+" "+params.date_end; - - - var msg = this.doCustomValidation(params); - - if(msg == null){ - var id = $('#'+this.getTableName()+"_submit #id").val(); - if(id != null && id != undefined && id != ""){ - $(params).attr('id',id); - } - this.add(params,[]); - this.cancel(); - }else{ - $("#"+this.getTableName()+'Form .label').html(msg); - $("#"+this.getTableName()+'Form .label').show(); - } - - } -}); - -EmployeeTimeEntryAdapter.method('doCustomValidation', function(params) { - var st = Date.parse(params.date_start); - var et = Date.parse(params.date_end); - if(st.compareTo(et) != -1){ - return "Start time should be less than End time"; - } - /* - var sd = Date.parse(this.currentTimesheet.date_start); - var ed = Date.parse(this.currentTimesheet.date_end).addDays(1); - - if(sd.compareTo(et) != -1 || sd.compareTo(st) > 0 || st.compareTo(ed) != -1 || et.compareTo(ed) != -1){ - return "Start time and end time shoud be with in " + sd.toString('MMM d, yyyy (dddd)') + " and " + ed.toString('MMM d, yyyy (dddd)'); - } - */ - return null; -}); - -EmployeeTimeEntryAdapter.method('addSuccessCallBack', function(callBackData,serverData) { - this.get(callBackData); - modJs.getTimeEntries(); -}); - -EmployeeTimeEntryAdapter.method('deleteRow', function(id) { - this.deleteObj(id,[]); - -}); - -EmployeeTimeEntryAdapter.method('deleteSuccessCallBack', function(callBackData,serverData) { - modJs.getTimeEntries(); -}); - - - - -/** - * QtsheetAdapter - */ - -function QtsheetAdapter(endPoint) { - this.initAdapter(endPoint); - this.cellDataUpdates = {}; - this.currentId = null; -} - -QtsheetAdapter.inherits(TableEditAdapter); - -QtsheetAdapter.method('validateCellValue', function(element, evt, newValue) { - - if ( !ValidationRules.float(newValue)) { - return false; - } - var val = parseFloat(newValue); - if(val < 0 || val > 24){ - return false; - } - - //Update total - //Find current column number - //Adding 2 because nth child is based on 1 and we are adding a virtual column for row names - var coldNum = this.columnIDMap[element.data('colId')] + 2; - var columnTotal = 0; - var columnTotalWithoutCurrent = 0; - $("#"+this.getTableName()+' tr td:nth-child('+coldNum+')').each(function(){ - var rowId = $(this).data('rowId'); - var tval = ''; - if(element.data('rowId') == rowId){ - tval = newValue; - }else{ - tval = $(this).html(); - } - - if(rowId != -1){ - if(ValidationRules.float(tval)){ - columnTotal += parseFloat(tval); - if(element.data('rowId') != rowId){ - columnTotalWithoutCurrent += parseFloat(tval); - } - } - }else{ - if(columnTotal > 24){ - $(this).html(columnTotalWithoutCurrent); - }else{ - $(this).html(columnTotal); - } - } - }); - - if(columnTotal > 24){ - return false; - } - - modJs.addCellDataUpdate(element.data('colId'),element.data('rowId'),newValue); - return true; -}); - -QtsheetAdapter.method('setCurrentTimeSheetId', function(val) { - this.currentId = val; - this.cellDataUpdates = {}; -}); - - -QtsheetAdapter.method('addAdditionalRequestData' , function(type, req) { - if(type == 'updateData'){ - req.currentId = this.currentId; - }else if(type == 'updateAllData'){ - req.currentId = this.currentId; - }else if(type == 'getAllData'){ - req.currentId = this.currentId; - } - - return req; -}); - -QtsheetAdapter.method('modifyCSVHeader', function(header) { - header.unshift(""); - return header; -}); - -QtsheetAdapter.method('getCSVData' , function() { - var csv = ""; - - for(var i=0;i
    '; - - //Find current page - var activePage = $('#'+elementId +" .dataTables_paginate .active a").html(); - var start = 0; - if(activePage != undefined && activePage != null){ - start = parseInt(activePage, 10)*100 - 100; - } - - $('#'+elementId).html(html); - - var dataTableParams = { - "oLanguage": { - "sLengthMenu": "_MENU_ records per page" - }, - "aaData": data, - "aoColumns": headers, - "bSort": false, - "iDisplayLength": 100, - "iDisplayStart": start - }; - - - var customTableParams = this.getCustomTableParams(); - - $.extend(dataTableParams, customTableParams); - - $('#'+elementId+' #grid').dataTable( dataTableParams ); - - $('#'+elementId+' #grid tr:last').find('td').removeClass('editcell'); - - $(".dataTables_paginate ul").addClass("pagination"); - $(".dataTables_length").hide(); - $(".dataTables_filter input").addClass("form-control"); - $(".dataTables_filter input").attr("placeholder","Search"); - $(".dataTables_filter label").contents().filter(function(){ - return (this.nodeType == 3); - }).remove(); - //$('.tableActionButton').tooltip(); - $('#'+elementId+' #grid').editableTableWidget(); - - $('#'+elementId+' #grid .editcell').on('validate', function(evt, newValue) { - - return modJs.validateCellValue($(this), evt, newValue); - - }); -}); - diff --git a/web/modules/travel/lib.js b/web/modules/travel/lib.js deleted file mode 100644 index 50bb0987..00000000 --- a/web/modules/travel/lib.js +++ /dev/null @@ -1,241 +0,0 @@ -/* -This file is part of iCE Hrm. - -Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd] -Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah) - */ - -function EmployeeImmigrationAdapter(endPoint) { - this.initAdapter(endPoint); -} - -EmployeeImmigrationAdapter.inherits(AdapterBase); - - - -EmployeeImmigrationAdapter.method('getDataMapping', function() { - return [ - "id", - "document", - "documentname", - "valid_until", - "status" - ]; -}); - -EmployeeImmigrationAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Document" }, - { "sTitle": "Document Id" }, - { "sTitle": "Valid Until"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeImmigrationAdapter.method('getFormFields', function() { - return [ - [ "id", {"label":"ID","type":"hidden"}], - [ "document", {"label":"Document","type":"select2","remote-source":["ImmigrationDocument","id","name"]}], - [ "documentname", {"label":"Document Id","type":"text","validation":""}], - [ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}], - [ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}], - [ "details", {"label":"Details","type":"textarea","validation":"none"}], - [ "attachment1", {"label":"Attachment 1","type":"fileupload","validation":"none"}], - [ "attachment2", {"label":"Attachment 2","type":"fileupload","validation":"none"}], - [ "attachment3", {"label":"Attachment 3","type":"fileupload","validation":"none"}] - ]; -}); - - - - - -function EmployeeTravelRecordAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.itemName = 'Travel'; - this.itemNameLower = 'employeetravelrecord'; - this.modulePathName = 'travel'; -} - -EmployeeTravelRecordAdapter.inherits(ApproveModuleAdapter); - - - -EmployeeTravelRecordAdapter.method('getDataMapping', function() { - return [ - "id", - "type", - "purpose", - "travel_from", - "travel_to", - "travel_date", - "return_date", - "status" - ]; -}); - -EmployeeTravelRecordAdapter.method('getHeaders', function() { - return [ - { "sTitle": "ID" ,"bVisible":false}, - { "sTitle": "Travel Type" }, - { "sTitle": "Purpose" }, - { "sTitle": "From"}, - { "sTitle": "To"}, - { "sTitle": "Travel Date"}, - { "sTitle": "Return Date"}, - { "sTitle": "Status"} - ]; -}); - -EmployeeTravelRecordAdapter.method('getFormFields', function() { - return this.addCustomFields([ - ["id", {"label": "ID", "type": "hidden"}], - ["type", { - "label": "Means of Transportation", - "type": "select", - "source": [ - ["Plane", "Plane"], - ["Rail", "Rail"], - ["Taxi", "Taxi"], - ["Own Vehicle", "Own Vehicle"], - ["Rented Vehicle", "Rented Vehicle"], - ["Other", "Other"] - ] - }], - ["purpose", {"label": "Purpose of Travel", "type": "textarea", "validation": ""}], - ["travel_from", {"label": "Travel From", "type": "text", "validation": ""}], - ["travel_to", {"label": "Travel To", "type": "text", "validation": ""}], - ["travel_date", {"label": "Travel Date", "type": "datetime", "validation": ""}], - ["return_date", {"label": "Return Date", "type": "datetime", "validation": ""}], - ["details", {"label": "Notes", "type": "textarea", "validation": "none"}], - ["currency", {"label": "Currency", "type": "select2", "allow-null":false, "remote-source": ["CurrencyType", "id", "code"]}], - ["funding", {"label": "Total Funding Proposed", "type": "text", "validation": "float", "default":"0.00", "mask":"9{0,10}.99"}], - ["attachment1", {"label": "Attachment", "type": "fileupload", "validation": "none"}], - ["attachment2", {"label": "Attachment", "type": "fileupload", "validation": "none"}], - ["attachment3", {"label": "Attachment", "type": "fileupload", "validation": "none"}] - ]); -}); - -/* -EmployeeTravelRecordAdapter.method('getActionButtonsHtml', function(id,data) { - var editButton = ''; - var deleteButton = ''; - var requestCancellationButton = ''; - - var html = '
    _edit__delete_
    '; - - if(this.showDelete){ - if(data[7] == "Approved"){ - html = html.replace('_delete_',requestCancellationButton); - }else{ - html = html.replace('_delete_',deleteButton); - } - - }else{ - html = html.replace('_delete_',''); - } - - if(this.showEdit){ - html = html.replace('_edit_',editButton); - }else{ - html = html.replace('_edit_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - return html; -}); - -EmployeeTravelRecordAdapter.method('cancelTravel', function(id) { - var that = this; - var object = {}; - object['id'] = id; - - var reqJson = JSON.stringify(object); - - var callBackData = []; - callBackData['callBackData'] = []; - callBackData['callBackSuccess'] = 'cancelSuccessCallBack'; - callBackData['callBackFail'] = 'cancelFailCallBack'; - - this.customAction('cancelTravel','modules=travel',reqJson,callBackData); -}); - -EmployeeTravelRecordAdapter.method('cancelSuccessCallBack', function(callBackData) { - this.showMessage("Successful", "Travel request cancellation request sent"); - this.get([]); -}); - -EmployeeTravelRecordAdapter.method('cancelFailCallBack', function(callBackData) { - this.showMessage("Error Occurred while cancelling Travel request", callBackData); -}); -*/ - -/* - EmployeeTravelRecordApproverAdapter - */ - -function EmployeeTravelRecordApproverAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.itemName = 'Travel'; - this.itemNameLower = 'employeetravelrecord'; - this.modulePathName = 'travel'; -} - -EmployeeTravelRecordApproverAdapter.inherits(EmployeeTravelRecordAdminAdapter); - -EmployeeTravelRecordApproverAdapter.method('getActionButtonsHtml', function(id,data) { - var statusChangeButton = ''; - var viewLogsButton = ''; - - var html = '
    _status__logs_
    '; - - - html = html.replace('_logs_',viewLogsButton); - - - if(data[this.getStatusFieldPosition()] == 'Processing'){ - html = html.replace('_status_',statusChangeButton); - - }else{ - html = html.replace('_status_',''); - } - - html = html.replace(/_id_/g,id); - html = html.replace(/_BASE_/g,this.baseUrl); - html = html.replace(/_cstatus_/g,data[this.getStatusFieldPosition()]); - return html; -}); - -EmployeeTravelRecordApproverAdapter.method('getStatusOptionsData', function(currentStatus) { - var data = {}; - if(currentStatus != 'Processing'){ - - }else{ - data["Approved"] = "Approved"; - data["Rejected"] = "Rejected"; - - } - - return data; -}); - -EmployeeTravelRecordApproverAdapter.method('getStatusOptions', function(currentStatus) { - return this.generateOptions(this.getStatusOptionsData(currentStatus)); -}); - - -/* - SubordinateExpenseModuleAdapter - */ - -function SubordinateEmployeeTravelRecordAdapter(endPoint,tab,filter,orderBy) { - this.initAdapter(endPoint,tab,filter,orderBy); - this.itemName = 'Travel'; - this.itemNameLower = 'employeetravelrecord'; - this.modulePathName = 'travel'; -} - -SubordinateEmployeeTravelRecordAdapter.inherits(EmployeeTravelRecordAdminAdapter); - diff --git a/web/themecss/AdminLTE.css b/web/themecss/AdminLTE.css index 15b33eba..a7b778e8 100644 --- a/web/themecss/AdminLTE.css +++ b/web/themecss/AdminLTE.css @@ -5112,4 +5112,4 @@ fieldset[disabled] .btn-vk.active { } .control-sidebar-light .control-sidebar-menu > li > a .menu-info > p { color: #5e5e5e; -} +} \ No newline at end of file