diff --git a/flatisfy/database/whooshalchemy.py b/flatisfy/database/whooshalchemy.py
index 223dd8a..af656bc 100644
--- a/flatisfy/database/whooshalchemy.py
+++ b/flatisfy/database/whooshalchemy.py
@@ -12,6 +12,7 @@ Based on Flask-whooshalchemy by Karl Gyllstrom (Flask is still supported, but no
:copyright: (c) 2012 by Karl Gyllstrom
:license: BSD (see LICENSE.txt)
"""
+# pylint: skip-file
from __future__ import absolute_import, print_function, unicode_literals
diff --git a/flatisfy/models/flat.py b/flatisfy/models/flat.py
index aee1f31..df67f7a 100644
--- a/flatisfy/models/flat.py
+++ b/flatisfy/models/flat.py
@@ -76,6 +76,7 @@ class Flat(BASE):
title = Column(String)
urls = Column(MagicJSON)
merged_ids = Column(MagicJSON)
+ notes = Column(Text)
# Flatisfy data
# TODO: Should be in another table with relationships
diff --git a/flatisfy/web/app.py b/flatisfy/web/app.py
index c79f6ff..2709dbd 100644
--- a/flatisfy/web/app.py
+++ b/flatisfy/web/app.py
@@ -78,6 +78,8 @@ def get_app(config):
app.route("/api/v1/flat/:flat_id", "GET", api_routes.flat_v1)
app.route("/api/v1/flat/:flat_id/status", "POST",
api_routes.update_flat_status_v1)
+ app.route("/api/v1/flat/:flat_id/notes", "POST",
+ api_routes.update_flat_notes_v1)
app.route("/api/v1/search", "POST", api_routes.search_v1)
diff --git a/flatisfy/web/js_src/api/index.js b/flatisfy/web/js_src/api/index.js
index 770a013..1c59ebb 100644
--- a/flatisfy/web/js_src/api/index.js
+++ b/flatisfy/web/js_src/api/index.js
@@ -68,7 +68,24 @@ export const updateFlatStatus = function (flatId, newStatus, callback) {
).then(callback).catch(function (ex) {
console.error('Unable to update flat status: ' + ex)
})
+}
+export const updateFlatNotes = function (flatId, newNotes, callback) {
+ fetch(
+ '/api/v1/flat/' + encodeURIComponent(flatId) + '/notes',
+ {
+ credentials: 'same-origin',
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ notes: newNotes
+ })
+ }
+ ).then(callback).catch(function (ex) {
+ console.error('Unable to update flat notes: ' + ex)
+ })
}
export const getTimeToPlaces = function (callback) {
@@ -82,7 +99,6 @@ export const getTimeToPlaces = function (callback) {
})
}
-
export const doSearch = function (query, callback) {
fetch(
'/api/v1/search',
@@ -101,5 +117,4 @@ export const doSearch = function (query, callback) {
}).catch(function (ex) {
console.error('Unable to perform search: ' + ex)
})
-
}
diff --git a/flatisfy/web/js_src/store/actions.js b/flatisfy/web/js_src/store/actions.js
index 66cdaaa..3d7909a 100644
--- a/flatisfy/web/js_src/store/actions.js
+++ b/flatisfy/web/js_src/store/actions.js
@@ -27,6 +27,12 @@ export default {
commit(types.UPDATE_FLAT_STATUS, { flatId, newStatus })
})
},
+ updateFlatNotes ({ commit }, { flatId, newNotes }) {
+ commit(types.IS_LOADING)
+ api.updateFlatNotes(flatId, newNotes, response => {
+ commit(types.UPDATE_FLAT_NOTES, { flatId, newNotes })
+ })
+ },
doSearch ({ commit }, { query }) {
commit(types.IS_LOADING)
api.doSearch(query, flats => {
diff --git a/flatisfy/web/js_src/store/mutations-types.js b/flatisfy/web/js_src/store/mutations-types.js
index b731821..f7a2cb6 100644
--- a/flatisfy/web/js_src/store/mutations-types.js
+++ b/flatisfy/web/js_src/store/mutations-types.js
@@ -1,5 +1,6 @@
export const REPLACE_FLATS = 'REPLACE_FLATS'
export const MERGE_FLATS = 'MERGE_FLATS'
export const UPDATE_FLAT_STATUS = 'UPDATE_FLAT_STATUS'
+export const UPDATE_FLAT_NOTES = 'UPDATE_FLAT_NOTES'
export const RECEIVE_TIME_TO_PLACES = 'RECEIVE_TIME_TO_PLACES'
export const IS_LOADING = 'IS_LOADING'
diff --git a/flatisfy/web/js_src/store/mutations.js b/flatisfy/web/js_src/store/mutations.js
index 4d22563..9cda85e 100644
--- a/flatisfy/web/js_src/store/mutations.js
+++ b/flatisfy/web/js_src/store/mutations.js
@@ -32,6 +32,13 @@ export const mutations = {
Vue.set(state.flats[index], 'status', newStatus)
}
},
+ [types.UPDATE_FLAT_NOTES] (state, { flatId, newNotes }) {
+ state.loading = false
+ const index = state.flats.findIndex(flat => flat.id === flatId)
+ if (index > -1) {
+ Vue.set(state.flats[index], 'notes', newNotes)
+ }
+ },
[types.RECEIVE_TIME_TO_PLACES] (state, { timeToPlaces }) {
state.loading = false
state.timeToPlaces = timeToPlaces
diff --git a/flatisfy/web/js_src/views/details.vue b/flatisfy/web/js_src/views/details.vue
index ef114d6..a1a784e 100644
--- a/flatisfy/web/js_src/views/details.vue
+++ b/flatisfy/web/js_src/views/details.vue
@@ -101,6 +101,14 @@