Detail page delete button

Signed-off-by: yanjuntao <yanjuntao@huawei.com>
This commit is contained in:
yanjuntao 2022-05-17 15:44:16 +08:00
parent 7bb563b6dd
commit dbd5c5cfbe
2 changed files with 48 additions and 2 deletions

View File

@ -198,12 +198,18 @@ export struct DeleteDialog {
.textAlign(TextAlign.Center)
.maxLines(1)
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
} else {
} else if (this.CheckedNoteArray.length > 1){
Text($r("app.string.deletePartNote", this.CheckedNoteArray.length))
.fontSize(14)
.textAlign(TextAlign.Center)
.maxLines(1)
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
} else {
Text($r("app.string.deleteNote"))
.fontSize(14)
.textAlign(TextAlign.Center)
.maxLines(1)
.visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
}
}
}

View File

@ -34,6 +34,14 @@ var time_id: number
const TAG = "NoteContentCompPortrait"
async function routePage() {
try {
await router.back()
} catch (err) {
LogUtil.info(TAG, "fail callback")
}
}
// Note content component
@Component
export struct NoteContentCompPortrait {
@ -250,6 +258,34 @@ export struct ToolBarComp {
@StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
controllerShow: WebController
onDeleteConfirm() {
if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
this.selectedNoteData.is_deleted = Delete.Yes
this.selectedNoteData.deleted_time = new Date().getTime()
// update note to db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null)
// 跳转
routePage()
} else {
NoteUtil.removeNoteData(this.AllNoteArray, this.selectedNoteData.uuid)
// delete note from db
let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid)
RdbStoreUtil.delete(predicates_note, null)
// 跳转
routePage()
}
}
noteDataDeleteDialogCtl: CustomDialogController = new CustomDialogController({
builder: DeleteDialog({ onConfirm: this.onDeleteConfirm.bind(this), multiSelect: true }),
alignment: DialogAlignment.Center,
autoCancel: false,
customStyle: true,
})
build() {
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
@ -286,7 +322,11 @@ export struct ToolBarComp {
AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
LogUtil.info(TAG, 'ToolBarComp, set continue note success')
})
}.width(36)
Image($r('app.media.delete')).height(24).width(24)
.onClick(()=>{
this.noteDataDeleteDialogCtl.open()
})
}.width(72)
.visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible)
} else {
Row({ space: StyleConstants.SPACE_6 }) {