Skip to content

Commit

Permalink
Merge pull request #240 from Snugug/feature/save-revision-no-conflict
Browse files Browse the repository at this point in the history
Feature/save revision no conflict
  • Loading branch information
scottnath committed Aug 10, 2016
2 parents 0af68ca + 3b5efa5 commit 62657e2
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Logs
logs
*.log
*.log*

# Runtime data
pids
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
edit: 'edit',
revisions: 'revisions',
save: 'save',
new: 'Save Revision',
},
directory: path.join(__dirname, '../content-types'),
messages: {
Expand Down
3 changes: 3 additions & 0 deletions content-types/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ attributes:
id: service-name
name: Service Name
description: Write a really cool name please.
required: save
inputs:
text:
placeholder: add svc name
- type: text
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
Expand Down
33 changes: 21 additions & 12 deletions lib/routes/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 29 additions & 0 deletions src/sass/partials/components/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -76,6 +102,7 @@
width: 100%;
@include breakpoint(setting-get('responsive form')) {
flex-grow: 1;
order: 2;
}
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ const service = [
approval: 2,
value: {
'service-name': {
'text':
{
'text': {
'value': 'This is the test title',
},
},
Expand Down
51 changes: 29 additions & 22 deletions views/content/_form-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,36 @@
<div class="form--field-container">
{{form.html | safe}}
</div>
<div class="form--field-container">
<fieldset class="form--fieldset">
<legend class="form--legend">Select Sunrise and Sunset</legend>
<div id="sunrise-sunset" class="form--field">
<label for="sunrise-date">Sunrise date</label>
<input type="date" name="sunrise-date" id="sunrise-date" value="{{data['sunrise-date'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunrise-time">Sunrise time</label>
<input type="time" name="sunrise-time" id="sunrise-time" value="{{data['sunrise-time'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunset-date">Sunset date</label>
<input type="date" name="sunset-date" id="sunset-date" value="{{data['sunset-date'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunset-time">Sunset time</label>
<input type="time" name="sunset-time" id="sunset-time" value="{{data['sunset-time'].value}}">
</div>
</fieldset>
</div>

<div class="form--actions">
<button type="submit" class="form--submit">{{step.name}}</button>
<input type="submit" name="submit" value="{{config.actions.new}}" class="form--submit">
<a href="../" class="form--cancel">Cancel</a>
</div>

<section class="form--publish-container">
<div class="form--publish-fields">
<fieldset class="form--fieldset">
<legend class="form--legend">Select Sunrise and Sunset</legend>
<div id="sunrise-sunset" class="form--field">
<label for="sunrise-date">Sunrise date</label>
<input type="date" name="sunrise-date" id="sunrise-date" value="{{data['sunrise-date'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunrise-time">Sunrise time</label>
<input type="time" name="sunrise-time" id="sunrise-time" value="{{data['sunrise-time'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunset-date">Sunset date</label>
<input type="date" name="sunset-date" id="sunset-date" value="{{data['sunset-date'].value}}">
</div>
<div id="sunrise-sunset" class="form--field">
<label for="sunset-time">Sunset time</label>
<input type="time" name="sunset-time" id="sunset-time" value="{{data['sunset-time'].value}}">
</div>
</fieldset>
</div>
<div class="form--actions">
<input type="submit" name="submit" value="{{step.name}}" class="form--submit">
</div>
</section>
</form>

0 comments on commit 62657e2

Please sign in to comment.