Browse Source

loading icon for editor

pull/1/head
wes 8 years ago
parent
commit
0ffd701716
  1. 18
      src/scripts/editor.tag

18
src/scripts/editor.tag

@ -1,5 +1,6 @@
<editor> <editor>
<div class="centered container"> <loading if={this.loading}></loading>
<div if={!this.loading} class="centered container">
<div class="columns"> <div class="columns">
<div class="column col-6"> <div class="column col-6">
<div> <div>
@ -60,6 +61,7 @@
</div> </div>
</div> </div>
<script> <script>
import './loading.tag';
import './raw.tag'; import './raw.tag';
import 'whatwg-fetch'; import 'whatwg-fetch';
import { default as showdown } from 'showdown'; import { default as showdown } from 'showdown';
@ -67,6 +69,7 @@ import { default as R } from 'ramda';
import querystring from 'querystring'; import querystring from 'querystring';
import Z from './zipper.js'; import Z from './zipper.js';
this.loading = false;
this.R = R; this.R = R;
this.querystring = querystring; this.querystring = querystring;
@ -149,9 +152,11 @@ newPost() {
this.refs.title.value = ""; this.refs.title.value = "";
this.refs.author.value = ""; this.refs.author.value = "";
this.refs.textarea.value = ""; this.refs.textarea.value = "";
this._id = false;
/* must overwrite the current _id */ /* must overwrite the current _id */
/* otherwise it overwrites the current post */ /* otherwise it overwrites the current post */
this._id = false;
this.isNewPost = true; this.isNewPost = true;
this.echo(); this.echo();
this.update(); this.update();
@ -166,6 +171,7 @@ submit() {
}; };
if (this._id) { if (this._id) {
/* If the post has an _id then it exists and we are editing it */
post["_id"] = this._id; post["_id"] = this._id;
} }
@ -181,8 +187,6 @@ submit() {
axios.post("/blog/insert/", postQuery, headers) axios.post("/blog/insert/", postQuery, headers)
.then(function(resp) { .then(function(resp) {
/* Refresh the current list of posts */ /* Refresh the current list of posts */
/* self.listPosts(); */
/* This post has been added, so insert it in the current position */ /* This post has been added, so insert it in the current position */
console.log("the post was successfully added"); console.log("the post was successfully added");
@ -206,21 +210,27 @@ submit() {
loadPost(_id) { loadPost(_id) {
return function() { return function() {
console.log("started loading");
self.update({"loading" : true});
if (!_id) { if (!_id) {
console.log("couldn't load the post"); console.log("couldn't load the post");
return false; return false;
} }
axios.get(`/blog/getpost/${_id}`) axios.get(`/blog/getpost/${_id}`)
.then(function(resp) { .then(function(resp) {
self.update({"loading" : false});
self.one("updated", function() {
self.refs.textarea.value = resp.data.content; self.refs.textarea.value = resp.data.content;
self.refs.title.value = resp.data.title; self.refs.title.value = resp.data.title;
self.refs.author.value = resp.data.author; self.refs.author.value = resp.data.author;
self._id = resp.data._id; self._id = resp.data._id;
self.focused = true; self.focused = true;
self.isNewPost = false; self.isNewPost = false;
console.log("loaded");
self.update(); self.update();
self.echo(); self.echo();
});
}) })
.catch(function(err) { .catch(function(err) {
console.log(err); console.log(err);

Loading…
Cancel
Save