diff --git a/.gitignore b/.gitignore index 632712f..e2ecb1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Logs logs -*.log +*.log* # Runtime data pids diff --git a/config/default.js b/config/default.js index 538af58..d18bdf9 100644 --- a/config/default.js +++ b/config/default.js @@ -20,6 +20,7 @@ module.exports = { edit: 'edit', revisions: 'revisions', save: 'save', + new: 'Save Revision', }, directory: path.join(__dirname, '../content-types'), messages: { diff --git a/content-types/services.yml b/content-types/services.yml index 205e703..861222c 100644 --- a/content-types/services.yml +++ b/content-types/services.yml @@ -8,6 +8,7 @@ attributes: id: service-name name: Service Name description: Write a really cool name please. + required: save inputs: text: placeholder: add svc name @@ -15,12 +16,14 @@ attributes: id: service-desciption name: Service Desc description: Write your brief desciption + required: publish inputs: text: placeholder: add svc desc - type: text id: service-url name: Service URL + required: publish inputs: text: placeholder: add svc url diff --git a/lib/routes/content.js b/lib/routes/content.js index 949901d..f8859c4 100644 --- a/lib/routes/content.js +++ b/lib/routes/content.js @@ -347,6 +347,7 @@ const routes = application => { const type = utils.singleItem('id', req.params.type.toLowerCase(), types); const workflow = workflows.workflow(type, allflows, config); let audits; + let check = 'publish'; // check type exists if (!utils.content.check.type(req, type)) { @@ -358,10 +359,12 @@ const routes = application => { return next(); } - // Validation - const validated = content.form.validate(req.body, type); + if (req.body.submit === config.content.actions.new) { + check = 'save'; + } - // utils.log(validated); + // Validation + const validated = content.form.validate(req.body, type, check); if (validated === true) { // id @@ -388,19 +391,25 @@ const routes = application => { const rev = { approval, }; + const self = workflow.steps[approval].hasOwnProperty('self') && workflow.steps[approval].self === true; - if (workflow.steps[approval].hasOwnProperty('self') && workflow.steps[approval].self === true) { - rev.approval = 1; - request.body['comment-textarea'] = 'Self published'; - request.body['action--select'] = 'self-published'; - audits = workflows.audits(rev, workflow, request); + if (self) { + rev.approval++; } - else { - request.body['comment-textarea'] = 'content submitted'; - request.body['action--select'] = 'submit'; - audits = workflows.audits(rev, workflow, request); + + if (check === 'publish') { + if (self) { + request.body['comment-textarea'] = 'Self published'; + request.body['action--select'] = 'self-published'; + } + else { + request.body['comment-textarea'] = 'content submitted'; + request.body['action--select'] = 'submit'; + } } + audits = workflows.audits(rev, workflow, request); + const data = utils.format(req.body); const insert = { diff --git a/package.json b/package.json index 496d9f9..8071d7b 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "passport": "^0.3.2", "passport-local": "^1.0.0", "pg": "^6.0.0", - "punchcard-content-types": "^4.0.8", + "punchcard-content-types": "^4.1.0", "sass-toolkit": "^2.10.0", "serve-favicon": "^2.3.0", "underscore.string": "^3.3.4", diff --git a/src/sass/partials/components/_forms.scss b/src/sass/partials/components/_forms.scss index 4664446..9a0ba52 100644 --- a/src/sass/partials/components/_forms.scss +++ b/src/sass/partials/components/_forms.scss @@ -61,6 +61,32 @@ } } + &--publish-container { + background-color: color('neutral-white', 40); + margin-top: setting-get('rhythm') / .5; + order: 0; + padding: setting-get('rhythm') / .75; + + @include breakpoint(setting-get('responsive form')) { + background-color: transparent; + padding: 0; + width: 48%; + } + } + + &--publish-fields { + + @include breakpoint(setting-get('responsive form')) { + background-color: color('neutral-white', 40); + order: 1; + padding: setting-get('rhythm') / .5; + } + + :first-child { + margin-top: 0; + } + } + &--legend { background-color: color('neutral-white', 40); border: setting-get('input border width') solid color('neutral-white', 40); @@ -76,6 +102,7 @@ width: 100%; @include breakpoint(setting-get('responsive form')) { flex-grow: 1; + order: 2; } } @@ -136,6 +163,8 @@ &--button, &--submit { @include button(setting-get('primary accent color'), setting-get('primary accent color'), setting-get('primary color'), setting-get('primary accent color'), setting-get('primary color'), setting-get('primary color'), setting-get('primary color')); + + margin-top: 0; } &--cancel { diff --git a/tests/server.js b/tests/server.js index 431bba1..35c127a 100644 --- a/tests/server.js +++ b/tests/server.js @@ -53,8 +53,7 @@ const service = [ approval: 2, value: { 'service-name': { - 'text': - { + 'text': { 'value': 'This is the test title', }, }, diff --git a/views/content/_form-content.html b/views/content/_form-content.html index d5d9b43..67a2c20 100644 --- a/views/content/_form-content.html +++ b/views/content/_form-content.html @@ -2,29 +2,36 @@
{{form.html | safe}}
-
-
- Select Sunrise and Sunset -
- - -
-
- - -
-
- - -
-
- - -
-
-
+
- + Cancel
+ +
+
+
+ Select Sunrise and Sunset +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+