mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-obrand.git
synced 2025-01-11 03:15:10 +00:00
”2016-03-29”
This commit is contained in:
parent
bf969ce01b
commit
4df6d53584
@ -0,0 +1,5 @@
|
|||||||
|
import ApplicationAdapter from './application';
|
||||||
|
|
||||||
|
export default ApplicationAdapter.extend({
|
||||||
|
namespace:'api'
|
||||||
|
});
|
@ -1,4 +1,48 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
const { service , store } = Ember.inject;
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
|
session: service('session'),
|
||||||
|
sessionAccount: service('session-account'),
|
||||||
|
actions: {
|
||||||
|
savePage: function() {
|
||||||
|
|
||||||
|
console.log('save page');
|
||||||
|
var store = this.get('store');
|
||||||
|
var model = this.get('model');
|
||||||
|
var pageContent = model.get('content');
|
||||||
|
|
||||||
|
var account = this.get('sessionAccount.account');
|
||||||
|
|
||||||
|
console.log(pageContent.get('title'));
|
||||||
|
|
||||||
|
model.set('cid', this.get('sessionAccount.account.memberof'));
|
||||||
|
|
||||||
|
model.save()
|
||||||
|
.then(function(d) {
|
||||||
|
console.log(d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
pageContent.save().then(function(d) {
|
||||||
|
console.log(d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(pageContent.serialize());
|
||||||
|
// This.set('isEditing', false);
|
||||||
|
|
||||||
|
//this.transitionTo('company');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
import DS from 'ember-data';
|
import DS from 'ember-data';
|
||||||
|
|
||||||
export default DS.Model.extend({
|
export default DS.Model.extend({
|
||||||
|
page: DS.belongsTo('page'),
|
||||||
title: DS.attr('string'),
|
title: DS.attr('string'),
|
||||||
imageUrl: DS.attr('string'),
|
imageUrl: DS.attr('string'),
|
||||||
link1Text: DS.attr('string'),
|
link1Text: DS.attr('string'),
|
||||||
@ -10,5 +13,20 @@ export default DS.Model.extend({
|
|||||||
link3Text: DS.attr('string'),
|
link3Text: DS.attr('string'),
|
||||||
link3Url: DS.attr('string'),
|
link3Url: DS.attr('string'),
|
||||||
link4Text: DS.attr('string'),
|
link4Text: DS.attr('string'),
|
||||||
link4Url: DS.attr('string')
|
link4Url: DS.attr('string'),
|
||||||
|
visibleLink1: function() {
|
||||||
|
return !((Ember.isBlank(this.get('link1Text'))) || (Ember.isBlank(this.get('link1Url'))));
|
||||||
|
}.property('link1Url','link1Text'),
|
||||||
|
visibleLink2: function() {
|
||||||
|
return !((Ember.isBlank(this.get('link2Text'))) && (Ember.isBlank(this.get('link2Url'))));
|
||||||
|
}.property('link2Url','link2Text'),
|
||||||
|
visibleLink3: function() {
|
||||||
|
return !((Ember.isBlank(this.get('link3Text'))) && (Ember.isBlank(this.get('link3Url'))));
|
||||||
|
}.property('link3Url','link3Text'),
|
||||||
|
visibleLink4: function() {
|
||||||
|
return !((Ember.isBlank(this.get('link4Text'))) && (Ember.isBlank(this.get('link4Url'))));
|
||||||
|
}.property('link4Url','link4Text'),
|
||||||
|
noImage: function() {
|
||||||
|
return Ember.isBlank(this.get('imageUrl'));
|
||||||
|
}.property('imageUrl')
|
||||||
});
|
});
|
||||||
|
@ -5,5 +5,5 @@ export default DS.Model.extend({
|
|||||||
pid: DS.attr('string'),
|
pid: DS.attr('string'),
|
||||||
category: DS.attr(),
|
category: DS.attr(),
|
||||||
title: DS.attr('string'),
|
title: DS.attr('string'),
|
||||||
content: DS.belongsTo('page-content')
|
content: DS.belongsTo('page-content', {embedded: 'always'})
|
||||||
});
|
});
|
||||||
|
@ -8,10 +8,12 @@ export default Ember.Route.extend({
|
|||||||
'use strict';
|
'use strict';
|
||||||
const cid = this.get('sessionAccount.account.memberOf');
|
const cid = this.get('sessionAccount.account.memberOf');
|
||||||
|
|
||||||
var newPageContent = this.store.createRecord('page-content',{});
|
var newPageContent = this.store.createRecord('page-content',{imageUrl:'http://lorempixel.com/300/300'});
|
||||||
var newPage = this.store.createRecord('page',{});
|
var newPage = this.store.createRecord('page',{});
|
||||||
newPage.set('cid', cid);
|
newPage.set('cid', cid);
|
||||||
newPage.set('content',newPageContent);
|
newPage.set('content',newPageContent);
|
||||||
|
|
||||||
|
newPageContent.set('page',newPage);
|
||||||
return newPage;
|
return newPage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
import DS from 'ember-data';
|
||||||
|
|
||||||
|
export default DS.JSONAPISerializer.extend({
|
||||||
|
serializeBelongsTo: function(record, json, relationship) {
|
||||||
|
var key = relationship.key,
|
||||||
|
belongsTo = Ember.get(record, key);
|
||||||
|
key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo") : key;
|
||||||
|
|
||||||
|
if (relationship.options.embedded === 'always') {
|
||||||
|
json[key] = belongsTo.serialize();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this._super(record, json, relationship);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
serializeHasMany: function(record, json, relationship) {
|
||||||
|
var key = relationship.key,
|
||||||
|
hasMany = Ember.get(record, key),
|
||||||
|
relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
|
||||||
|
|
||||||
|
if (relationship.options.embedded === 'always') {
|
||||||
|
if (hasMany && relationshipType === 'manyToNone' || relationshipType === 'manyToMany' ||
|
||||||
|
relationshipType === 'manyToOne') {
|
||||||
|
|
||||||
|
json[key] = [];
|
||||||
|
hasMany.forEach(function(item, index){
|
||||||
|
json[key].push(item.serialize());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this._super(record, json, relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -52,3 +52,8 @@ body {
|
|||||||
box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.43);
|
box-shadow: 0px 4px 5px 0px rgba(0,0,0,0.43);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image300 {
|
||||||
|
max-width: 300px;
|
||||||
|
max-height: 300px;
|
||||||
|
}
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
<label for="title">Title:</label>
|
<label for="title">Title:</label>
|
||||||
{{input id='title' placeholder='title' value=model.content.title class="form-control" required="required"}}
|
{{input id='title' placeholder='title' value=model.content.title class="form-control" required="required"}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-12 form-inline">
|
||||||
|
<label for="imageUrl">Image URL:</label>
|
||||||
|
{{input id='imageUrl' placeholder='URL to your image' value=model.content.imageUrl class="form-control" required="required"}}
|
||||||
|
</div>
|
||||||
<div class="col-md-12 form-inline">
|
<div class="col-md-12 form-inline">
|
||||||
<div>Link One</div>
|
<div>Link One</div>
|
||||||
<label for="link1title">Text:</label>
|
<label for="link1title">Text:</label>
|
||||||
@ -20,23 +23,88 @@
|
|||||||
|
|
||||||
<label for="link1url">URL:</label>
|
<label for="link1url">URL:</label>
|
||||||
{{input id='link1url' placeholder='http://something.com/link' value=model.content.link1Url class="form-control"}}
|
{{input id='link1url' placeholder='http://something.com/link' value=model.content.link1Url class="form-control"}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-12 form-inline">
|
||||||
|
<div>Link Two</div>
|
||||||
|
<label for="link2title">Text:</label>
|
||||||
|
{{input id='link2title' placeholder='Text' value=model.content.link2Text class="form-control"}}
|
||||||
|
|
||||||
|
<label for="link2url">URL:</label>
|
||||||
|
{{input id='link2url' placeholder='http://something.com/link' value=model.content.link2Url class="form-control"}}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 form-inline">
|
||||||
|
<div>Link Three</div>
|
||||||
|
<label for="link3title">Text:</label>
|
||||||
|
{{input id='link3title' placeholder='Text' value=model.content.link3Text class="form-control"}}
|
||||||
|
|
||||||
|
<label for="link3url">URL:</label>
|
||||||
|
{{input id='link3url' placeholder='http://something.com/link' value=model.content.link3Url class="form-control"}}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 form-inline">
|
||||||
|
<div>Link Four</div>
|
||||||
|
<label for="link4title">Text:</label>
|
||||||
|
{{input id='link4title' placeholder='Text' value=model.content.link4Text class="form-control"}}
|
||||||
|
|
||||||
|
<label for="link4url">URL:</label>
|
||||||
|
{{input id='link4url' placeholder='http://something.com/link' value=model.content.link4Url class="form-control"}}
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<button type="submit" class="btn btn-default">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div></div>
|
||||||
<div class="col-md-8 content">
|
<div class="col-md-8 content">
|
||||||
<div id="fakeDevice" class="fakeDevice">
|
<div id="fakeDevice" class="fakeDevice">
|
||||||
<h1 class="text-xs-center">{{ model.content.title }}</h1>
|
<h1 class="text-xs-center">{{ model.content.title }}</h1>
|
||||||
|
{{#if model.content.noImage }}
|
||||||
<img src="http://pipes.silvrtree.co.uk/assets/fm.png"
|
<img src="http://pipes.silvrtree.co.uk/assets/fm.png"
|
||||||
class="center-block"/>
|
class="center-block image300"/>
|
||||||
<ul class="list-group">
|
{{else}}
|
||||||
{{#if model.content.link1Url }}
|
<img src="{{model.content.imageUrl}}"
|
||||||
<li class="list-group-item">{{#link-to model.content.link1Url}}{{model.content.link1Text}}{{/link-to}}</li>
|
class="center-block image300"/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<li class="list-group-item">List item 2</li>
|
<ul class="list-group">
|
||||||
<li class="list-group-item">List item 3</li>
|
{{#if model.content.visibleLink1 }}
|
||||||
<li class="list-group-item">List item 4</li>
|
<li class="list-group-item text-xs-center"><a
|
||||||
|
href="{{model.content.link1Url}}"
|
||||||
|
target="_blank">{{model.content.link1Text}}</a></li>
|
||||||
|
{{else}}
|
||||||
|
<li class="list-group-item text-muted text-xs-center">
|
||||||
|
<em>Your link here</em></li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
|
{{#if model.content.visibleLink2 }}
|
||||||
|
<li class="list-group-item"><a
|
||||||
|
href="{{model.content.link2Url}}"
|
||||||
|
target="_blank">{{model.content.link2Text}}</a></li>
|
||||||
|
{{else}}
|
||||||
|
<li class="list-group-item text-muted text-xs-center">
|
||||||
|
<em>Your link here</em></li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if model.content.visibleLink3 }}
|
||||||
|
<li class="list-group-item"><a
|
||||||
|
href="{{model.content.link3Url}}"
|
||||||
|
target="_blank">{{model.content.link3Text}}</a></li>
|
||||||
|
{{else}}
|
||||||
|
<li class="list-group-item text-muted text-xs-center">
|
||||||
|
<em>Your link here</em></li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if model.content.visibleLink4 }}
|
||||||
|
<li class="list-group-item"><a
|
||||||
|
href="{{model.content.link4Url}}"
|
||||||
|
target="_blank">{{model.content.link4Text}}</a></li>
|
||||||
|
{{else}}
|
||||||
|
<li class="list-group-item text-muted text-xs-center">
|
||||||
|
<em>Your link here</em></li>
|
||||||
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,11 +52,12 @@
|
|||||||
"express": "^4.13.4",
|
"express": "^4.13.4",
|
||||||
"glob": "^4.5.3",
|
"glob": "^4.5.3",
|
||||||
"loader.js": "^4.0.0",
|
"loader.js": "^4.0.0",
|
||||||
|
"md-utils": "git+http://gitlab.silvrtree.co.uk/martind2000/md-utils.git",
|
||||||
"morgan": "^1.7.0",
|
"morgan": "^1.7.0",
|
||||||
"node-validator": "git+http://gitlab.silvrtree.co.uk/martind2000/node-validator.git",
|
"node-validator": "git+http://gitlab.silvrtree.co.uk/martind2000/node-validator.git",
|
||||||
"md-utils": "git+http://gitlab.silvrtree.co.uk/martind2000/md-utils.git",
|
|
||||||
"oauth2-server": "^2.4.1",
|
"oauth2-server": "^2.4.1",
|
||||||
"pg-promise": "^3.3.0"
|
"pg-promise": "^3.3.0",
|
||||||
|
"util": "^0.10.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcrypt": "^0.8.5",
|
"bcrypt": "^0.8.5",
|
||||||
|
51
dev-archive/censis/obrand/obrand-admin/server/mocks/pages.js
Normal file
51
dev-archive/censis/obrand/obrand-admin/server/mocks/pages.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*jshint node:true*/
|
||||||
|
var util = require('util');
|
||||||
|
|
||||||
|
module.exports = function(app) {
|
||||||
|
var express = require('express');
|
||||||
|
var pagesRouter = express.Router();
|
||||||
|
|
||||||
|
pagesRouter.get('/', function(req, res) {
|
||||||
|
res.send({
|
||||||
|
'pages': []
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
pagesRouter.post('/', function(req, res) {
|
||||||
|
console.log(util.inspect(req.body.data));
|
||||||
|
res.status(201).end();
|
||||||
|
});
|
||||||
|
|
||||||
|
pagesRouter.get('/:id', function(req, res) {
|
||||||
|
res.send({
|
||||||
|
'pages': {
|
||||||
|
id: req.params.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
pagesRouter.put('/:id', function(req, res) {
|
||||||
|
res.send({
|
||||||
|
'pages': {
|
||||||
|
id: req.params.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
pagesRouter.delete('/:id', function(req, res) {
|
||||||
|
res.status(204).end();
|
||||||
|
});
|
||||||
|
|
||||||
|
// The POST and PUT call will not contain a request body
|
||||||
|
// because the body-parser is not included by default.
|
||||||
|
// To use req.body, run:
|
||||||
|
|
||||||
|
// npm install --save-dev body-parser
|
||||||
|
app.use('/api/pages', require('body-parser').json({type: 'application/vnd.api+json'}));
|
||||||
|
|
||||||
|
// After installing, you need to `use` the body-parser for
|
||||||
|
// this mock uncommenting the following line:
|
||||||
|
//
|
||||||
|
//app.use('/api/pages', require('body-parser').json());
|
||||||
|
app.use('/api/pages', pagesRouter);
|
||||||
|
};
|
@ -0,0 +1,12 @@
|
|||||||
|
import { moduleFor, test } from 'ember-qunit';
|
||||||
|
|
||||||
|
moduleFor('adapter:page', 'Unit | Adapter | page', {
|
||||||
|
// Specify the other units that are required for this test.
|
||||||
|
// needs: ['serializer:foo']
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace this with your real tests.
|
||||||
|
test('it exists', function(assert) {
|
||||||
|
let adapter = this.subject();
|
||||||
|
assert.ok(adapter);
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
import { moduleForModel, test } from 'ember-qunit';
|
||||||
|
|
||||||
|
moduleForModel('useful', 'Unit | Serializer | useful', {
|
||||||
|
// Specify the other units that are required for this test.
|
||||||
|
needs: ['serializer:useful']
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace this with your real tests.
|
||||||
|
test('it serializes records', function(assert) {
|
||||||
|
let record = this.subject();
|
||||||
|
|
||||||
|
let serializedRecord = record.serialize();
|
||||||
|
|
||||||
|
assert.ok(serializedRecord);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user