fixed card's note input and recording
This commit is contained in:
parent
2bf557b733
commit
72890c7ab0
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -75,7 +75,7 @@
|
||||||
</section>
|
</section>
|
||||||
<section class="tool note">
|
<section class="tool note">
|
||||||
<span
|
<span
|
||||||
v-if="note_nid"
|
v-if="note_id"
|
||||||
class="btn mdi mdi-note"
|
class="btn mdi mdi-note"
|
||||||
v-touch.prevent.stop="onTapTool"
|
v-touch.prevent.stop="onTapTool"
|
||||||
/>
|
/>
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
v-touch.prevent.stop="onTapTool"
|
v-touch.prevent.stop="onTapTool"
|
||||||
/>
|
/>
|
||||||
<div class="tool-content">
|
<div class="tool-content">
|
||||||
<textarea spellcheck="false" v-model="note" name="note"/>
|
<textarea spellcheck="false" v-model="note" name="note" @input="onNoteInput"/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="tool print">
|
<section class="tool print">
|
||||||
|
@ -358,7 +358,7 @@ export default {
|
||||||
loadingFlag: false,
|
loadingFlag: false,
|
||||||
lightbox_index: null,
|
lightbox_index: null,
|
||||||
note: "",
|
note: "",
|
||||||
note_nid: null
|
note_id: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -382,15 +382,17 @@ export default {
|
||||||
created () {
|
created () {
|
||||||
console.log('modale item', this.item)
|
console.log('modale item', this.item)
|
||||||
this.loadMaterial()
|
this.loadMaterial()
|
||||||
|
this.note_id = this.item.note_id
|
||||||
this.debouncedSaveNote = _debounce(this.saveNote, 500)
|
this.debouncedSaveNote = _debounce(this.saveNote, 500)
|
||||||
},
|
},
|
||||||
watch: {
|
// watch: {
|
||||||
// whenever question changes, this function will run
|
// // whenever question changes, this function will run
|
||||||
note: function (n, o) {
|
// // TODO: on mobile, this is called only on white caractere key
|
||||||
console.log("note watcher: note", n)
|
// note: function (n, o) {
|
||||||
this.debouncedSaveNote()
|
// console.log("note watcher: note", n)
|
||||||
}
|
// this.debouncedSaveNote()
|
||||||
},
|
// }
|
||||||
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions({
|
...mapActions({
|
||||||
// refreshItem: 'Search/refreshItem',
|
// refreshItem: 'Search/refreshItem',
|
||||||
|
@ -478,7 +480,16 @@ export default {
|
||||||
},
|
},
|
||||||
onSwipeCard (e) {
|
onSwipeCard (e) {
|
||||||
console.log('onSwipeCard', e)
|
console.log('onSwipeCard', e)
|
||||||
|
switch(e){
|
||||||
|
case 'top':
|
||||||
|
break
|
||||||
|
case 'bottom':
|
||||||
|
break
|
||||||
|
case 'left':
|
||||||
|
case 'right':
|
||||||
this.$modal.hide(`modal-${this.item.id}`)
|
this.$modal.hide(`modal-${this.item.id}`)
|
||||||
|
break
|
||||||
|
}
|
||||||
},
|
},
|
||||||
prettyFileSize(bytes){
|
prettyFileSize(bytes){
|
||||||
return prettyBytes(parseInt(bytes))
|
return prettyBytes(parseInt(bytes))
|
||||||
|
@ -486,9 +497,14 @@ export default {
|
||||||
shortUrl(url){
|
shortUrl(url){
|
||||||
return url.replace(/^http:\/\//, '').replace(/^www\./, '')
|
return url.replace(/^http:\/\//, '').replace(/^www\./, '')
|
||||||
},
|
},
|
||||||
|
onNoteInput(e){
|
||||||
|
console.log('onNoteInput', e, this.note)
|
||||||
|
this.note = e.target.value
|
||||||
|
this.debouncedSaveNote()
|
||||||
|
},
|
||||||
saveNote(){
|
saveNote(){
|
||||||
console.log("saveNote", this.note)
|
console.log("saveNote", this.note_id, this.note)
|
||||||
if (this.note_nid) {
|
if (this.note_id) {
|
||||||
this.updateNote()
|
this.updateNote()
|
||||||
} else {
|
} else {
|
||||||
this.createNote()
|
this.createNote()
|
||||||
|
@ -504,7 +520,7 @@ export default {
|
||||||
"X-CSRF-Token": this.csrf_token
|
"X-CSRF-Token": this.csrf_token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
REST.patch(`/node/${this.note_nid}?_format=json`, params, config)
|
REST.patch(`/node/${this.note_id}?_format=json`, params, config)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log('updateNote REST data', data)
|
console.log('updateNote REST data', data)
|
||||||
})
|
})
|
||||||
|
@ -527,13 +543,13 @@ export default {
|
||||||
REST.post('/node?_format=json', params, config)
|
REST.post('/node?_format=json', params, config)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log('createNote REST data', data)
|
console.log('createNote REST data', data)
|
||||||
this.note_nid = data.nid[0].value
|
this.note_id = data.nid[0].value
|
||||||
// call search results refresh of the item to display that note is now existing for this item
|
// call search results refresh of the item to display that note is now existing for this item
|
||||||
// this.refreshItem({id: this.item.id})
|
// this.refreshItem({id: this.item.id})
|
||||||
// no needs to refresh the entire item via searchresults
|
// no needs to refresh the entire item via searchresults
|
||||||
// plus if we are in article, there is not searchresults
|
// plus if we are in article, there is not searchresults
|
||||||
// instead call the callbackfunction from teh parent to add directly the note id
|
// instead call the callbackfunction from the parent to add directly the note id
|
||||||
this.addNoteId(this.note_nid)
|
this.addNoteId(this.note_id)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Issue with createNote', error)
|
console.warn('Issue with createNote', error)
|
||||||
|
@ -548,7 +564,11 @@ export default {
|
||||||
e.target.parentNode.classList.add('tapped')
|
e.target.parentNode.classList.add('tapped')
|
||||||
},
|
},
|
||||||
onTapCard (e) {
|
onTapCard (e) {
|
||||||
console.log('ontapCard', e)
|
console.log('ontapCard', e.target.tagName)
|
||||||
|
// in case we tap on note's textarea
|
||||||
|
if(e.target.tagName == "TEXTAREA"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
let tools = this.$refs['tools'].querySelectorAll('section.tool')
|
let tools = this.$refs['tools'].querySelectorAll('section.tool')
|
||||||
// console.log()
|
// console.log()
|
||||||
tools.forEach((item, i) => {
|
tools.forEach((item, i) => {
|
||||||
|
|
Loading…
Reference in New Issue