-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Revert 3 commits for plugin API to add directory columns (#13423)
- Loading branch information
1 parent
c47f552
commit 95b5166
Showing
27 changed files
with
102 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
app/assets/javascripts/discourse/app/helpers/directory-item-helpers.js
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/discourse/app/helpers/directory-item-label.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { htmlSafe } from "@ember/template"; | ||
import { registerUnbound } from "discourse-common/lib/helpers"; | ||
import I18n from "I18n"; | ||
|
||
export default registerUnbound("mobile-directory-item-label", function (args) { | ||
// Args should include key/values { item, column } | ||
|
||
const count = args.item.get(args.column.name); | ||
return htmlSafe(I18n.t(`directory.${args.column.name}`, { count })); | ||
}); |
16 changes: 16 additions & 0 deletions
16
app/assets/javascripts/discourse/app/helpers/directory-item-user-field-value.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { htmlSafe } from "@ember/template"; | ||
import { registerUnbound } from "discourse-common/lib/helpers"; | ||
|
||
export default registerUnbound( | ||
"directory-item-user-field-value", | ||
function (args) { | ||
// Args should include key/values { item, column } | ||
|
||
const value = | ||
args.item.user && args.item.user.user_fields | ||
? args.item.user.user_fields[args.column.user_field_id] | ||
: null; | ||
const content = value || "-"; | ||
return htmlSafe(`<span class='user-field-value'>${content}</span>`); | ||
} | ||
); |
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/discourse/app/helpers/directory-item-value.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { htmlSafe } from "@ember/template"; | ||
import { registerUnbound } from "discourse-common/lib/helpers"; | ||
import { number } from "discourse/lib/formatter"; | ||
|
||
export default registerUnbound("directory-item-value", function (args) { | ||
// Args should include key/values { item, column } | ||
|
||
return htmlSafe( | ||
`<span class='number'>${number(args.item.get(args.column.name))}</span>` | ||
); | ||
}); |
6 changes: 3 additions & 3 deletions
6
app/assets/javascripts/discourse/app/templates/components/directory-item.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/discourse/app/templates/mobile/components/directory-item.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class DirectoryColumn < ActiveRecord::Base | ||
self.inheritance_column = nil | ||
|
||
def self.automatic_column_names | ||
@automatic_column_names ||= [:likes_received, | ||
:likes_given, | ||
:topics_entered, | ||
:topic_count, | ||
:post_count, | ||
:posts_read, | ||
:days_visited] | ||
end | ||
|
||
def self.active_column_names | ||
DirectoryColumn.where(type: [:automatic, :plugin]).where(enabled: true).pluck(:name).map(&:to_sym) | ||
end | ||
|
||
@@plugin_directory_columns = [] | ||
|
||
enum type: { automatic: 0, user_field: 1, plugin: 2 } | ||
|
||
belongs_to :user_field | ||
|
||
def self.add_plugin_directory_column(name) | ||
@@plugin_directory_columns << name | ||
end | ||
|
||
def self.plugin_directory_columns | ||
@@plugin_directory_columns | ||
end | ||
|
||
def self.clear_plugin_directory_columns | ||
@@plugin_directory_columns = [] | ||
end | ||
end |
Oops, something went wrong.