”2016-04-01”

This commit is contained in:
Martin Donnelly 2016-04-01 16:45:00 +01:00
parent 98dc4e49ab
commit 89d11de315
5 changed files with 195 additions and 136 deletions

View File

@ -3,6 +3,7 @@ const { service , store } = Ember.inject;
export default Ember.Controller.extend({
session: service('session'),
sessionAccount: service('session-account'),
actions: {
savePage: function() {
@ -23,9 +24,33 @@ export default Ember.Controller.extend({
console.log(err);
});
// This.set('isEditing', false);
},
//This.transitionTo('company');
}
createNew: function() {
'use strict';
console.log('Create a new page');
var model = this.get('model');
const cid = this.get('sessionAccount.account.memberof');
var store = this.get('store');
var model = this.get('model');
var newPage = store.createRecord('page',{cid: cid,vid: 'JPnbDnRzwDSNLTCcS4miFq', content: 0, imageUrl: 'http://lorempixel.com/300/300'});
console.log(newPage);
this.set('content',newPage);
this.set('isEditing', true);
}, cancelEdit: function() {
var model = this.get('model');
model.rollbackAttributes();
model = this.store.findAll('page');
this.set('isEditing', false);
this.set('model', model);
}
}
});

View File

@ -30,5 +30,9 @@ export default DS.Model.extend({
}.property('link4Url','link4Text'),
noImage: function() {
return Ember.isBlank(this.get('imageUrl'));
}.property('imageUrl')
}.property('imageUrl'),
pageMode: function() {
let modeArray = ['Basic Page', 'Other type 1', 'Other type 2', 'Other type 3'];
return modeArray[this.get('content')];
}.property('content')
});

View File

@ -4,15 +4,26 @@ const { inject: { service }, RSVP } = Ember;
export default Ember.Route.extend({
sessionAccount: service('session-account'),
beforeModel() {
'use strict';
const cid = this.get('sessionAccount.account.memberof');
console.log(cid);
this.store.query('page', { filter: { cid: cid } }).then(function(d) {
// Do something with `peters`
// console.log(d);
return d;
});
},
model: function(params) {
'use strict';
return this.store.findAll('page');
/* 'use strict';
const cid = this.get('sessionAccount.account.memberof');
console.log(cid);
this.store.query('page', { filter: { cid: cid } }).then(function(d) {
// Do something with `peters`
console.log(d);
return d;
});*/
var newPage = this.store.createRecord('page',{cid:cid,vid:'JPnbDnRzwDSNLTCcS4miFq', content:0, imageUrl:'http://lorempixel.com/300/300'});
// newPage.set('cid', cid);
// newPage.set('imageUrl','http://lorempixel.com/300/300');
return newPage;
}
}
});

View File

@ -9,15 +9,7 @@ export default Ember.Route.extend({
'use strict';
const accountId = this.get('sessionAccount.account.id');
/*return new RSVP.Promise((resolve,reject) => {
return this.get('store').find('profile',accountId)
.then(function(p) {
resolve(p);
},reject);
});*/
return new RSVP.Promise((resolve,reject) => {
console.log('***HERE***');
return this.get('store').find('profile',accountId)
.then(resolve,reject);
});

View File

@ -1,129 +1,156 @@
<div class="container-fluid main-container">
<div class="col-md-12 content">
<div class="card">
<div class="card-block">
<div class="row">
<div class="col-md-4 content">
<button class="btn btn-primary-outline">Create a new page</button>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
New Page
</div>
<div class="card-block">
<div class="row">
<div class="col-md-4 content">
<form {{action "savePage" on='submit'}}>
<div class="col-md-12 form-inline">
<label for="title">Title:</label>
{{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.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.link1Text class="form-control"}}
<label for="link1url">URL:</label>
{{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.link2Text class="form-control"}}
<label for="link2url">URL:</label>
{{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.link3Text class="form-control"}}
<label for="link3url">URL:</label>
{{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.link4Text class="form-control"}}
<label for="link4url">URL:</label>
{{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">
<button type="submit" class="btn btn-primary">Save</button>
<button class="btn btn-danger">Cancel</button>
</div>
</div>
</form>
</div>
<div></div>
<div class="col-md-8 content">
<div id="fakeDevice" class="fakeDevice">
<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.imageUrl}}"
class="center-block image300"/>
{{/if}}
<ul class="list-group">
{{#if model.visibleLink1 }}
<li class="list-group-item text-xs-center"><a
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.visibleLink2 }}
<li class="list-group-item"><a
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.visibleLink3 }}
<li class="list-group-item"><a
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.visibleLink4 }}
<li class="list-group-item"><a
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>
{{/if}}
</ul>
</div>
<button
class="btn btn-primary-outline" {{action "createNew"}}>Create a new basic page
</button>
</div>
</div>
</div>
</div>
{{#unless isEditing}}
<div class="card">
<div class="card-block">
{{#each model as |item|}}
<div class="row">
<div class="col-md-4 content">
{{item.title}}
</div>
<div class="col-md-4 content">
{{item.pageMode}}
</div>
<div class="col-md-4 content">
<button class="btn btn-primary btn-sm">Edit</button>
<button class="btn btn-danger btn-sm">Delete</button>
</div>
</div>
{{/each}}
</div>
</div>
{{/unless}}
{{#if isEditing}}
<div class="card">
<div class="card-header">
New Page
</div>
<div class="card-block">
<div class="row">
<div class="col-md-4 content">
<form {{action "savePage" on='submit'}}>
<div class="col-md-12 form-inline">
<label for="title">Title:</label>
{{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.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.link1Text class="form-control"}}
<label for="link1url">URL:</label>
{{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.link2Text class="form-control"}}
<label for="link2url">URL:</label>
{{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.link3Text class="form-control"}}
<label for="link3url">URL:</label>
{{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.link4Text class="form-control"}}
<label for="link4url">URL:</label>
{{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">
<button type="submit" class="btn btn-primary">Save</button>
<button
class="btn btn-danger" {{action "cancelEdit"}}>Cancel
</button>
</div>
</div>
</form>
</div>
<div></div>
<div class="col-md-8 content">
<div id="fakeDevice" class="fakeDevice">
<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.imageUrl}}" class="center-block image300"/>
{{/if}}
<ul class="list-group">
{{#if model.visibleLink1 }}
<li class="list-group-item text-xs-center"><a
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.visibleLink2 }}
<li class="list-group-item text-xs-center"><a
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.visibleLink3 }}
<li class="list-group-item text-xs-center"><a
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.visibleLink4 }}
<li class="list-group-item text-xs-center"><a
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>
{{/if}}
</ul>
</div>
</div>
</div>
</div>
</div>
{{/if}}
</div>
</div>