diff --git a/rpg-docs/client/style/main.scss b/rpg-docs/client/style/main.scss index 4fef1b62..e8ac388a 100644 --- a/rpg-docs/client/style/main.scss +++ b/rpg-docs/client/style/main.scss @@ -18,16 +18,6 @@ body { background-color: #E0E0E0; } -//fix tabs and core-toolbar having box shadow -core-toolbar { - box-shadow: none; -} - -//give drawer panel a shadow always -core-header-panel[drawer] { - box-shadow: 2px 0px 5px 0px rgba(0,0,0,0.2); -} - //Paragraphs p { margin-bottom: 8px; @@ -77,6 +67,10 @@ paper-icon-item::shadow #contentIcon { right: 24px; } +paper-fab { + background-color: #d13b2e; +} + //Buttons paper-button { color: #000; diff --git a/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.html b/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.html index 3bacd87d..8db8bfe5 100644 --- a/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.html +++ b/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.html @@ -1,40 +1,27 @@ \ No newline at end of file + diff --git a/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.js b/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.js index dcfc96cb..9d8cf28a 100644 --- a/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.js +++ b/rpg-docs/client/views/character/newCharacterDialog/newCharacterDialog.js @@ -1,13 +1,49 @@ -Template.newCharacterDialog.events({ - "tap #addButton": function(event, instance){ - Characters.insert({ - name: instance.find("#nameInput").value, - gender: instance.find("#genderInput").value, - race: instance.find("#raceInput").value, - owner: Meteor.userId(), - }, function(err, id){ - if (err) throw err; - Router.go("characterSheet", {_id: id}); - }); - } +Template.newCharacterDialog.onCreated(function(){ + this.character = {}; + this.schema = new SimpleSchema({ + //strings + name: {type: String}, + gender: {type: String, optional: true}, + race: {type: String, optional: true}, + }); + this.context = this.schema.newContext(); + this.context.runOnce = false; +}); + +Template.newCharacterDialog.helpers({ + invalid(){ + let context = Template.instance().context; + let valid = context.isValid() && context.runOnce; + return !valid; + }, + errorAtts(key){ + let error = Template.instance().context.keyErrorMessage(key); + if (error){ + return { + invalid: true, + ["error-message"]: error, + } + } + }, +}); + +changeFunction = function(field){ + return _.debounce(function(event, instance){ + instance.character[field] = event.currentTarget.value; + instance.schema.clean(instance.character); + instance.context.validate(instance.character); + if (!instance.context.runOnce) instance.context.runOnce = true; + }, 200); +}; + +Template.newCharacterDialog.events({ + "input .nameInput": changeFunction("name"), + "input .genderInput": changeFunction("gender"), + "input .raceInput": changeFunction("race"), + "click .cancelButton": function(event, instance){ + popDialogStack(); + }, + "click .addButton": function(event, instance){ + popDialogStack(instance.character); + }, }); diff --git a/rpg-docs/client/views/characterList/characterList.html b/rpg-docs/client/views/characterList/characterList.html index fd53d2d6..b7bd9d59 100644 --- a/rpg-docs/client/views/characterList/characterList.html +++ b/rpg-docs/client/views/characterList/characterList.html @@ -51,11 +51,7 @@
+ title="Add"> diff --git a/rpg-docs/client/views/characterList/characterList.js b/rpg-docs/client/views/characterList/characterList.js index 825a6fb7..c5971a03 100644 --- a/rpg-docs/client/views/characterList/characterList.js +++ b/rpg-docs/client/views/characterList/characterList.js @@ -22,9 +22,15 @@ Template.characterList.helpers({ Template.characterList.events({ "tap .addCharacter": function(event, template) { - GlobalUI.showDialog({ - heading: "New Character", + pushDialogStack({ template: "newCharacterDialog", - }); + element: event.currentTarget, + callback(character){ + if (!character) return; + character.owner = Meteor.userId(); + let _id = Characters.insert(character); + Router.go("characterSheet", {_id}); + }, + }) }, }); diff --git a/rpg-docs/client/views/feedback/feedback.css b/rpg-docs/client/views/feedback/feedback.css deleted file mode 100644 index fea6940f..00000000 --- a/rpg-docs/client/views/feedback/feedback.css +++ /dev/null @@ -1,7 +0,0 @@ -.feedback .form { - padding: 24px; -} - -.feedback .buttons { - padding: 8px 8px 8px 24px; -} diff --git a/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.css b/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.css index ee93bc36..9f743de7 100644 --- a/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.css +++ b/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.css @@ -50,3 +50,11 @@ background: red; border-radius: 30px; } + +.dialog-stack .dialog .form { + padding: 24px; +} + +.dialog-stack .dialog .buttons { + padding: 8px 8px 8px 24px; +}