Make display_mode and page_size blank
This commit is contained in:
parent
d8e7113fef
commit
8d96e22591
@ -27,7 +27,7 @@ import {
|
||||
} from 'rxjs'
|
||||
import { Group } from 'src/app/data/group'
|
||||
import {
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DisplayMode,
|
||||
DocumentDisplayField,
|
||||
SavedView,
|
||||
|
@ -9,7 +9,7 @@
|
||||
<a class="btn-link text-decoration-none" header-buttons [routerLink]="[]" (click)="showAll()" i18n>Show all</a>
|
||||
}
|
||||
|
||||
@if (documents.length && savedView.display_mode === DashboardViewMode.TABLE) {
|
||||
@if (documents.length && (!savedView.display_mode || savedView.display_mode === DashboardViewMode.TABLE)) {
|
||||
<table content class="table table-hover mb-0 mt-n2 align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -13,7 +13,8 @@ import {
|
||||
DocumentDisplayField,
|
||||
DisplayMode,
|
||||
SavedView,
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_PAGE_SIZE,
|
||||
} from 'src/app/data/saved-view'
|
||||
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
@ -133,7 +134,7 @@ export class SavedViewWidgetComponent
|
||||
this.documentService
|
||||
.listFiltered(
|
||||
1,
|
||||
this.savedView.page_size,
|
||||
this.savedView.page_size ?? DEFAULT_PAGE_SIZE,
|
||||
this.savedView.sort_field,
|
||||
this.savedView.sort_reverse,
|
||||
this.savedView.filter_rules,
|
||||
@ -250,6 +251,6 @@ export class SavedViewWidgetComponent
|
||||
const id = column.split('_')[2]
|
||||
return this.customFields.find((c) => c.id === parseInt(id))?.name
|
||||
}
|
||||
return DOCUMENT_DISPLAY_FIELDS.find((c) => c.id === column)?.name
|
||||
return DEFAULT_DOCUMENT_DISPLAY_FIELDS.find((c) => c.id === column)?.name
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
|
||||
import {
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DocumentDisplayField,
|
||||
} from 'src/app/data/saved-view'
|
||||
|
||||
@ -36,7 +36,7 @@ export class DocumentCardLargeComponent extends ComponentWithPermissions {
|
||||
|
||||
@Input()
|
||||
displayFields: Set<DocumentDisplayField | string> = new Set(
|
||||
DOCUMENT_DISPLAY_FIELDS.map((f) => f.id)
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS.map((f) => f.id)
|
||||
)
|
||||
|
||||
@Output()
|
||||
|
@ -13,7 +13,7 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
|
||||
import {
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DocumentDisplayField,
|
||||
} from 'src/app/data/saved-view'
|
||||
|
||||
@ -43,7 +43,7 @@ export class DocumentCardSmallComponent extends ComponentWithPermissions {
|
||||
|
||||
@Input()
|
||||
displayFields: Set<DocumentDisplayField | string> = new Set(
|
||||
DOCUMENT_DISPLAY_FIELDS.map((f) => f.id)
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS.map((f) => f.id)
|
||||
)
|
||||
|
||||
@Output()
|
||||
|
@ -4,6 +4,7 @@ import { ObjectWithPermissions } from './object-with-permissions'
|
||||
export enum DisplayMode {
|
||||
TABLE = 'table',
|
||||
SMALL_CARDS = 'smallCards',
|
||||
LARGE_CARDS = 'largeCards',
|
||||
}
|
||||
|
||||
export enum DocumentDisplayField {
|
||||
@ -21,7 +22,9 @@ export enum DocumentDisplayField {
|
||||
ASN = 'asn',
|
||||
}
|
||||
|
||||
export const DOCUMENT_DISPLAY_FIELDS = [
|
||||
export const DEFAULT_PAGE_SIZE = 10
|
||||
|
||||
export const DEFAULT_DOCUMENT_DISPLAY_FIELDS = [
|
||||
{
|
||||
id: DocumentDisplayField.TITLE,
|
||||
name: $localize`Title`,
|
||||
|
@ -13,7 +13,7 @@ import { AppModule } from '../app.module'
|
||||
import { UiSettings, SETTINGS_KEYS } from '../data/ui-settings'
|
||||
import { SettingsService } from './settings.service'
|
||||
import {
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DocumentDisplayField,
|
||||
SavedView,
|
||||
} from '../data/saved-view'
|
||||
@ -353,7 +353,7 @@ describe('SettingsService', () => {
|
||||
settingsService.initializeDisplayFields()
|
||||
expect(
|
||||
settingsService.allDocumentDisplayFields.includes(
|
||||
DOCUMENT_DISPLAY_FIELDS[0]
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS[0]
|
||||
)
|
||||
).toBeTruthy()
|
||||
expect(
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
} from './permissions.service'
|
||||
import { ToastService } from './toast.service'
|
||||
import {
|
||||
DOCUMENT_DISPLAY_FIELDS,
|
||||
DEFAULT_DOCUMENT_DISPLAY_FIELDS,
|
||||
DocumentDisplayField,
|
||||
SavedView,
|
||||
} from '../data/saved-view'
|
||||
@ -307,7 +307,7 @@ export class SettingsService {
|
||||
}
|
||||
|
||||
public initializeDisplayFields() {
|
||||
this.allDocumentDisplayFields = DOCUMENT_DISPLAY_FIELDS
|
||||
this.allDocumentDisplayFields = DEFAULT_DOCUMENT_DISPLAY_FIELDS
|
||||
|
||||
if (
|
||||
this.permissionsService.currentUserCan(
|
||||
@ -316,7 +316,7 @@ export class SettingsService {
|
||||
)
|
||||
) {
|
||||
this.customFieldsService.listAll().subscribe((r) => {
|
||||
this.allDocumentDisplayFields = DOCUMENT_DISPLAY_FIELDS.concat(
|
||||
this.allDocumentDisplayFields = DEFAULT_DOCUMENT_DISPLAY_FIELDS.concat(
|
||||
r.results.map((field) => {
|
||||
return {
|
||||
id: `${DocumentDisplayField.CUSTOM_FIELD}${field.id}` as any,
|
||||
|
@ -17,19 +17,25 @@ class Migration(migrations.Migration):
|
||||
model_name="savedview",
|
||||
name="display_mode",
|
||||
field=models.CharField(
|
||||
choices=[("table", "Table"), ("smallCards", "Small Cards")],
|
||||
default="table",
|
||||
blank=True,
|
||||
choices=[
|
||||
("table", "Table"),
|
||||
("smallCards", "Small Cards"),
|
||||
("largeCards", "Large Cards"),
|
||||
],
|
||||
max_length=128,
|
||||
verbose_name="Dashboard view display mode",
|
||||
null=True,
|
||||
verbose_name="View display mode",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="savedview",
|
||||
name="page_size",
|
||||
field=models.PositiveIntegerField(
|
||||
default=10,
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[django.core.validators.MinValueValidator(1)],
|
||||
verbose_name="Dashboard view limit",
|
||||
verbose_name="View page size",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
@ -45,7 +51,7 @@ class Migration(migrations.Migration):
|
||||
("correspondent", "Correspondent"),
|
||||
("storagepath", "Storage Path"),
|
||||
],
|
||||
default="created,title,tags,correspondent",
|
||||
default="created,title,tag,correspondent",
|
||||
max_length=128,
|
||||
),
|
||||
),
|
@ -555,6 +555,7 @@ class SavedView(ModelWithOwner):
|
||||
class ViewDisplayMode(models.TextChoices):
|
||||
TABLE = ("table", _("Table"))
|
||||
SMALL_CARDS = ("smallCards", _("Small Cards"))
|
||||
LARGE_CARDS = ("largeCards", _("Large Cards"))
|
||||
|
||||
class DocumentDisplayFields(models.TextChoices):
|
||||
TITLE = ("title", _("Title"))
|
||||
@ -587,7 +588,8 @@ class SavedView(ModelWithOwner):
|
||||
|
||||
page_size = models.PositiveIntegerField(
|
||||
_("View page size"),
|
||||
default=10,
|
||||
null=True,
|
||||
blank=True,
|
||||
validators=[MinValueValidator(1)],
|
||||
)
|
||||
|
||||
@ -595,7 +597,8 @@ class SavedView(ModelWithOwner):
|
||||
max_length=128,
|
||||
verbose_name=_("View display mode"),
|
||||
choices=ViewDisplayMode.choices,
|
||||
default=ViewDisplayMode.TABLE,
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
document_display_fields = DynamicMultiSelectField(
|
||||
|
@ -1614,7 +1614,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
||||
status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
|
||||
def test_create_update_patch(self):
|
||||
def test_savedview_create_update_patch(self):
|
||||
User.objects.create_user("user1")
|
||||
|
||||
view = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user