Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Jun 22, 2023
2 parents ba838e0 + 006bd10 commit 9dcd75b
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 105 deletions.
3 changes: 2 additions & 1 deletion next-app/src/lib/forms/Button.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script>
export let danger = false
export let disabled = false
export let loading = false
export {clazz as class}
let clazz = ''
</script>

<!-- https://daisyui.com/components/button -->
<button on:click class:btn-error={danger} class:btn-disabled={disabled} class='btn btn-primary { clazz }'>
<button on:click class:btn-error={danger} class:btn-disabled={disabled} class:loading={loading} class='btn btn-primary { clazz }'>
<slot />
</button>
8 changes: 5 additions & 3 deletions next-app/src/routes/projects/[project_code]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export let data: DashboardData
let only_showing_subset = true
let loading = false;
$: project = data.project
$: activities = data.activities
Expand Down Expand Up @@ -53,8 +54,9 @@
].filter(({ value }) => value !== undefined)
async function load_all_activities() {
loading = true
activities = await GET({url: `/projects/${$page.params.project_code}/activities`})
loading = false
only_showing_subset = false
}
</script>
Expand All @@ -80,8 +82,8 @@
<Activity { activities } />

{#if only_showing_subset}
<footer class='flex justify-center mt-2'>
<Button on:click={ load_all_activities } class='btn-outline btn-xs sm:btn-sm'>
<footer class='flex justify-center m-4'>
<Button on:click={ load_all_activities } class='btn-outline btn-xs sm:btn-sm' {loading}>
show all
</Button>
</footer>
Expand Down
23 changes: 17 additions & 6 deletions next-app/src/routes/projects/[project_code]/Activity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
interface AugmentedActivity extends Activity {
date_locale: string,
date_time_locale: string,
date_iso: string,
time: number,
field_names: string,
Expand Down Expand Up @@ -36,6 +37,7 @@
return {
...activity,
date_locale: date.toLocaleDateString(),
date_time_locale: date.toLocaleString(),
date_iso: date.toISOString().split('T')[0],
time: date.getTime(),
field_names: to_names(activity.fields),
Expand All @@ -44,16 +46,25 @@
}
function byDateThenUser(a: AugmentedActivity, b: AugmentedActivity) {
return a.date_iso === b.date_iso ? a.user === b.user ? des(a.time, b.time)
: asc(a.user.username, b.user.username)
: des(a.date_iso, b.date_iso)
if (a.date_iso !== b.date_iso) {
return des(a.date_iso, b.date_iso);
}
if (a.user.username !== b.user.username) {
return asc(a.user.username, b.user.username);
}
return des(a.time, b.time);
}
const asc = (a: string | number, b: string | number) => a > b ? 1 : -1
const des = (a: string | number, b: string | number) => a < b ? 1 : -1
function to_names(fields: Field[] = []): string {
return fields.map(field => field.name).join(', ')
// This is quite rudimentary, but far better than nothing
return [...new Set(fields.map(field => field.fieldLabel?.label)
.filter(label => !!label))]
.join(', ')
}
</script>

Expand All @@ -63,20 +74,20 @@
<thead>
<tr>
<td>user</td>
<th>date</th>
<th>action</th>
<th>entry</th>
<th>fields</th>
<th>date</th>
</tr>
</thead>
<tbody>
{#each sorted_activities as activity}
<tr>
<td>{ activity.user.username }</td>
<td>{ activity.date_locale }</td>
<td>{ action_display[activity.action] || activity.action }</td>
<td>{ activity.entry || '' }</td>
<td>{ activity.field_names || '' }</td>
<td>{ activity.date_time_locale }</td>
</tr>
{:else}
<tr><td>No activity</td></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type LegacyResult = {
}

export type Field = {
name: string,
fieldLabel?: { label: string },
}

type LegacyActivity = {
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Model/Shared/Dto/ActivityListDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static function getActivityForUser($userId, $filterParams = [])
$unreadItems = array_merge($unreadItems, self::getUnreadActivityForUserInProject($userId, $project["id"]));
}
$unreadItems = array_merge($unreadItems, self::getGlobalUnreadActivityForUser($userId));
uasort($activity, ["self", "sortActivity"]);
usort($activity, ["self", "sortActivity"]);
$dto = [
"activity" => $activity,
"unread" => $unreadItems,
Expand All @@ -124,7 +124,7 @@ public static function getActivityForOneProject($projectModel, $userId, $filterP
{
$activity = self::getActivityForProject($projectModel, $filterParams);
$unreadItems = self::getUnreadActivityForUserInProject($userId, $projectModel->id->asString());
uasort($activity, ["self", "sortActivity"]);
usort($activity, ["self", "sortActivity"]);
$dto = [
"activity" => $activity,
"unread" => $unreadItems,
Expand All @@ -146,7 +146,7 @@ public static function getActivityForOneLexEntry($projectModel, $entryId, $filte
// TODO: handle unread items for this activity log type (single-entry). Perhaps the getUnreadActivity() functions should just take a list of items? 2018-02 RM
// $unreadItems = self::getUnreadActivityForUserInProject($userId, $projectModel->id->asString());
$unreadItems = [];
uasort($activity, ["self", "sortActivity"]);
usort($activity, ["self", "sortActivity"]);
$dto = [
"activity" => $activity,
"unread" => $unreadItems,
Expand Down
29 changes: 29 additions & 0 deletions src/angular-app/languageforge/lexicon/editor/_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@

@import "../../../../Site/views/languageforge/theme/default/sass/variables";

#lexAppEditView {
display: flex;
justify-content: center;
.container {
margin: 0;
}
}

.container-sticky {
position: sticky;
top: 0px;
z-index: 30;
margin-bottom: 10px;
background: white;
}

.container-scroll {
overflow-y: scroll;
overflow-x: hidden;

@include media-breakpoint-up(md) {
height: calc(100vh - 240px);
}

@include media-breakpoint-down(sm) {
height: calc(100vh - 215px);
}
}

.lexAppToolbar {
border: 1px solid $line-color;
margin: 0 0 5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,6 @@
@import "../../../../../../node_modules/bootstrap/scss/variables";
@import "../../../../../../node_modules/bootstrap/scss/mixins";

#lexAppEditView {
display: flex;
justify-content: center;
.container {
margin: 0;
}
}

.container-sticky {
position: sticky;
top: 0px;
z-index: 3;
margin-bottom: 10px;
}

.container-scroll {
overflow-y: scroll;
overflow-x: hidden;

@include media-breakpoint-up(md) {
height: calc(100vh - 230px);
}

@include media-breakpoint-down(sm) {
height: calc(100vh - 215px);
}
}

.comments-right-panel {
color: $Eden;
font-size: 14px;
Expand Down
Loading

0 comments on commit 9dcd75b

Please sign in to comment.