From 3dff5f06ff265a8b160a30837e38298aad105e16 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 26 Feb 2021 09:08:31 +0100 Subject: [PATCH] starred modules front and backend 1st steps --- .../starred-module/getStarredModules.js | 17 +++++ .../specs/getStarredModules.spec.js | 6 ++ back/model-config.json | 6 ++ back/models/module.json | 15 +++++ back/models/starred-module.json | 35 +++++++++++ db/changes/10281-valentineDay/00-module.sql | 4 ++ .../10281-valentineDay/01-starredModule.sql | 10 +++ db/dump/fixtures.sql | 18 +++++- front/salix/components/home/home.html | 63 ++++++++++++++----- front/salix/components/home/home.js | 8 +++ front/salix/components/home/locale/es.yml | 1 + front/salix/components/home/style.scss | 49 +++++++++++---- 12 files changed, 203 insertions(+), 29 deletions(-) create mode 100644 back/methods/starred-module/getStarredModules.js create mode 100644 back/methods/starred-module/specs/getStarredModules.spec.js create mode 100644 back/models/module.json create mode 100644 back/models/starred-module.json create mode 100644 db/changes/10281-valentineDay/00-module.sql create mode 100644 db/changes/10281-valentineDay/01-starredModule.sql create mode 100644 front/salix/components/home/locale/es.yml diff --git a/back/methods/starred-module/getStarredModules.js b/back/methods/starred-module/getStarredModules.js new file mode 100644 index 000000000..e00fc9011 --- /dev/null +++ b/back/methods/starred-module/getStarredModules.js @@ -0,0 +1,17 @@ +module.exports = function(Self) { + Self.remoteMethodCtx('getStarredModules', { + description: 'returns the receved modules adding the starred property.', + returns: { + type: 'object', + root: true + }, + http: { + path: `/getStarredModules`, + verb: 'get' + } + }); + + Self.getStarredModules = async ctx => { + console.log('ctx.req.accessToken.userId', ctx.req.accessToken.userId); + }; +}; diff --git a/back/methods/starred-module/specs/getStarredModules.spec.js b/back/methods/starred-module/specs/getStarredModules.spec.js new file mode 100644 index 000000000..0bfa9f3a8 --- /dev/null +++ b/back/methods/starred-module/specs/getStarredModules.spec.js @@ -0,0 +1,6 @@ +const app = require('vn-loopback/server/server'); + +describe('getStarredModule()', () => { + it(`should return the starred modules for a given user`, async() => { + }); +}); diff --git a/back/model-config.json b/back/model-config.json index 7759c32fa..418cd4d1f 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -59,6 +59,9 @@ "Language": { "dataSource": "vn" }, + "Module": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, @@ -71,6 +74,9 @@ "SageWithholding": { "dataSource": "vn" }, + "StarredModule": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/module.json b/back/models/module.json new file mode 100644 index 000000000..0f5074157 --- /dev/null +++ b/back/models/module.json @@ -0,0 +1,15 @@ +{ + "name": "Module", + "base": "VnModel", + "options": { + "mysql": { + "table": "salix.module" + } + }, + "properties": { + "code": { + "type": "string", + "id": true + } + } +} diff --git a/back/models/starred-module.json b/back/models/starred-module.json new file mode 100644 index 000000000..b53a906d0 --- /dev/null +++ b/back/models/starred-module.json @@ -0,0 +1,35 @@ +{ + "name": "StarredModule", + "base": "VnModel", + "options": { + "mysql": { + "table": "vn.starredmodule" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "workerFk": { + "type": "number", + "required": true + }, + "moduleFk": { + "type": "string", + "required": true + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "module": { + "type": "belongsTo", + "model": "Module", + "foreignKey": "moduleFk" + } + } +} diff --git a/db/changes/10281-valentineDay/00-module.sql b/db/changes/10281-valentineDay/00-module.sql new file mode 100644 index 000000000..d3cfa0f4d --- /dev/null +++ b/db/changes/10281-valentineDay/00-module.sql @@ -0,0 +1,4 @@ +CREATE TABLE `salix`.`module` ( + `code` VARCHAR(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10281-valentineDay/01-starredModule.sql b/db/changes/10281-valentineDay/01-starredModule.sql new file mode 100644 index 000000000..e36777030 --- /dev/null +++ b/db/changes/10281-valentineDay/01-starredModule.sql @@ -0,0 +1,10 @@ +CREATE TABLE `vn`.`starredModule` ( + `id` INT(11) unsigned NOT NULL AUTO_INCREMENT, + `workerFk` INT(10) NOT NULL, + `moduleFk` VARCHAR(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `starred_workerFk` (`workerFk`), + KEY `starred_moduleFk` (`moduleFk`), + CONSTRAINT `starred_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `starred_moduleFk` FOREIGN KEY (`moduleFk`) REFERENCES `salix`.`module` (`code`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d821c7bfc..cef9783dd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2174,4 +2174,20 @@ INSERT INTO `hedera`.`image`(`collectionFk`, `name`) INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`) VALUES - (1, 4, 160, 160); \ No newline at end of file + (1, 4, 160, 160); + +INSERT INTO `salix`.`module`(`code`) + VALUES + ('Items'), + ('Oders'), + ('Clients'), + ('Entries'), + ('Travels'), + ('Invoices out'), + ('Suppliers'), + ('Claims'), + ('Routes'), + ('Tickets'), + ('Workers'), + ('Users'), + ('Zones'); \ No newline at end of file diff --git a/front/salix/components/home/home.html b/front/salix/components/home/home.html index ada51d76f..f9d5c705e 100644 --- a/front/salix/components/home/home.html +++ b/front/salix/components/home/home.html @@ -1,20 +1,51 @@
+
+ Favorites +
+
+
+
+
+
diff --git a/front/salix/components/home/home.js b/front/salix/components/home/home.js index 3da49a265..16f6047e5 100644 --- a/front/salix/components/home/home.js +++ b/front/salix/components/home/home.js @@ -9,6 +9,14 @@ export default class Controller extends Component { this.$sce = $sce; } + get modules() { + return this._modules; + } + + set modules(value) { + this._modules = value; + } + getModuleName(mod) { let getName = mod => { let name = this.$t(mod.name); diff --git a/front/salix/components/home/locale/es.yml b/front/salix/components/home/locale/es.yml new file mode 100644 index 000000000..f4595aaef --- /dev/null +++ b/front/salix/components/home/locale/es.yml @@ -0,0 +1 @@ +Favorites: Favoritos \ No newline at end of file diff --git a/front/salix/components/home/style.scss b/front/salix/components/home/style.scss index 7524d2be3..11cc612db 100644 --- a/front/salix/components/home/style.scss +++ b/front/salix/components/home/style.scss @@ -10,28 +10,57 @@ vn-home { text-align: center; margin-bottom: 15px; } + + & > .top-border { + margin: 0 auto; + flex-direction: row; + float: center; + max-width: 690px; + border-bottom: 2px solid $color-font-secondary; + line-height: 2px; + + > span { + height: 10px; + margin-left: 30px; + background-color: $color-bg; + padding:0 11px; + } + } + & > .modules { + padding: 10px 0 10px 0; display: flex; - flex: 1; - flex-direction: row; - justify-content: center; flex-wrap: wrap; + flex: 1; max-width: 704px; margin: 0 auto; & > a { @extend %clickable-light; - overflow:hidden; - border-radius: 6px; - background-color: $color-button; - color: $color-font-dark; display: flex; flex-direction: column; + overflow:hidden; + justify-content: center; + border-radius: 6px; height: 128px; width: 128px; margin: 8px; padding: 16px; - justify-content: center; + background-color: $color-button; + color: $color-font-dark; + + & .pin { + opacity: 0; + flex-direction: row; + justify-content: left; + height: 0px; + vn-icon { + font-size: 1rem; + } + } + &:hover .pin { + opacity: 1; + } & > div { height: 70px; @@ -56,10 +85,6 @@ vn-home { color: inherit; margin: 0; line-height: 24px; - - /* & > .bind-letter { - color: #FD0; - } */ } } }