️ Sync Collection -> Notes

This commit is contained in:
Liyas Thomas
2020-02-02 08:31:06 +05:30
parent 4c62baa577
commit 7cf5345c5a
5 changed files with 46 additions and 39 deletions

View File

@@ -3,10 +3,10 @@
v-if="fb.currentFeeds.length !== 0" v-if="fb.currentFeeds.length !== 0"
class="virtual-list" class="virtual-list"
:class="{ filled: fb.currentFeeds.length }" :class="{ filled: fb.currentFeeds.length }"
:size="56" :size="90"
:remain="Math.min(8, fb.currentFeeds.length)" :remain="Math.min(5, fb.currentFeeds.length)"
> >
<ul v-for="feed in fb.currentFeeds" :key="feed.id"> <ul v-for="feed in fb.currentFeeds" :key="feed.id" class="entry">
<div class="show-on-large-screen"> <div class="show-on-large-screen">
<li> <li>
<input <input
@@ -18,13 +18,15 @@
class="bg-color" class="bg-color"
/> />
</li> </li>
<button class="icon" @click="saveFeed(feed)">
<i class="material-icons">get_app</i>
</button>
<button class="icon" @click="deleteFeed(feed)"> <button class="icon" @click="deleteFeed(feed)">
<i class="material-icons">delete</i> <i class="material-icons">delete</i>
</button> </button>
</div> </div>
<div class="show-on-large-screen">
<li class="info clamb-3">
<label>{{ feed.message }}</label>
</li>
</div>
</ul> </ul>
</virtual-list> </virtual-list>
<ul v-else> <ul v-else>
@@ -38,6 +40,23 @@
.virtual-list { .virtual-list {
max-height: calc(100vh - 288px); max-height: calc(100vh - 288px);
} }
ul,
ol {
flex-direction: column;
}
.entry {
border-bottom: 1px dashed var(--brd-color);
padding: 0 0 8px;
}
.clamb-3 {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style> </style>
<script> <script>
@@ -58,23 +77,6 @@ export default {
this.$toast.error(this.$t("deleted"), { this.$toast.error(this.$t("deleted"), {
icon: "delete" icon: "delete"
}); });
},
saveFeed(feed) {
const dataToWrite = JSON.stringify(feed.message, null, 2);
const file = new Blob([dataToWrite], { type: "application/json" });
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = (feed.label + " on " + Date()).replace(/\./g, "[dot]");
document.body.appendChild(a);
a.click();
this.$toast.success(this.$t("download_started"), {
icon: "done"
});
setTimeout(() => {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 1000);
} }
} }
}; };

View File

@@ -7,7 +7,8 @@
type="text" type="text"
autofocus autofocus
v-model="message" v-model="message"
:placeholder="$t('paste_a_collection')" :placeholder="$t('paste_a_note')"
@keyup.enter="formPost"
/> />
</li> </li>
</ul> </ul>
@@ -19,11 +20,12 @@
autofocus autofocus
v-model="label" v-model="label"
:placeholder="$t('label')" :placeholder="$t('label')"
@keyup.enter="formPost"
/> />
</li> </li>
<button <button
class="icon" class="icon"
:disabled="!(this.message && this.label)" :disabled="!(this.message || this.label)"
value="Save" value="Save"
@click="formPost" @click="formPost"
> >
@@ -46,6 +48,9 @@ export default {
}, },
methods: { methods: {
formPost() { formPost() {
if (!(this.message || this.label)) {
return;
}
fb.writeFeeds(this.message, this.label); fb.writeFeeds(this.message, this.label);
this.message = null; this.message = null;
this.label = null; this.label = null;

View File

@@ -289,11 +289,6 @@ ol {
flex-direction: column; flex-direction: column;
} }
ul li,
ol li {
display: flex;
}
.method-list-item { .method-list-item {
position: relative; position: relative;

View File

@@ -259,6 +259,7 @@ export default {
syncCollections: "Collections", syncCollections: "Collections",
turn_on: "Turn on", turn_on: "Turn on",
login_first: "Login first", login_first: "Login first",
paste_a_collection: "Paste a Collection", paste_a_note: "Paste a note",
import_from_sync: "Import from Sync" import_from_sync: "Import from Sync",
notes: "Notes"
}; };

View File

@@ -932,12 +932,12 @@
</pw-section> </pw-section>
</div> </div>
<input id="sync-tab" type="radio" name="side" /> <input id="sync-tab" type="radio" name="side" />
<label for="sync-tab">{{ $t("sync") }}</label> <label for="sync-tab">{{ $t("notes") }}</label>
<div class="tab"> <div class="tab">
<pw-section <pw-section
v-if="fb.currentUser" v-if="fb.currentUser"
class="pink" class="pink"
label="Sync" :label="$t('notes')"
ref="sync" ref="sync"
> >
<inputform /> <inputform />
@@ -1505,9 +1505,9 @@ export default {
}, },
rawInput(status) { rawInput(status) {
if (status && this.rawParams === "") { if (status && this.rawParams === "") {
this.rawParams = "{}"; this.rawParams = "{}";
} else { } else {
this.setRouteQueryState(); this.setRouteQueryState();
} }
}, },
"response.body": function(val) { "response.body": function(val) {
@@ -2455,7 +2455,7 @@ export default {
const haveItems = [...this[key]].length; const haveItems = [...this[key]].length;
if (haveItems && this[key]["value"] !== "") { if (haveItems && this[key]["value"] !== "") {
return `${key}=${JSON.stringify(this[key])}&`; return `${key}=${JSON.stringify(this[key])}&`;
} }
return ""; return "";
}; };
let flats = [ let flats = [
@@ -2524,7 +2524,9 @@ export default {
const { value: text } = document.getElementById("import-text"); const { value: text } = document.getElementById("import-text");
try { try {
const parsedCurl = parseCurlCommand(text); const parsedCurl = parseCurlCommand(text);
const { origin, pathname } = new URL(parsedCurl.url.replace(/"/g, "").replace(/'/g, "")); const { origin, pathname } = new URL(
parsedCurl.url.replace(/"/g, "").replace(/'/g, "")
);
this.url = origin; this.url = origin;
this.path = pathname; this.path = pathname;
this.headers = []; this.headers = [];
@@ -2790,7 +2792,9 @@ export default {
}); });
}, },
tokenReqChange({ target }) { tokenReqChange({ target }) {
const { details, name } = this.tokenReqs.find(({ name }) => name === target.value); const { details, name } = this.tokenReqs.find(
({ name }) => name === target.value
);
const { const {
oidcDiscoveryUrl, oidcDiscoveryUrl,
authUrl, authUrl,