Skip to content

Commit eb73177

Browse files
committed
edit resource card from display page
1 parent 784d996 commit eb73177

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

src/EventBus.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const Events = {
1818
DISPLAY_CATEGORY_DELETED: 'DISPLAY_CATEGORY_DELETED',
1919
DISPLAY_CURRENT_CATEGORY_DELETED: 'DISPLAY_CURRENT_CATEGORY_DELETED',
2020

21+
// For editing resource card directly from display screen
22+
DISPLAY_SAME_SCREEN_EDIT_RESOURCE: 'DISPLAY_SAME_SCREEN_EDIT_RESOURCE',
23+
2124
// Resource page
2225
RESOURCE_NEW_CARD_CLOSE: 'RESOURCE_NEW_CARD_CLOSE',
2326
RESOURCE_CATEGORY: 'RESOURCE_CATEGORY',

src/components/YdDisplayCardSettings.vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<div class="settings-dialog-title">{{ $t('message.edit_card') }}</div>
99
<div class="classware-title">
1010
<!--<input type="text" :placeholder="cardContent.name"></input>-->
11-
{{cardContent.name}}
11+
{{cardContent.name}} <span @click="editFromLibrary">({{ $t('message.edit_from_library') }})</span>
1212
</div>
1313
<div class="classware-layout">
1414
<div class="row">{{ $t('message.choose_animation') }}</div>
@@ -79,6 +79,19 @@ export default {
7979
select: function(value) {
8080
this.selected = value
8181
},
82+
editFromLibrary: function() {
83+
console.log('edit from library')
84+
let categoryList = db.getNonOfficialResourceCategories()
85+
let isOfficialCategory = _.find(categoryList, (o) => {
86+
return o.uuid === this.cardContent.category
87+
})
88+
if (isOfficialCategory) {
89+
EventBus.$emit(Events.DISPLAY_SAME_SCREEN_EDIT_RESOURCE, this.cardContent)
90+
} else {
91+
var f7 = Utils.getF7()
92+
f7.alert(this.$t('message.cannot_edit_preload'), this.$t('message.forbidden'))
93+
}
94+
},
8295
deleteClasswareItem: function() {
8396
var f7 = Utils.getF7()
8497
f7.confirm(this.$t('message.are_you_sure'), this.$t('message.alert_delete_card'), () => {
@@ -164,6 +177,12 @@ export default {
164177
border: none;
165178
background-color: transparent;
166179
}
180+
181+
.classware-title span {
182+
margin-left: 0.25em;
183+
color: red;
184+
}
185+
167186
.settings-dialog .classware-layout {
168187
position: absolute;
169188
top: 27%;

src/pages/YdDisplay.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
<yd-display-card-settings v-if="showCardSettings" :card="cardInEdit"></yd-display-card-settings>
6767
<yd-display-classware-settings v-if="showClasswareSettings" :classwareId="rootUuid"></yd-display-classware-settings>
6868
<yd-edit-category-dialog v-if="showCategorySettings" :card="cardInEdit" :newCategory="showNewClasswareCategorySettings"></yd-edit-category-dialog>
69+
<yd-edit-card-dialog v-if="showEditResCardDialog" :cardInEdit="cardInEdit"></yd-edit-card-dialog>
70+
6971
</transition>
7072
<div class="dark-overlay" v-if="isOverlay"></div>
7173
<!--Multi-touch areas-->
@@ -248,6 +250,7 @@ import Utils from '../utils'
248250
import YdDisplayClasswareSettings from '../components/YdDisplayClasswareSettings'
249251
import YdDisplayCardSettings from '../components/YdDisplayCardSettings'
250252
import YdEditCategoryDialog from '../components/YdEditCategoryDialog'
253+
import YdEditCardDialog from '../components/YdEditCardDialog'
251254
import _ from 'lodash'
252255
253256
export default {
@@ -261,6 +264,7 @@ export default {
261264
cardInEdit: {},
262265
showClasswareSettings: false,
263266
showNewClasswareCategorySettings: false,
267+
showEditResCardDialog: false,
264268
firstStartup: false,
265269
touchAreas: [
266270
{ name: 'touch-top-left', pressed: false },
@@ -269,7 +273,7 @@ export default {
269273
]
270274
}
271275
},
272-
components: { YdDrawer, YdDisplayClasswareSettings, YdDisplayCardSettings, YdEditCategoryDialog },
276+
components: { YdDrawer, YdDisplayClasswareSettings, YdDisplayCardSettings, YdEditCategoryDialog, YdEditCardDialog },
273277
watch: {
274278
editMode: function(val, oldVal) {
275279
window.ga.trackEvent('USER_EVENT', 'EDITMODE', 'CHANGE', val, false)
@@ -285,6 +289,9 @@ export default {
285289
return classwareObj.name
286290
},
287291
showCardSettings: function() {
292+
if (this.showEditResCardDialog) {
293+
return false
294+
}
288295
if (this.cardInEdit && this.cardInEdit.type === 'card') {
289296
return true
290297
}
@@ -364,6 +371,18 @@ export default {
364371
// TODO: Close drawers or warn if root is not the same with top classware
365372
this.showClasswareSettings = false
366373
})
374+
EventBus.$on(Events.DISPLAY_SAME_SCREEN_EDIT_RESOURCE, (doc) => {
375+
console.log('from display: ')
376+
console.log(doc)
377+
// this.showCardSettings = false
378+
this.cardInEdit = doc
379+
this.showEditResCardDialog = true
380+
})
381+
// for eidt resource dialog to be closed
382+
EventBus.$on(Events.RESOURCE_NEW_CARD_CLOSE, () => {
383+
this.showEditResCardDialog = false
384+
this.cardInEdit = {}
385+
})
367386
EventBus.$on(Events.DISPLAY_NEW_ROOT_CLASSWARE, (doc) => {
368387
window.ga.trackEvent('USER_EVENT', 'DISPLAY', 'ROOT_COURSEWARE_CHANGED')
369388
window.setTimeout(() => {
@@ -404,6 +423,8 @@ export default {
404423
this.showClasswareSettings = false
405424
} else if (this.showNewClasswareCategorySettings) {
406425
this.showNewClasswareCategorySettings = false
426+
} else if (this.showEditResCardDialog) {
427+
this.showEditResCardDialog = false
407428
} else if (!_.isEmpty(this.cardInEdit)) {
408429
this.cardInEdit = {}
409430
} else if (this.drawers.length > 1) {

src/strings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export default {
4545
// Edit card
4646
missing_info_body: 'Please choose name, category and image before save',
4747
missing_info_title: 'Missing infomation',
48+
edit_from_library: 'Edit from library',
49+
cannot_edit_preload: 'Cannot edit preloaded cards',
4850
// Edit category
4951
require_category_title: 'Category title is required',
5052
cannot_edit_in_all: 'Cannot edit in "All" category',
@@ -121,6 +123,8 @@ export default {
121123
// Edit card
122124
missing_info_body: '请选择名称、分类和图片,然后保存',
123125
missing_info_title: '缺少信息',
126+
edit_from_library: '去素材库编辑',
127+
cannot_edit_preload: '不能编辑自带卡片',
124128
// Edit category
125129
require_category_title: '必须输入一个名称',
126130
cannot_edit_in_all: '不能在”全部“中编辑',

0 commit comments

Comments
 (0)