Skip to content

Commit

Permalink
1.4.2: #8
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Apr 3, 2018
1 parent f4dd6e1 commit 9365665
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
31 changes: 23 additions & 8 deletions assets/javascripts/discourse/routes/user-ask.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@ export default Discourse.Route.extend({
let root = Ember.getOwner(this).get('rootElement');
Ember.$(root).addClass('df-ask-screen');
},
/**
* 2018-03-23
* I implemented the controller retrieving by analogy with
* https://github.com/vinkashq/discourse-content_lockers/blob/8996e438/assets/javascripts/discourse/lib/show-lockable-modal.js.es6#L3-L8
*/
composer() {return this.route().controllerFor('composer');},
/**
* 2018-03-23
* I implemented the controller retrieving by analogy with
* https://github.com/vinkashq/discourse-content_lockers/blob/8996e438/assets/javascripts/discourse/lib/show-lockable-modal.js.es6#L3-L8
*/
route() {return Discourse.__container__.lookup('route:application');},
actions: {
showComposer(user) {
// 2018-03-23
// I implemented the controller retrieving by analogy with
// https://github.com/vinkashq/discourse-content_lockers/blob/8996e438/assets/javascripts/discourse/lib/show-lockable-modal.js.es6#L3-L8
const container = Discourse.__container__;
const route = container.lookup('route:application');
const composerController = route.controllerFor('composer');
// 2018-03-28
// «How to programmatucally check in JavaScript
// whether the current Discourse user is authenticated?» https://discourse.pro/t/76
if (!Discourse.User.current()) {
route.send('showLogin');
this.route().send('showLogin');
}
else {
// 2018-03-23
// I implemented it by analogy with
// https://github.com/discourse/discourse/blob/v2.0.0.beta4/app/assets/javascripts/discourse/routes/application.js.es6#L56-L69
return composerController.open({
return this.composer().open({
action: Composer.CREATE_TOPIC
,draftKey: Composer.CREATE_TOPIC
,draftSequence: 0
Expand All @@ -41,6 +47,15 @@ export default Discourse.Route.extend({
}}
});
}
},
/**
* 2018-04-04
* @override
* https://guides.emberjs.com/v2.13.0/routing/preventing-and-retrying-transitions/#toc_preventing-transitions-via-code-willtransition-code
*/
willTransition() {
this.composer().cancelComposer();
return true;
}
}
});
4 changes: 3 additions & 1 deletion assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
}
}
}
// 2018-04-03 «Increase Composer height»: https://github.com/discourse-pro/df-ask/issues/9
// 2018-04-03
// «Increase Composer height»: https://github.com/discourse-pro/df-ask/issues/9
// It is 400px in the core: https://github.com/discourse/discourse/blob/v2.0.0.beta5/app/assets/stylesheets/common/base/compose.scss#L43-L48
.df-ask-screen #reply-control.open {height: 600px;}
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name: df-ask
# about: «Ask me a question» plugin
# version: 1.4.1
# version: 1.4.2
# authors: Dmitry Fedyuk
# url: https://github.com/discourse-pro/df-ask
register_asset 'stylesheets/main.scss'
Expand Down

0 comments on commit 9365665

Please sign in to comment.