docbrown/app/javascript/internal/controllers/article_controller.js
Jacob Herrington 2b442ca8b6
Internal bug fixes and misc JS/CSS cleanup (#6684)
* Remove unused CSS rules

* Use bootstrap utility class over custom css

* Fix grapical bug with buffer tags

* Fix internal UI highlighting and misc fixes

This commit is a little bit too big.

It fixes a bug with the internal UI that was breaking the highlighting
feature (indicates status of articles and when an AJAX request has been
made).

It also does some reformatting in the internal listings UI. This should
make it a bit easier on anyone writing buffer updates in the listings
UI. I was able to reapply some stimulus I wrote previously for this,
super easy!

There are also a couple of CSS classes I renamed to match Bootstrap's
naming conventions.

* Remove <br> tag

* Update article_controller Stimulus test
2020-03-18 16:05:33 -05:00

33 lines
898 B
JavaScript

import { Controller } from 'stimulus';
export default class ArticleController extends Controller {
static targets = ['featuredNumber'];
increaseFeaturedNumber() {
// Increases the article's chances of being seen
const seconds = new Date().getTime() / 1000;
this.featuredNumberTarget.value = Math.round(seconds);
}
decreaseFeaturedNumber() {
// Decreases the article's chances of being seen
const seconds = new Date().getTime() / 1080;
this.featuredNumberTarget.value = Math.round(seconds);
}
highlightElement() {
const card = this.element.querySelector('.card-body');
card.classList.add('bg-highlighted', 'border-highlighted');
setTimeout(() => {
card.classList.remove('bg-highlighted');
}, 350);
}
get articleId() {
return parseInt(this.data.get('id'), 10);
}
set articleId(value) {
this.data.set('id', value);
}
}