Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Word filters#311

Open
Azareal wants to merge 2 commits into
mybb:masterfrom
Azareal:word-filters
Open

Word filters#311
Azareal wants to merge 2 commits into
mybb:masterfrom
Azareal:word-filters

Conversation

@Azareal
Copy link
Copy Markdown
Contributor

@Azareal Azareal commented Oct 8, 2017

Word Filter Component for the ACP and a little refactor for the isOnline method of the UserPresenter.
I've so far done the word filter list.

Copy link
Copy Markdown
Member

@euantorano euantorano left a comment

Choose a reason for hiding this comment

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

Looks good so far, just some minor comments on the current progress.

* @var array
*/
protected $casts = [
'id' => 'int',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indentation here is a little weird for some reason.

'replace' => 'string',
];

public function getID() : int
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer this styled as getId() personally, and I think our style guide says something similar.


namespace MyBB\Core\Database\Repositories\Eloquent;

use MyBB\Core\Database\Repositories\Collection;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Group the two Repository classes together like:

use MyBB\Core\Database\Repositories\{
    Collection,
    WordFilterRepositoryInterface
};

$this->wordFilter = $wordFilter;
}

public function getAll() : \Illuminate\Database\Eloquent\Collection
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there's a collection interface/contract, it's better to state that we return an interface rather than a concrete type.

// TODO: Implement this
//public function find(int $id) : WordFilter;

public function getAll() : \Illuminate\Database\Eloquent\Collection;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again, I think there's a collection interface/contract, it's better to state that we return an interface rather than a concrete type.

It's probably also best to have a paginate() method and paginate them in the ACP. If you have many filters, looking through them all is difficult.

$this->wordFilterRepository = $wordFilterRepository;
}

public function index() : \Illuminate\View\View
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally I prefer to return a response interface in the function signature, in case something changes in the future.

*/
protected $guard;

public function __construct(WordFilterModel $resource, Guard $guard) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

{ should be on the line below.

'title' => 'Word Filters',
'add_button' => 'Add Word Filter',
'find_field' => 'Find',
'replace_field' => 'Replacement',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wouldn't bother trying to line all the values up, it just gets annoying trying to maintain it later down the line 😉

</div>
</div>
<div class="admin-body__content" style="display: flex;flex-direction: row;">
<table class="admin-table admin-table--bordered users" style="width:79%;">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Paging @Eric-Jackson 😛

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mentioned to @Azareal in Discord, we will want to avoid inline style and tables. For now the classes already available on these elements should work fine for removing that inline stuff, the tables can be replaced later so I wouldn't worry about them at this moment. The class "users" should be replaced with something more appropriate word-filters.

</tr>
</thead>
<tbody>
{% for filter in word_filter_items %}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably a good idea to use an else block to display a message if the collection is empty.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants