Permalink
Find file
c3b45b3 May 15, 2016
109 lines (90 sloc) 2.66 KB
<!--
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../note-app/na-elements.html">
<link rel="import" href="/bower_components/app-storage/app-indexeddb-mirror/app-indexeddb-mirror.html">
<link rel="import" href="/bower_components/polymerfire/polymerfire.html">
<dom-module id="note-app">
<template>
<style include="note-app-shared-styles"></style>
<na-toolbar
signed-in="[[signedIn]]"
on-sign-out="signOut">
</na-toolbar>
<na-login
on-sign-in="signIn"
signed-in="[[signedIn]]"
disabled="[[!online]]">
</na-login>
<firebase-auth
id="auth"
app-name="notes"
provider="google"
signed-in="{{signedIn}}"
user="{{user}}">
</firebase-auth>
<firebase-query
id="query"
app-name="notes"
path="/notes/[[user.uid]]"
data="{{data}}">
</firebase-query>
<app-indexeddb-mirror
session="[[user.uid]]"
key="notes"
data="{{data}}"
persisted-data="{{persistedData}}">
</app-indexeddb-mirror>
<div class="notes">
<template is="dom-repeat" items="[[persistedData]]" as="note">
<na-note
id$="[[note.$key]]"
title="[[note.title]]"
body="[[note.body]]"
on-tap="edit">
</na-note>
</template>
</div>
<paper-fab icon="add" disabled="[[!online]]" on-tap="create"></paper-fab>
<firebase-document
id="document"
app-name="notes"
path="[[editableNoteId]]"
data="{{editableNote}}">
</firebase-document>
<na-editor
id="editor"
note="{{editableNote}}"
on-close="commitChange">
</na-editor>
</template>
<script>
(() => {
'use strict';
Polymer({
is: 'note-app',
behaviors: [
Polymer.NoteAppBehavior
],
get isEditable() {
return this.online;
},
get notesPath() {
return `/notes/${this.user.uid}`;
},
toEditableId(noteId) {
return `${this.notesPath}/${noteId}`;
},
signIn() {
this.$.auth.signInWithPopup();
}
});
})();
</script>
</dom-module>