├── .devcontainer ├── Dockerfile ├── arm64 │ ├── Dockerfile │ └── README.md └── devcontainer.json ├── .github └── ISSUE_TEMPLATE │ └── session-feedback-template.md ├── .gitignore ├── CODEOWNERS ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── REUSE.toml ├── bookshop └── finished-webapp │ ├── package-lock.json │ ├── package.json │ ├── ui5.yaml │ └── webapp │ ├── Component.js │ ├── controller │ └── App.controller.js │ ├── css │ └── style.css │ ├── i18n │ ├── i18n.properties │ └── i18n_de.properties │ ├── index.html │ ├── localService │ ├── metadata.xml │ ├── mockdata │ │ ├── Books.json │ │ ├── Currencies.json │ │ └── Genres.json │ └── mockserver.js │ ├── manifest.json │ ├── model │ └── formatter.js │ ├── test │ ├── initMockServer.js │ └── mockServer.html │ └── view │ └── App.view.xml ├── chapters ├── 00-prep-dev-environment │ └── readme.md ├── 01-scaffolding │ ├── readme.md │ └── result.png ├── 02-first-view │ ├── readme.md │ └── result.png ├── 03-first-model │ ├── App.view.png │ ├── readme.md │ └── result.png ├── 04-first-controller │ ├── App.view.png │ ├── alert.png │ ├── readme.md │ └── result.png ├── 05-order-feature │ ├── App.controller.png │ ├── App.view.png │ ├── readme.md │ └── result.png ├── 06-search-feature │ ├── App.controller.png │ ├── App.view.png │ ├── readme.md │ └── result.png ├── 07-formatting │ ├── App.controller.png │ ├── App.view.png │ ├── readme.md │ └── result.png ├── 08-i18n │ ├── manifest.png │ ├── readme.md │ └── result.png ├── 09-custom-css │ ├── App.view.png │ ├── manifest.png │ ├── readme.md │ └── result.png ├── 10-deployment │ ├── readme.md │ ├── result1.png │ └── result2.png ├── 11-further-improvements │ └── readme.md ├── appendix-01-fe-fpm │ ├── fiori-tools.png │ ├── readme.md │ └── result.png ├── appendix-02-object-page │ ├── readme.md │ └── result.png └── appendix-03-fiori-tools │ ├── page-map.png │ ├── readme.md │ └── result.png └── finished-app.png /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/javascript-node/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] Node.js version: 16, 14, 12 4 | ARG VARIANT="18-buster" 5 | FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} 6 | 7 | # Prepare for apt-based install of Cloud Foundry CLI by adding Cloud Foundry Foundation public key & package repository (see https://docs.cloudfoundry.org/cf-cli/install-go-cli.html) 8 | RUN wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - 9 | RUN echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list 10 | 11 | # Update local package index and run installs 12 | RUN apt-get update 13 | RUN apt-get install cf7-cli sqlite3 14 | 15 | # Install global node modules for SAP CAP and frontend development 16 | RUN su node -c "npm install -g @ui5/cli @sap/cds-dk yo mbt" 17 | -------------------------------------------------------------------------------- /.devcontainer/arm64/Dockerfile: -------------------------------------------------------------------------------- 1 | # Base build stage 2 | FROM arm64v8/debian:latest as foundry 3 | 4 | # Install necessary dependencies 5 | RUN apt-get update && \ 6 | apt-get install -y apt-transport-https ca-certificates gnupg curl && \ 7 | rm -rf /var/lib/apt/lists/* 8 | 9 | # Install the Cloud Foundry CLI 10 | RUN curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=v7" | tar -zx && \ 11 | mv cf7 /usr/local/bin/cf && \ 12 | chmod +x /usr/local/bin/cf 13 | 14 | # Final build stage 15 | ARG VARIANT="18-buster-slim" 16 | FROM arm64v8/node:${VARIANT} 17 | 18 | COPY --from=foundry /usr/local/bin/cf /usr/local/bin/cf 19 | 20 | # Update local package index and run installs 21 | RUN apt-get update 22 | 23 | RUN apt-get install -y sqlite3 24 | RUN apt-get install -y git 25 | 26 | # Install global node modules for SAP CAP and frontend development 27 | RUN npm install -g @ui5/cli @sap/cds-dk yo mbt 28 | 29 | EXPOSE 8080 30 | EXPOSE 8081 31 | -------------------------------------------------------------------------------- /.devcontainer/arm64/README.md: -------------------------------------------------------------------------------- 1 | # Info Dockerfile for arm64 2 | 3 | ## Trivia 4 | 5 | Based on the original Dockerfile from this repo, this one will create a base image with which one can natively run a containerized exercise app on an M1/M2 MacBook. 6 | 7 | ## Issues 8 | 9 | Opening the running app via https://localhost:8080 may fail. 10 | 11 | To solve this, one needs to add `--accept-remote-connections` to `ui5 serve`. 12 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/javascript-node 3 | { 4 | "name": "SAP UI5 CodeJam Exercises Devcontainer", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | // Update 'VARIANT' to pick a Node version: 12, 14, 16 8 | "args": { "VARIANT": "18" } 9 | }, 10 | 11 | // Set *default* container specific settings.json values on container create. 12 | "settings": {}, 13 | 14 | // Add the IDs of extensions you want installed when the container is created. 15 | "extensions": [ 16 | "sapse.vscode-cds", 17 | "sapse.sap-ux-fiori-tools-extension-pack", 18 | "hookyqr.beautify", 19 | "yzhang.markdown-all-in-one", 20 | "mechatroner.rainbow-csv", 21 | "saposs.sap-hana-driver-for-sqltools", 22 | "saposs.xml-toolkit" 23 | ], 24 | 25 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 26 | "forwardPorts": [ 4004 ], 27 | 28 | // Use 'postCreateCommand' to run commands after the container is created. 29 | // "postCreateCommand": "npm install", 30 | 31 | // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 32 | "remoteUser": "node" 33 | } 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/session-feedback-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Session Feedback Template 3 | about: To give feedback on the session 4 | title: Session Feedback 5 | labels: feedback 6 | assignees: '' 7 | 8 | --- 9 | 10 | Thanks for taking a couple of minutes to give feedback, which will help me improve for next time. **Before doing anything else, hit the green button "Submit new issue" right now to save this issue content, rather than try to complete the feedback in this raw form.** Then go through the questions and mark a single checkbox for each, to represent your answer. Finally, in the empty comment box below this one, please describe what you liked and what you didn't like. 11 | 12 | **How experienced were you with web development in general before this session?** 13 | 14 | - [ ] Didn't know what HTML is 15 | - [ ] Heard about HTML/CSS/JavaScript, but never developed a web app 16 | - [ ] Used HTML/CSS/JavaScript before, but never developed a complete web app on my own 17 | - [ ] Developed one or more (smaller) web app(s) on my own 18 | - [ ] I am a very experienced web developer 19 | 20 | **How experienced were you with UI5 before this session?** 21 | 22 | - [ ] Didn't know what UI5 was 23 | - [ ] Heard about UI5, but never developed a UI5 app 24 | - [ ] Used UI5 before, but never developed a complete UI5 app on my own 25 | - [ ] Developed one or more (smaller) UI5 app(s) on my own 26 | - [ ] I am [Peter Muessig](https://twitter.com/pmuessig), or at least very experienced 27 | 28 | **How do you feel about UI5 now (after this session)?** 29 | 30 | - [ ] Don't know what UI5 is 31 | - [ ] Know what UI5 is, but don't know how develop a UI5 app 32 | - [ ] Know how to use parts of it, but don't know how to built a complete application on my own 33 | - [ ] Know how to built a complete application on my own 34 | - [ ] I am [Peter Muessig](https://twitter.com/pmuessig), or at least very experienced 35 | 36 | **Did this session meet your expectations?** 37 | 38 | - [ ] Not really 39 | - [ ] Somewhat 40 | - [ ] Mostly 41 | - [ ] Fully 42 | 43 | **Was the time allotted to each exercise enough for you to work through them?** 44 | 45 | - [ ] Not really 46 | - [ ] Somewhat 47 | - [ ] Mostly 48 | - [ ] Fully 49 | 50 | **What did you think of the extra information (collapsable sections 💬) and explanations provided?** 51 | 52 | - [ ] Too much information 53 | - [ ] Didn't really read it, didn't really bother me though 54 | - [ ] Found it helpful as context and background 55 | 56 | **How did you find the way we all moved at the same pace through the exercises?** 57 | 58 | - [ ] Would have preferred to go through them on my own at my own speed 59 | - [ ] Didn't mind, no strong feelings either way 60 | - [ ] Found it useful to keep pace and discuss the exercise questions, and reflect 61 | 62 | **Which development environment(s) did you use?** 63 | 64 | - [ ] SAP Business Application Studio 65 | - [ ] Code editor on my local machine 66 | - [ ] Devcontainer 67 | 68 | If you have time, please add a comment below to write free-form what you liked and what you disliked about the session. Thank you! -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | dist/ 3 | node_modules/ 4 | 5 | bookshop/manifest.yaml 6 | bookshop/package-lock.json 7 | bookshop/package.json 8 | bookshop/ui5.yaml 9 | bookshop/xs-app.json 10 | 11 | .DS_Store 12 | .vscode/ -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * nicolai.schoenteich@sap.com -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 30 | 31 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 32 | 33 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 34 | 35 | (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and 36 | 37 | (b) You must cause any modified files to carry prominent notices stating that You changed the files; and 38 | 39 | (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 40 | 41 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 42 | 43 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 44 | 45 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 46 | 47 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 48 | 49 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 50 | 51 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 52 | 53 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 54 | 55 | END OF TERMS AND CONDITIONS 56 | 57 | APPENDIX: How to apply the Apache License to your work. 58 | 59 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 60 | 61 | Copyright [yyyy] [name of copyright owner] 62 | 63 | Licensed under the Apache License, Version 2.0 (the "License"); 64 | you may not use this file except in compliance with the License. 65 | You may obtain a copy of the License at 66 | 67 | http://www.apache.org/licenses/LICENSE-2.0 68 | 69 | Unless required by applicable law or agreed to in writing, software 70 | distributed under the License is distributed on an "AS IS" BASIS, 71 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 72 | See the License for the specific language governing permissions and 73 | limitations under the License. 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/ui5-exercises-codejam)](https://api.reuse.software/info/github.com/SAP-samples/ui5-exercises-codejam) 2 | 3 | # SAP CodeJam - UI5 4 | 5 | This repository contains the material for SAP CodeJam events on UI5. 6 | 7 | Please check the [prerequisites](/chapters/00-prep-dev-environment/readme.md#1-prerequisites) before the event an make sure you meet them. 8 | 9 | ## Overview 10 | 11 | The material in this repository introduces you to the core principles of UI5, an enterprise-ready web development framework used to build apps that follow the Fiori design guidelines. This repository is a step-by-step guide explaining how build a frontend web application using UI5. The finished app is a bookshop app, where users can browse and order books. The app sits on top of the well-known [bookshop](https://github.com/SAP-samples/cloud-cap-samples/tree/main/bookshop) backend application built with the Node.js flavour of the SAP Cloud Application Programming Model (CAP). 12 | 13 | ![The finished app](/finished-app.png) 14 | 15 | The finished UI5 bookshop app already exists in the [bookshop/finished-webapp](/bookshop/finished-webapp/) directory, but we want to rebuild it from scratch step by step. You can compare the finished app with your version in case you have issues along the way. 16 | 17 | After reading all chapters and following the instructions, you will be able to build your own UI5 applications leveraging the official [SAPUI5 API Reference](https://sapui5.hana.ondemand.com/#/api). 18 | 19 | ## Previous Knowledge 20 | 21 | The material in this repository aims to be beginner friendly. If you have never built a (UI5) web app before, you will still be able to follow along. No prior knowledge is required, although it certainly helps to have experience in (web) development. 22 | 23 | The material includes additional explanations in collapsable sections (see example below), whenever a concept is used that web developers are probably already familiar with, but beginners might not be. You can decide for yourself whether you want to read or skip them. 24 | 25 | See this example: 26 | 27 |
28 | What is SAPUI5? 💬 29 | 30 |
31 | 32 | > SAPUI5 is an HTML5 framework for creating cross-platform, enterprise-grade web applications in an efficient way. 33 | > 34 | > See this [blog post](https://blogs.sap.com/2021/08/23/what-is-sapui5/) for more information. 35 | 36 |
37 | 38 | ## Material Organization 39 | 40 | The material consists of a series of chapters, each in their own directory. The chapters build on top of each other and are meant to be completed in the given order. Each of the [chapters](#chapters) has its own 'readme' file with explanations, instructions, code samples and screen shots. From a session flow perspective, we are taking a "coordinated" approach: 41 | 42 | The instructor will set you off on the first chapter. Do not proceed to the next chapter until the instructor tells you to do so. If you finish a chapter before others, there are some questions at the end of each chapter for you to ponder. 43 | 44 | > The exercises are written in a conversational way - this is so that they have enough context and information to be completed outside the hands-on session itself. To help you navigate and find what you have to actually do next, there are pointers like this ➡️ throughout that indicate the things you have to actually do (as opposed to just read for background information). 45 | 46 | ## Chapters 47 | 48 | - [00 - Preparing the Development Environment](/chapters/00-prep-dev-environment/) 49 | - [01 - Scaffolding the App](/chapters/01-scaffolding/) 50 | - [02 - Creating the First View](/chapters/02-first-view/) 51 | - [03 - Creating and Consuming the First Model](/chapters/03-first-model/) 52 | - [04 - Creating and Extending the First Controller](/chapters/04-first-controller/) 53 | - [05 - Adding an 'Order' Feature](/chapters/05-order-feature/) 54 | - [06 - Adding a 'Search' Feature](/chapters/06-search-feature/) 55 | - [07 - Adding Expression Binding and Custom Formatting](/chapters/07-formatting/) 56 | - [08 - Adding i18n Features](/chapters/08-i18n/) 57 | - [09 - Adding Custom CSS](/chapters/09-custom-css/) 58 | - [10 - Deploying the App](/chapters/10-deployment/) (Optional) 59 | - [11 - Further Improvements and Learning Material](/chapters/11-further-improvements/) 60 | 61 | ## SAPUI5 vs. OpenUI5 62 | 63 | You will often read about either SAPUI5 or OpenUI5 when working with the framework. The main difference between the two is the license. Whereas SAPUI5 requires a license and is integrated into a lot of SAP products, OpenUI5 is open source and generally available under an Apache 2.0 license. SAPUI5 includes more libraries than OpenUI5, but the latter still contains all central functionality and most commonly used control libraries are identical in both deliveries. 64 | 65 | The material in this repository would work with both deliveries, but uses OpenUI5. For the sake of simplicity and to indicate that the material would work with SAPUI5, too, the material simply refers to the framework as 'UI5'. 66 | 67 | You can find more information about this in the [SAPUI5 Documentation](https://sapui5.hana.ondemand.com/#/topic/5982a9734748474aa8d4af9c3d8f31c0). 68 | 69 | ## Feedback 70 | 71 | If you can spare a couple of minutes at the end of the session, please help the [author](https://github.com/nicoschoenteich) improve for next time by providing some feedback. 72 | 73 | Simply use this [template](https://github.com/SAP-samples/ui5-exercises-codejam/issues/new?assignees=&labels=feedback&template=session-feedback-template.md&title=Session%20Feedback) link to create a special "feedback" issue, and follow the instructions in there. 74 | 75 | Thank you! 76 | 77 | ## Support 78 | 79 | Support for the content in this repository is available during SAP CodeJam events, for which this content has been designed. Otherwise, this content is provided 'as-is' with no other support. 80 | 81 | ## Contributing 82 | If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses [the standard DCO text of the Linux Foundation](https://developercertificate.org/). 83 | 84 | ## License 85 | Copyright (c) 2022 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](/LICENSE) file. 86 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-PackageName = "ui5-exercises-codejam" 3 | SPDX-PackageSupplier = "Nico Schoenteich " 4 | SPDX-PackageDownloadLocation = "" 5 | SPDX-PackageComment = "The code in this project may include calls to APIs (\"API Calls\") of\n SAP or third-party products or services developed outside of this project\n (\"External Products\").\n \"APIs\" means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project's code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls." 6 | 7 | [[annotations]] 8 | path = "**" 9 | precedence = "aggregate" 10 | SPDX-FileCopyrightText = "2022 SAP SE or an SAP affiliate company and ui5-exercises-codejam contributors" 11 | SPDX-License-Identifier = "Apache-2.0" 12 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bookshop", 3 | "version": "0.0.1", 4 | "scripts": { 5 | "dev": "ui5 serve --open \"index.html\"", 6 | "dev:mock": "ui5 serve --open \"test/mockServer.html\"" 7 | 8 | }, 9 | "devDependencies": { 10 | "@ui5/cli": "^4", 11 | "@sap/ux-ui5-tooling": "^1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/ui5.yaml: -------------------------------------------------------------------------------- 1 | specVersion: '2.6' 2 | metadata: 3 | name: bookshop 4 | type: application 5 | server: 6 | customMiddleware: 7 | - name: fiori-tools-proxy 8 | afterMiddleware: compression 9 | configuration: 10 | backend: 11 | - path: /v2/browse 12 | url: https://developer-advocates-free-tier-central-hana-cloud-instan3b540fd6.cfapps.us10.hana.ondemand.com 13 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/Component.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "sap/ui/core/UIComponent" 3 | ], function (UIComponent) { 4 | "use strict" 5 | return UIComponent.extend( 6 | "sap.codejam.Component", { 7 | metadata : { 8 | "interfaces": [ 9 | "sap.ui.core.IAsyncContentCreation" 10 | ], 11 | manifest: "json" 12 | }, 13 | init : function () { 14 | UIComponent.prototype.init.apply( 15 | this, 16 | arguments 17 | ) 18 | } 19 | }) 20 | } 21 | ) -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/controller/App.controller.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "sap/ui/core/mvc/Controller", 3 | "sap/m/MessageToast", 4 | "sap/m/Dialog", 5 | "sap/m/Button", 6 | "sap/m/Text", 7 | "sap/ui/model/Filter", 8 | "sap/ui/model/FilterOperator", 9 | "../model/formatter" 10 | ], function (Controller, MessageToast, Dialog, Button, Text, Filter, FilterOperator, formatter) { 11 | "use strict" 12 | return Controller.extend("sap.codejam.controller.App", { 13 | formatter: formatter, 14 | onSelect: function (oEvent) { 15 | const oSource = oEvent.getSource() 16 | const contextPath = oSource.getBindingContextPath() 17 | const form = this.getView().byId("bookDetails") 18 | form.bindElement(contextPath) 19 | }, 20 | onSubmitOrder: function (oEvent) { 21 | const oBindingContext = this.getView().byId("bookDetails").getBindingContext() 22 | const selectedBookID = oBindingContext.getProperty("ID") 23 | const selectedBookTitle = oBindingContext.getProperty("title") 24 | const inputValue = this.getView().byId("stepInput").getValue() 25 | 26 | const i18nModel = this.getView().getModel("i18n") 27 | const oModel = this.getView().getModel() 28 | oModel.callFunction("/submitOrder", { 29 | method: "POST", 30 | urlParameters: { 31 | "book": selectedBookID, 32 | "quantity": inputValue 33 | }, 34 | success: function(oData, oResponse) { 35 | oModel.refresh() 36 | const oText = `${i18nModel.getProperty("orderSuccessful")} (${selectedBookTitle}, ${inputValue} ${i18nModel.getProperty("pieces")})` 37 | MessageToast.show(oText) 38 | }, 39 | error: function(oError) { 40 | if (oError.responseText) { 41 | oError = JSON.parse(oError.responseText).error 42 | } 43 | this.oErrorMessageDialog = new Dialog({ 44 | type: "Standard", 45 | title: i18nModel.getProperty("Error"), 46 | state: "Error", 47 | content: new Text({ text: oError.message }) 48 | .addStyleClass("sapUiTinyMargin"), 49 | beginButton: new Button({ 50 | text: i18nModel.getProperty("Close"), 51 | press: function () { 52 | this.oErrorMessageDialog.close() 53 | }.bind(this) 54 | }) 55 | }) 56 | this.oErrorMessageDialog.open() 57 | }.bind(this) 58 | }) 59 | }, 60 | onSearch: function (oEvent) { 61 | const sQuery = oEvent.getParameter("newValue") 62 | const aFilter = [] 63 | if (sQuery) { 64 | aFilter.push(new Filter("title", FilterOperator.Contains, sQuery)) 65 | } 66 | const oList = this.byId("booksTable") 67 | const oBinding = oList.getBinding("items") 68 | oBinding.filter(aFilter) 69 | }, 70 | onAfterRendering: function () { 71 | this.getView().byId("orderBtn").setEnabled(false) 72 | } 73 | }) 74 | }) -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/css/style.css: -------------------------------------------------------------------------------- 1 | .orderControls { 2 | gap: 20px; 3 | } -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/i18n/i18n.properties: -------------------------------------------------------------------------------- 1 | Bookshop=Bookshop 2 | Book=Book 3 | Author=Author 4 | Genre=Genre 5 | Price=Price 6 | Stock=Stock 7 | Order=Order 8 | orderSuccessful=Order successful 9 | pieces=pcs. 10 | Error=Error 11 | Close=Close -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/i18n/i18n_de.properties: -------------------------------------------------------------------------------- 1 | Bookshop=Buchhandlung 2 | Book=Buch 3 | Author=Autor 4 | Genre=Genre 5 | Price=Preis 6 | Stock=Verfügbarkeit 7 | Order=Bestellen 8 | orderSuccessful=Bestellung erfolgreich 9 | pieces=Stk. 10 | Error=Fehler 11 | Close=Schließen -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | 18 | 19 |
24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/localService/metadata.xml: -------------------------------------------------------------------------------- 1 | 4 | 7 | 8 | 9 | 11 | 12 | 13 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/localService/mockdata/Books.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "createdAt": "2023-02-22T17:14:38.366Z", 4 | "modifiedAt": "2023-02-22T17:14:38.366Z", 5 | "ID": 201, 6 | "title": "Wuthering Heights", 7 | "descr": "Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym \"Ellis Bell\". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.", 8 | "author": "Emily Brontë", 9 | "genre_ID": 11, 10 | "stock": 0, 11 | "price": 11.11, 12 | "currency_code": "GBP" 13 | }, 14 | { 15 | "createdAt": "2023-02-22T17:14:38.366Z", 16 | "modifiedAt": "2023-02-22T17:14:38.366Z", 17 | "ID": 207, 18 | "title": "Jane Eyre", 19 | "descr": "Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name \"Currer Bel\", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.", 20 | "author": "Charlotte Brontë", 21 | "genre_ID": 11, 22 | "stock": 11, 23 | "price": 12.34, 24 | "currency_code": "GBP" 25 | }, 26 | { 27 | "createdAt": "2023-02-22T17:14:38.366Z", 28 | "modifiedAt": "2023-02-22T17:14:38.366Z", 29 | "ID": 251, 30 | "title": "The Raven", 31 | "descr": "\"The Raven\" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word \"Nevermore\". The poem makes use of folk, mythological, religious, and classical references.", 32 | "author": "Edgar Allen Poe", 33 | "genre_ID": 16, 34 | "stock": 333, 35 | "price": 13.13, 36 | "currency_code": "USD" 37 | }, 38 | { 39 | "createdAt": "2023-02-22T17:14:38.366Z", 40 | "modifiedAt": "2023-02-22T17:14:38.366Z", 41 | "ID": 252, 42 | "title": "Eleonora", 43 | "descr": "\"Eleonora\" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively \"happy\" ending.", 44 | "author": "Edgar Allen Poe", 45 | "genre_ID": 16, 46 | "stock": 555, 47 | "price": 14, 48 | "currency_code": "USD" 49 | }, 50 | { 51 | "createdAt": "2023-02-22T17:14:38.366Z", 52 | "modifiedAt": "2023-02-22T17:14:38.366Z", 53 | "ID": 271, 54 | "title": "Catweazle", 55 | "descr": "Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.", 56 | "author": "Richard Carpenter", 57 | "genre_ID": 13, 58 | "stock": 22, 59 | "price": 150, 60 | "currency_code": "JPY" 61 | } 62 | ] -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/localService/mockdata/Currencies.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Euro", 4 | "descr": null, 5 | "code": "EUR", 6 | "symbol": "€" 7 | }, 8 | { 9 | "name": "British Pound", 10 | "descr": null, 11 | "code": "GBP", 12 | "symbol": "£" 13 | }, 14 | { 15 | "name": "Shekel", 16 | "descr": null, 17 | "code": "ILS", 18 | "symbol": "₪" 19 | }, 20 | { 21 | "name": "Yen", 22 | "descr": null, 23 | "code": "JPY", 24 | "symbol": "¥" 25 | }, 26 | { 27 | "name": "US Dollar", 28 | "descr": null, 29 | "code": "USD", 30 | "symbol": "$" 31 | } 32 | ] -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/localService/mockdata/Genres.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ID": 10, 4 | "name": "Fiction" 5 | }, 6 | { 7 | "ID": 11, 8 | "name": "Drama" 9 | }, 10 | { 11 | "ID": 12, 12 | "name": "Poetry" 13 | }, 14 | { 15 | "ID": 13, 16 | "name": "Fantasy" 17 | }, 18 | { 19 | "ID": 14, 20 | "name": "Science Fiction" 21 | }, 22 | { 23 | "ID": 15, 24 | "name": "Romance" 25 | }, 26 | { 27 | "ID": 16, 28 | "name": "Mystery" 29 | }, 30 | { 31 | "ID": 17, 32 | "name": "Thriller" 33 | }, 34 | { 35 | "ID": 18, 36 | "name": "Dystopia" 37 | }, 38 | { 39 | "ID": 19, 40 | "name": "Fairy Tale" 41 | }, 42 | { 43 | "ID": 20, 44 | "name": "Non-Fiction" 45 | }, 46 | { 47 | "ID": 21, 48 | "name": "Biography" 49 | }, 50 | { 51 | "ID": 22, 52 | "name": "Autobiography" 53 | }, 54 | { 55 | "ID": 23, 56 | "name": "Essay" 57 | }, 58 | { 59 | "ID": 24, 60 | "name": "Speech" 61 | } 62 | ] -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/localService/mockserver.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "sap/ui/core/util/MockServer", 3 | "sap/base/util/UriParameters" 4 | ], function (MockServer, UriParameters) { 5 | "use strict" 6 | 7 | return { 8 | init: function () { 9 | // create 10 | const oMockServer = new MockServer({ 11 | rootUri: "/v2/browse/" 12 | }) 13 | 14 | const oUriParameters = new UriParameters(window.location.href) 15 | 16 | // configure mock server with a delay 17 | MockServer.config({ 18 | autoRespond: true, 19 | autoRespondAfter: oUriParameters.get("serverDelay") || 500 20 | }) 21 | 22 | // simulate 23 | const sPath = sap.ui.require.toUrl("sap/codejam/localService") 24 | oMockServer.simulate(sPath + "/metadata.xml", sPath + "/mockdata") 25 | 26 | // mock custom function 27 | const defaultRequests = oMockServer.getRequests() 28 | oMockServer.setRequests(defaultRequests.concat({ 29 | method: "POST", 30 | path: new RegExp("submitOrder(.*)"), 31 | response: function (oXhr, sUrlParams) { 32 | const responseBody = { d: {} } // sending empty data, just mocking backend functionality 33 | const responseHeader = { "Content-Type": "application/json" } 34 | oXhr.respond(200, responseHeader, JSON.stringify(responseBody)) 35 | } 36 | })) 37 | 38 | // start 39 | oMockServer.start() 40 | } 41 | } 42 | 43 | }) -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "sap.app": { 3 | "id": "codejam", 4 | "type": "application", 5 | "title": "CodeJam Bookshop", 6 | "applicationVersion": { 7 | "version": "1.0.0" 8 | }, 9 | "dataSources": { 10 | "remoteBookshop": { 11 | "uri": "/v2/browse/", 12 | "type" : "OData", 13 | "settings" : { 14 | "odataVersion" : "2.0" 15 | } 16 | } 17 | } 18 | }, 19 | "sap.ui5": { 20 | "rootView": { 21 | "viewName": "sap.codejam.view.App", 22 | "type": "XML", 23 | "id": "app" 24 | }, 25 | "models": { 26 | "": { 27 | "dataSource": "remoteBookshop" 28 | }, 29 | "i18n": { 30 | "type": "sap.ui.model.resource.ResourceModel", 31 | "settings": { 32 | "bundleName": "sap.codejam.i18n.i18n" 33 | } 34 | } 35 | }, 36 | "resources": { 37 | "css": [ 38 | { 39 | "uri": "css/style.css" 40 | } 41 | ] 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/model/formatter.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([], function () { 2 | "use strict" 3 | return { 4 | inputLowerThanStock: function (availableStock) { 5 | const inputValue = this.getView().byId("stepInput").getValue() 6 | return inputValue <= availableStock 7 | } 8 | } 9 | }) -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/test/initMockServer.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "../localService/mockserver" 3 | ], function (mockserver) { 4 | "use strict" 5 | 6 | // initialize the mock server 7 | mockserver.init() 8 | 9 | // initialize the embedded component on the HTML page 10 | sap.ui.require(["sap/ui/core/ComponentSupport"]) 11 | }) -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/test/mockServer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 19 | 20 |
25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /bookshop/finished-webapp/webapp/view/App.view.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 41 | 43 | 45 | 48 | 56 | 57 | 58 | 59 |
60 | 61 | 65 |