”2016-03-30”

This commit is contained in:
Martin Donnelly 2016-03-30 09:33:33 +01:00
parent 4df6d53584
commit f44ce7e5f9
4 changed files with 51 additions and 48 deletions

View File

@ -9,14 +9,9 @@ export default Ember.Controller.extend({
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);
@ -28,18 +23,6 @@ export default Ember.Controller.extend({
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');

View File

@ -5,5 +5,28 @@ export default DS.Model.extend({
pid: DS.attr('string'),
category: DS.attr(),
title: DS.attr('string'),
content: DS.belongsTo('page-content', {embedded: 'always'})
imageUrl: DS.attr('string'),
link1Text: DS.attr('string'),
link1Url: DS.attr('string'),
link2Text: DS.attr('string'),
link2Url: DS.attr('string'),
link3Text: DS.attr('string'),
link3Url: DS.attr('string'),
link4Text: 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')
});

View File

@ -8,12 +8,9 @@ export default Ember.Route.extend({
'use strict';
const cid = this.get('sessionAccount.account.memberOf');
var newPageContent = this.store.createRecord('page-content',{imageUrl:'http://lorempixel.com/300/300'});
var newPage = this.store.createRecord('page',{});
newPage.set('cid', cid);
newPage.set('content',newPageContent);
newPageContent.set('page',newPage);
newPage.set('imageUrl','http://lorempixel.com/300/300');
return newPage;
}

View File

@ -10,43 +10,43 @@
<form {{action "savePage" on='submit'}}>
<div class="col-md-12 form-inline">
<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.title class="form-control" required="required"}}
</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"}}
{{input id='imageUrl' placeholder='URL to your image' value=model.imageUrl class="form-control" required="required"}}
</div>
<div class="col-md-12 form-inline">
<div>Link One</div>
<label for="link1title">Text:</label>
{{input id='link1title' placeholder='Text' value=model.content.link1Text class="form-control"}}
{{input id='link1title' placeholder='Text' value=model.link1Text class="form-control"}}
<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.link1Url class="form-control"}}
</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"}}
{{input id='link2title' placeholder='Text' value=model.link2Text class="form-control"}}
<label for="link2url">URL:</label>
{{input id='link2url' placeholder='http://something.com/link' value=model.content.link2Url class="form-control"}}
{{input id='link2url' placeholder='http://something.com/link' value=model.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"}}
{{input id='link3title' placeholder='Text' value=model.link3Text class="form-control"}}
<label for="link3url">URL:</label>
{{input id='link3url' placeholder='http://something.com/link' value=model.content.link3Url class="form-control"}}
{{input id='link3url' placeholder='http://something.com/link' value=model.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"}}
{{input id='link4title' placeholder='Text' value=model.link4Text class="form-control"}}
<label for="link4url">URL:</label>
{{input id='link4url' placeholder='http://something.com/link' value=model.content.link4Url class="form-control"}}
{{input id='link4url' placeholder='http://something.com/link' value=model.link4Url class="form-control"}}
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
@ -59,48 +59,48 @@
<div></div>
<div class="col-md-8 content">
<div id="fakeDevice" class="fakeDevice">
<h1 class="text-xs-center">{{ model.content.title }}</h1>
{{#if model.content.noImage }}
<h1 class="text-xs-center">{{ model.title }}</h1>
{{#if model.noImage }}
<img src="http://pipes.silvrtree.co.uk/assets/fm.png"
class="center-block image300"/>
{{else}}
<img src="{{model.content.imageUrl}}"
<img src="{{model.imageUrl}}"
class="center-block image300"/>
{{/if}}
<ul class="list-group">
{{#if model.content.visibleLink1 }}
{{#if model.visibleLink1 }}
<li class="list-group-item text-xs-center"><a
href="{{model.content.link1Url}}"
target="_blank">{{model.content.link1Text}}</a></li>
href="{{model.link1Url}}"
target="_blank">{{model.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 }}
{{#if model.visibleLink2 }}
<li class="list-group-item"><a
href="{{model.content.link2Url}}"
target="_blank">{{model.content.link2Text}}</a></li>
href="{{model.link2Url}}"
target="_blank">{{model.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 }}
{{#if model.visibleLink3 }}
<li class="list-group-item"><a
href="{{model.content.link3Url}}"
target="_blank">{{model.content.link3Text}}</a></li>
href="{{model.link3Url}}"
target="_blank">{{model.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 }}
{{#if model.visibleLink4 }}
<li class="list-group-item"><a
href="{{model.content.link4Url}}"
target="_blank">{{model.content.link4Text}}</a></li>
href="{{model.link4Url}}"
target="_blank">{{model.link4Text}}</a></li>
{{else}}
<li class="list-group-item text-muted text-xs-center">
<em>Your link here</em></li>