From f44ce7e5f932f2d04c4f3a123937a96f7d68c076 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Wed, 30 Mar 2016 09:33:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9D2016-03-30=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../obrand-admin/app/controllers/pages.js | 19 +------ .../obrand/obrand-admin/app/models/page.js | 25 +++++++++- .../obrand/obrand-admin/app/routes/pages.js | 5 +- .../obrand-admin/app/templates/pages.hbs | 50 +++++++++---------- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/dev-archive/censis/obrand/obrand-admin/app/controllers/pages.js b/dev-archive/censis/obrand/obrand-admin/app/controllers/pages.js index 87e86e4..9d2ab1b 100644 --- a/dev-archive/censis/obrand/obrand-admin/app/controllers/pages.js +++ b/dev-archive/censis/obrand/obrand-admin/app/controllers/pages.js @@ -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'); diff --git a/dev-archive/censis/obrand/obrand-admin/app/models/page.js b/dev-archive/censis/obrand/obrand-admin/app/models/page.js index d42548e..95096c7 100644 --- a/dev-archive/censis/obrand/obrand-admin/app/models/page.js +++ b/dev-archive/censis/obrand/obrand-admin/app/models/page.js @@ -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') }); diff --git a/dev-archive/censis/obrand/obrand-admin/app/routes/pages.js b/dev-archive/censis/obrand/obrand-admin/app/routes/pages.js index 8a888b4..2855a70 100644 --- a/dev-archive/censis/obrand/obrand-admin/app/routes/pages.js +++ b/dev-archive/censis/obrand/obrand-admin/app/routes/pages.js @@ -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; } diff --git a/dev-archive/censis/obrand/obrand-admin/app/templates/pages.hbs b/dev-archive/censis/obrand/obrand-admin/app/templates/pages.hbs index e2f04d1..1b1846e 100644 --- a/dev-archive/censis/obrand/obrand-admin/app/templates/pages.hbs +++ b/dev-archive/censis/obrand/obrand-admin/app/templates/pages.hbs @@ -10,43 +10,43 @@
- {{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"}}
- {{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"}}
Link One
- {{input id='link1title' placeholder='Text' value=model.content.link1Text class="form-control"}} + {{input id='link1title' placeholder='Text' value=model.link1Text class="form-control"}} - {{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"}}
Link Two
- {{input id='link2title' placeholder='Text' value=model.content.link2Text class="form-control"}} + {{input id='link2title' placeholder='Text' value=model.link2Text class="form-control"}} - {{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"}}
Link Three
- {{input id='link3title' placeholder='Text' value=model.content.link3Text class="form-control"}} + {{input id='link3title' placeholder='Text' value=model.link3Text class="form-control"}} - {{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"}}
Link Four
- {{input id='link4title' placeholder='Text' value=model.content.link4Text class="form-control"}} + {{input id='link4title' placeholder='Text' value=model.link4Text class="form-control"}} - {{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"}}
@@ -59,48 +59,48 @@
-

{{ model.content.title }}

- {{#if model.content.noImage }} +

{{ model.title }}

+ {{#if model.noImage }} {{else}} - {{/if}}
    - {{#if model.content.visibleLink1 }} + {{#if model.visibleLink1 }}
  • {{model.content.link1Text}}
  • + href="{{model.link1Url}}" + target="_blank">{{model.link1Text}} {{else}}
  • Your link here
  • {{/if}} - {{#if model.content.visibleLink2 }} + {{#if model.visibleLink2 }}
  • {{model.content.link2Text}}
  • + href="{{model.link2Url}}" + target="_blank">{{model.link2Text}} {{else}}
  • Your link here
  • {{/if}} - {{#if model.content.visibleLink3 }} + {{#if model.visibleLink3 }}
  • {{model.content.link3Text}}
  • + href="{{model.link3Url}}" + target="_blank">{{model.link3Text}} {{else}}
  • Your link here
  • {{/if}} - {{#if model.content.visibleLink4 }} + {{#if model.visibleLink4 }}
  • {{model.content.link4Text}}
  • + href="{{model.link4Url}}" + target="_blank">{{model.link4Text}} {{else}}
  • Your link here