Skip to content

Commit

Permalink
添加直接保存且不跳转页面功能
Browse files Browse the repository at this point in the history
  • Loading branch information
heguanghao committed Nov 16, 2023
1 parent 692feb4 commit 7ec377b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/controllers/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ func (this *PageController) Modify() {
comment := strings.TrimSpace(this.GetString("comment", ""))
isNoticeUser := strings.TrimSpace(this.GetString("is_notice_user", "0"))
isFollowDoc := strings.TrimSpace(this.GetString("is_follow_doc", "0"))
// 保存类型
saveType := strings.TrimSpace(this.GetString("save_type", ""))

// rm document_page_editor-markdown-doc
this.Ctx.Request.PostForm.Del("document_page_editor-markdown-doc")
Expand Down Expand Up @@ -281,7 +283,7 @@ func (this *PageController) Modify() {
}(documentId)

this.InfoLog("修改文档 " + documentId + " 成功")
this.jsonSuccess("文档修改成功!", nil, "/document/index?document_id="+documentId)
this.jsonSuccess("文档修改成功!", saveType, "/document/index?document_id="+documentId)
}

// document share display
Expand Down
18 changes: 15 additions & 3 deletions static/js/modules/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Page = {
* @param element
* @returns {boolean}
*/
ajaxSave: function (element, sendEmail, isAutoFollow) {
ajaxSave: function (element, sendEmail, isAutoFollow, isConfirm) {

/**
* 成功信息条
Expand Down Expand Up @@ -45,14 +45,26 @@ var Page = {
Storage.remove(storageId);
successBox(result.message, result.data);
}
if (result.redirect.url) {
if (result.redirect.url && result.data == "0") {
var sleepTime = result.redirect.sleep || 3000;
setTimeout(function () {
parent.location.href = result.redirect.url;
}, sleepTime);
}
}

// 直接保存
if(isConfirm == false){
var commentText = ""
var options = {
dataType: 'json',
success: response,
data: {'comment': commentText, 'is_notice_user': "0", 'is_follow_doc': "1", 'save_type':"1"}
};
$(element).ajaxSubmit(options);
return false;
}

var containerHtml = '<div class="container-fluid" style="padding: 20px 20px 0 20px">';
containerHtml += '<textarea name="edit_comment" class="form-control" rows="3" autofocus="autofocus" style="resize:none""></textarea>';
containerHtml += '<div style="margin-top: 8px;text-align: left">';
Expand Down Expand Up @@ -95,7 +107,7 @@ var Page = {
var options = {
dataType: 'json',
success: response,
data: {'comment': commentText, 'is_notice_user': isNoticeUser, 'is_follow_doc': isFollowDoc}
data: {'comment': commentText, 'is_notice_user': isNoticeUser, 'is_follow_doc': isFollowDoc, 'save_type':"0"}
};
$(element).ajaxSubmit(options);
}
Expand Down
3 changes: 2 additions & 1 deletion views/page/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<input type="text" name="name" class="form-control" placeholder="请输入文档名称" value="{{$document.name}}" {{if eq $document.parent_id "0"}} readonly="readonly" {{end}}>
</div>
<div class="col-md-2 text-center" >
<button type="button" class="btn btn-primary" onclick="Page.ajaxSave(this.form, {{.sendEmail}}, {{.autoFollowDoc}})"><i class="fa fa-save"></i> 保存</button>
<button type="button" class="btn btn-primary" onclick="Page.ajaxSave(this.form, {{.sendEmail}}, {{.autoFollowDoc}}, true)"><i class="fa fa-save"></i> 确认保存</button>
<button type="button" class="btn btn-primary" onclick="Page.ajaxSave(this.form, {{.sendEmail}}, {{.autoFollowDoc}}, false)"><i class="fa fa-save"></i> 直接保存</button>
<button type="button" class="btn btn-default" onclick="Page.cancelSave('确定要放弃此次修改吗?', '/document/index?document_id={{$document.document_id}}')"><i class="fa fa-mail-reply"></i> 取消</button>
</div>
</div>
Expand Down

2 comments on commit 7ec377b

@rochgh
Copy link

@rochgh rochgh commented on 7ec377b Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

添加直接保存且不跳转页面功能

@GX158
Copy link

@GX158 GX158 commented on 7ec377b Nov 16, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.