Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Able to view the list of users associated with an Organization #8511

Merged
merged 12 commits into from
Jun 14, 2023
8 changes: 8 additions & 0 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,14 @@ HTML
$user_template_data_ref->{edit_profile} = 1;
$user_template_data_ref->{orgid} = $orgid;
}
if (defined $User{pro_moderator}) {
my @org_members;
foreach my $member_id (sort keys %{$user_or_org_ref->{members}}) {
my $member_details = retrieve_user($member_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

As a convention, when a variable is an object reference, we suffix it with _ref. Coul you rename $member_details to $member_user_ref or similar?

push @org_members, $member_details;
}
$user_template_data_ref->{org_members} = \@org_members;
}

process_template('web/pages/org_profile/org_profile.tt.html',
$user_template_data_ref, \$profile_html)
Expand Down
10 changes: 10 additions & 0 deletions lib/ProductOpener/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ BEGIN {
&is_admin_user
&create_password_hash
&check_password_hash
&retrieve_user

&check_session

Expand Down Expand Up @@ -921,6 +922,15 @@ sub open_user_session ($user_ref, $request_ref) {
return;
}

sub retrieve_user ($user_id) {
my $user_file = "$data_root/users/" . get_string_id_for_lang("no_language", $user_id) . ".sto";
my $user_ref;
if (-e $user_file) {
$user_ref = retrieve($user_file);
}
return $user_ref;
}

sub init_user ($request_ref) {

my $user_id = undef;
Expand Down
16 changes: 16 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5039,6 +5039,22 @@ msgctxt "official_site"
msgid "Official site"
msgstr "Official site"

msgctxt "organization_members"
msgid "Organization Members"
msgstr "Organization Members"

msgctxt "number_of_members"
msgid "Number of Members"
msgstr "Number of Members"

msgctxt "serial_no"
msgid "S.No"
msgstr "S.No"

msgctxt "member_userid"
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have strings for "Name", "Email", "Country", "Language" etc. in the .po file, so we can reuse them without adding new translation strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okayy..will make the changes👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of "member_userid" can you use the existing "username" string?

msgid "UserId"
msgstr "UserId"

msgctxt "contact_form"
msgid "Contact form"
msgstr "Contact form"
Expand Down
16 changes: 16 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -5076,6 +5076,22 @@ msgctxt "official_site"
msgid "Official site"
msgstr "Official site"

msgctxt "organization_members"
msgid "Organization Members"
msgstr "Organization Members"

msgctxt "number_of_members"
msgid "Number of Members"
msgstr "Number of Members"

msgctxt "serial_no"
msgid "S.No"
msgstr "S.No"

msgctxt "member_userid"
msgid "UserId"
msgstr "UserId"

msgctxt "contact_form"
msgid "Contact form"
msgstr "Contact form"
Expand Down
47 changes: 47 additions & 0 deletions scss/_off.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1451,3 +1451,50 @@ a.panel_title {
background-color: scale-color($button-bg-color, $lightness: -$button-function-factor / 2);
color: #fff;
}
// organization members table in producers platform
Copy link
Contributor

Choose a reason for hiding this comment

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

We can do it in a separate PR, but it would be a good thing to see if we can make the CSS code that we have for packagings generic, so that it can be applied to any table, instead of having similar separate CSS code for each table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes..It would be good to make the CSS generic for these tables👍...would open a separate PR for CSS things..will do it asap!

$breakpoint-tablet: 636px;

#org_main_table {
box-shadow: 0 0 5px rgba(0,0,0,.25);
vertical-align: middle;
}

#org_table_header {
background-color:$macchiato;
@media (max-width: $breakpoint-tablet){
tr{
display:none;
}
}
th {
color:white;
font-weight: 600;
padding:.5rem;
text-align: center;
}
}

#org_table_body {
td{
padding:.5rem;
}
@media (max-width: $breakpoint-tablet) {
tr {
display:block;
}
td{
text-align: right;
display:block;
padding: .5rem;
}
td::before {
content:attr(data-cell) ": ";
float:left;
text-transform: capitalize;
font-weight: 600;
}
}
}
#org_table_body tr:nth-child(even){
background-color:$latte;
}
35 changes: 35 additions & 0 deletions templates/web/pages/org_profile/org_profile.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@
<p>&rarr; <a href="[% link %]">[% lang("official_site") %]</a></p>
[% END %]

[% IF org_members.size %]
<h2>[% lang("organization_members") %]</h2>
<p>[% lang("number_of_members") %][% sep %]: [% org_members.size %]</p>
<div style="position:relative">
<table id="org_main_table">
<thead id="org_table_header">
<tr>
<th>[% lang("serial_no") %]</th>
<th>[% lang("member_userid") %]</th>
<th>[% lang("name") %]</th>
<th>[% lang("email") %]</th>
<th>[% lang("select_lang") %]</th>
<th>[% lang("select_country") %]</th>

</tr>
</thead>
[% SET count = 1 %]
[% FOREACH users IN org_members %]
<tbody id="org_table_body">
Copy link
Contributor

Choose a reason for hiding this comment

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

the tbody element should be outside the FOREACH loop, otherwise you will have a table with more than 1 tbody.

<tr>
<td data-cell =[% lang("serial_no") %]>[% count %].</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

What is "data-cell =[% lang("serial_no") %]" for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The data-cell is a custom attribute used to store additional data or metadata related to the HTML element. This attribute is being used by CSS to manipulate the element for smaller screens--

td::before {
      content:attr(data-cell) ": ";
       float:left;
      text-transform: capitalize;
      font-weight: 600;
}

It would add : after the data cell value i.e serial no in this case when the screen width is small

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand, thanks for the explanation.

<td data-cell =[% lang("member_userid") %]>[% users.userid %]</td>
<td data-cell =[% lang("name") %]>[% users.name %]</td>
<td data-cell =[% lang("email") %]>[% users.email %]</td>
<td data-cell =[% lang("select_lang") %]>[% users.initial_lc %]</td>
<td data-cell =[% lang("select_country") %]>[% users.initial_cc %]</td>
</tr>
</tbody>
[% SET count = count + 1 %]
[% END %]
</table>
</div>
[% END %]


<div class="row">

[% FOREACH contact IN ['customer_service', 'commercial_service'] %]
Expand Down