Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Plugin API to add directory columns (#13440)
- Loading branch information
1 parent
fe5923d
commit 7fc3d7b
Showing
33 changed files
with
452 additions
and
195 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: 37 additions & 0 deletions
37
app/assets/javascripts/discourse/app/helpers/directory-item-helpers.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,37 @@ | ||
import { htmlSafe } from "@ember/template"; | ||
import { number } from "discourse/lib/formatter"; | ||
import { registerUnbound } from "discourse-common/lib/helpers"; | ||
import I18n from "I18n"; | ||
|
||
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 })); | ||
}); | ||
|
||
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>` | ||
); | ||
}); | ||
|
||
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>`); | ||
}); | ||
|
||
registerUnbound("directory-column-is-automatic", function (args) { | ||
// Args should include key/values { column } | ||
return args.column.type === "automatic"; | ||
}); | ||
|
||
registerUnbound("directory-column-is-user-field", function (args) { | ||
// Args should include key/values { column } | ||
return args.column.type === "user_field"; | ||
}); |
10 changes: 0 additions & 10 deletions
10
app/assets/javascripts/discourse/app/helpers/directory-item-label.js
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
app/assets/javascripts/discourse/app/helpers/directory-item-user-field-value.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/assets/javascripts/discourse/app/helpers/directory-item-value.js
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.