瀏覽代碼

err -> flash.

master
Patrick Peng Sun 8 年之前
父節點
當前提交
b27c40eae2
共有 6 個文件被更改,包括 38 次插入25 次删除
  1. +17
    -7
      crmMeeting.go
  2. +2
    -7
      spa/assets/js/spa.js
  3. +0
    -2
      spa/edit.html
  4. +10
    -2
      spa/editmeeting.html
  5. +1
    -1
      spa/pinegrow.json
  6. +8
    -6
      spaEditMeeting.go

+ 17
- 7
crmMeeting.go 查看文件

@@ -46,7 +46,8 @@ type crmdMeeting struct {
CoverName string `json:"coverName,omitempty"`

//for web spa operation
spaErrMsg []string
spaFlashTitle string
spaFlashMsg []string
}

func (m crmdMeeting) save() (newMeeting crmdMeeting, err error) {
@@ -75,20 +76,29 @@ func (m crmdMeeting) save() (newMeeting crmdMeeting, err error) {
}

func (m *crmdMeeting) clearSpaErr(e string) {
m.spaErrMsg = []string{}
m.spaFlashMsg = []string{}
}

func (m *crmdMeeting) addSpaErr(e string) {
m.spaErrMsg = append(m.spaErrMsg, e)
func (m *crmdMeeting) addFlashMsg(e string) {
m.spaFlashMsg = append(m.spaFlashMsg, e)
}

func (m crmdMeeting) ErrorMessage() string {
v := strings.Join(m.spaErrMsg, "<br>")
func (m crmdMeeting) FlashMessage() string {
v := strings.Join(m.spaFlashMsg, "<br>")
return v
}

func (m crmdMeeting) FlashTitle() string {
return m.spaFlashTitle
}

func (m *crmdMeeting) setFlashTitle(val string) string {
m.spaFlashTitle = val
return m.spaFlashTitle
}

func (m crmdMeeting) hasError() bool {
return len(m.spaErrMsg) > 0
return len(m.spaFlashMsg) > 0
}

func (m crmdMeeting) CoverCacheURL() string {

+ 2
- 7
spa/assets/js/spa.js 查看文件

@@ -54,7 +54,7 @@ $(document).ready(function() {
aftershow: function(){} //Function for after opening timepicker
});
if ($("#errmsg").text() !="" && $("#errmsg").text() != "{{.ErrorMessage}}"){
if ($("#errmsg").text() !="" && $("#errmsg").text() != "{{.FlashMessage}}"){
$('#modalerr').modal('open');
}
@@ -62,10 +62,5 @@ $(document).ready(function() {
console.log("spa ready");
});

$("form").submit(function(event){
if ( $(this).find("input.Iagree").is(":checked") == false) {
alert("发起活动之前,请选择同意主办方须知");
event.preventDefault();
}
});


+ 0
- 2
spa/edit.html 查看文件

@@ -102,8 +102,6 @@
closeWechatBrowser();
}
});
</script>
</body>
</html>

+ 10
- 2
spa/editmeeting.html 查看文件

@@ -116,8 +116,8 @@
<!-- Modal Structure -->
<div id="modalerr" class="modal deep-orange">
<div class="modal-content">
<h5>您好</h5>
<p id="errmsg">{{.ErrorMessage}}</p>
<h5>{{.FlashTitle}}</h5>
<p id="errmsg">{{.FlashMessage}}</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">知道了</a>
@@ -137,4 +137,12 @@
<script src="materialize/js/materialize.js"></script>
<script src="index.js"></script>
<script src="assets/js/spa.js"></script>
<script type="text/javascript">
$("form").submit(function(event){
if ( $(this).find("input.Iagree").is(":checked") == false) {
alert("发起活动之前,请选择同意主办方须知");
event.preventDefault();
}
});
</script>
</body>

+ 1
- 1
spa/pinegrow.json 查看文件

@@ -1 +1 @@
{"files":{"edit.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":896},"404.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"livecast.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.project.items","pg.asset.manager","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"newEvents.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.project.items","pg.asset.manager","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"newevent.html":{"frameworks":["spa","pg.insight.events","pg.asset.manager","pg.code-validator","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"editmeeting.html":{"frameworks":["spa","pg.insight.events","pg.asset.manager","pg.code-validator","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"403.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"400.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"500.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024}},"breakpoints":["28.875em","33.875em","35.875em","38.875em","40.125em","46.75em","360px","390px","420px","450px","480px","510px","540px","570px","601px","630px","660px","690px","720px","750px","780px","810px","840px","870px","900px","930px","960px","993px","1200px"],"frameworks":["spa","pg.insight.events","pg.asset.manager","pg.code-validator","pg.project.items","mat0.97.5","pg.html","pg.components"],"template_framework_id":"materialize"}
{"files":{"edit.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":896},"404.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"livecast.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.project.items","pg.asset.manager","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"newEvents.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.project.items","pg.asset.manager","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"newevent.html":{"frameworks":["spa","pg.insight.events","pg.asset.manager","pg.code-validator","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"editmeeting.html":{"frameworks":["spa","pg.insight.events","pg.asset.manager","pg.code-validator","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"403.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"400.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024},"500.html":{"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"last_page_width":1024}},"breakpoints":["28.875em","33.875em","35.875em","38.875em","40.125em","46.75em","360px","390px","420px","450px","480px","510px","540px","570px","601px","630px","660px","690px","720px","750px","780px","810px","840px","870px","900px","930px","960px","993px","1200px"],"frameworks":["spa","pg.insight.events","pg.code-validator","pg.asset.manager","pg.project.items","mat0.97.5","pg.html","pg.components"],"template_framework_id":"materialize"}

+ 8
- 6
spaEditMeeting.go 查看文件

@@ -121,6 +121,8 @@ func (m crmdMeeting) saveFromWeb(w http.ResponseWriter, r *http.Request) {
meeting.ID = m.ID
updatedMeeting, err := meeting.save()
if err == nil {
updatedMeeting.setFlashTitle("成功保存")
updatedMeeting.addFlashMsg("活动信息已经成功保存,其他校友可通过公众号查阅本活动信息")
updatedMeeting.showEdit(w)
return
}
@@ -134,14 +136,14 @@ func (m *crmdMeeting) validateFormInput(form url.Values) bool {
if ok {
m.Name = val[0]
} else {
m.addSpaErr("活动主题/标题不能为空")
m.addFlashMsg("活动主题/标题不能为空")
}

val, ok = form["description"]
if ok {
m.Description = val[0]
} else {
m.addSpaErr("清添加描述活动本身")
m.addFlashMsg("清添加描述活动本身")
}

startdate, sok := form["startdate"]
@@ -150,14 +152,14 @@ func (m *crmdMeeting) validateFormInput(form url.Values) bool {
if sok && hok && rok {
m.buildStartDate(startdate[0], starthour[0], duration[0])
} else {
m.addSpaErr("活动日期,开始时间,持续时间 不能为空")
m.addFlashMsg("活动日期,开始时间,持续时间 不能为空")
}

val, ok = form["venue"]
if ok {
m.Venue = val[0]
} else {
m.addSpaErr("请添加活动地点/集合地点")
m.addFlashMsg("请添加活动地点/集合地点")
}

return !m.hasError()
@@ -187,7 +189,7 @@ func (m *crmdMeeting) buildStartDate(date, hour, duration string) {
value := strings.TrimSpace(date) + " " + strings.TrimSpace(hour) + " AEST" //Force Sydney time
t, err := time.Parse(layout, value)
if err != nil {
m.addSpaErr("开始日期,时间,无法识别")
m.addFlashMsg("开始日期,时间,无法识别")
return
}
utc, err := time.LoadLocation("UTC")
@@ -204,7 +206,7 @@ func (m *crmdMeeting) buildDuration(duration string) {
var hour, minute int
cnt, err := fmt.Sscanf(duration, "%d:%d", &hour, &minute)
if cnt != 2 && err != nil {
m.addSpaErr("持续时间不正确")
m.addFlashMsg("持续时间不正确")
return
}
m.Duration = (hour * 3600) + (minute * 60)

Loading…
取消
儲存