fix challenge cancel/decline from quicklist
parent
f14b8ce0e6
commit
17edc5067c
|
@ -42,6 +42,6 @@ object Ai extends LilaController {
|
||||||
infos => WS.url(replyToUrl).post(lila.analyse.Info encodeList infos)
|
infos => WS.url(replyToUrl).post(lila.analyse.Info encodeList infos)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
funit
|
fuccess(Ok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,8 @@ object Challenge extends LilaController {
|
||||||
}
|
}
|
||||||
|
|
||||||
def cancel(id: String) = Open { implicit ctx =>
|
def cancel(id: String) = Open { implicit ctx =>
|
||||||
OptionFuResult(env.api byId id) { challenge =>
|
OptionFuResult(env.api byId id) { c =>
|
||||||
if (isMine(challenge)) env.api cancel challenge inject Redirect(routes.Lobby.home)
|
if (isMine(c)) env.api cancel c
|
||||||
else notFound
|
else notFound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,10 @@ private[controllers] trait LilaController
|
||||||
|
|
||||||
protected implicit def LilaHtmlToResult(content: Html): Result = Ok(content)
|
protected implicit def LilaHtmlToResult(content: Html): Result = Ok(content)
|
||||||
|
|
||||||
protected implicit def LilaFunitToResult(funit: Funit): Fu[Result] = funit inject Ok("ok")
|
protected implicit def LilaFunitToResult(funit: Funit)(implicit ctx: Context): Fu[Result] =
|
||||||
|
negotiate(
|
||||||
|
html = fuccess(Ok("ok")),
|
||||||
|
api = _ => fuccess(Ok(Json.obj("ok" -> true)) as JSON))
|
||||||
|
|
||||||
implicit def lang(implicit req: RequestHeader) = Env.i18n.pool lang req
|
implicit def lang(implicit req: RequestHeader) = Env.i18n.pool lang req
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,15 @@ module.exports = function(env) {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
this.cancel = function(id) {
|
||||||
|
this.data.out.forEach(function(c) {
|
||||||
|
if (c.id === id) {
|
||||||
|
c.declined = true;
|
||||||
|
xhr.cancel(id);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
xhr.load().then(this.update);
|
xhr.load().then(this.update);
|
||||||
|
|
||||||
var showUser = function(user) {
|
var showUser = function(user) {
|
||||||
|
|
|
@ -35,18 +35,18 @@ function inButtons(ctrl, c) {
|
||||||
action: '/challenge/' + c.id + '/accept'
|
action: '/challenge/' + c.id + '/accept'
|
||||||
}, m('button', {
|
}, m('button', {
|
||||||
'type': 'submit',
|
'type': 'submit',
|
||||||
class: 'submit button accept',
|
class: 'button accept',
|
||||||
'data-icon': 'E'
|
'data-icon': 'E'
|
||||||
})),
|
})),
|
||||||
m('form', m('button', {
|
m('button', {
|
||||||
'type': 'submit',
|
'type': 'submit',
|
||||||
class: 'submit button decline',
|
class: 'submit button decline',
|
||||||
'data-icon': 'L',
|
'data-icon': 'L',
|
||||||
onclick: function(e) {
|
onclick: function() {
|
||||||
ctrl.decline(c.id);
|
ctrl.decline(c.id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}))
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ function outButtons(ctrl, c) {
|
||||||
href: '/' + c.id
|
href: '/' + c.id
|
||||||
}, 'View challenge')
|
}, 'View challenge')
|
||||||
]),
|
]),
|
||||||
m('form', {
|
m('button', {
|
||||||
method: 'post',
|
class: 'button decline',
|
||||||
action: '/challenge/' + c.id + '/cancel'
|
|
||||||
}, m('button', {
|
|
||||||
'type': 'submit',
|
|
||||||
class: 'submit button decline',
|
|
||||||
'data-icon': 'L',
|
'data-icon': 'L',
|
||||||
})),
|
onclick: function() {
|
||||||
|
ctrl.cancel(c.id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ function allChallenges(ctrl, d, nb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function empty(ctrl, d) {
|
function empty(ctrl, d) {
|
||||||
return m('div.empty', 'No challenges.');
|
return m('div.empty.text[data-icon=]', 'No challenges.');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(ctrl) {
|
module.exports = function(ctrl) {
|
||||||
|
|
|
@ -21,7 +21,14 @@ module.exports = {
|
||||||
return m.request({
|
return m.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/challenge/' + id + '/decline',
|
url: '/challenge/' + id + '/decline',
|
||||||
config: xhrConfig,
|
config: xhrConfig
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cancel: function(id) {
|
||||||
|
return m.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/challenge/' + id + '/cancel',
|
||||||
|
config: xhrConfig
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue