Skip to content

Commit

Permalink
skip lazyformat option, List get
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierce01 committed Oct 7, 2023
1 parent 54087ec commit 0870cb2
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Hierarchy } from "./Hierarchy.js"
import { Media } from "./Media.js"
import { MediaCategory } from "./MediaCategory.js"
import { MediaType } from "./MediaType.js"
import { List } from "./List.js"
import { Profile } from "./Profile.js"
import { Upload } from "./Upload.js"
import { ServerSideLink } from "./ServerSideLink.js"
Expand All @@ -23,6 +24,7 @@ export class Client {
media: Media
mediaCategory: MediaCategory
mediaType: MediaType
list: List
profile: Profile
serverSideLink: ServerSideLink
upload: Upload
Expand All @@ -38,6 +40,7 @@ export class Client {
this.media = new Media(this)
this.mediaCategory = new MediaCategory(this)
this.mediaType = new MediaType(this)
this.list = new List(this)
this.profile = new Profile(this)
this.serverSideLink = new ServerSideLink(this)
this.upload = new Upload(this)
Expand Down
8 changes: 5 additions & 3 deletions src/lib/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ export class Content {
return response?.ok
}

async create(sectionId: number, options: contenUploadDTO) {
async create(sectionId: number, options: contenUploadDTO, isFormatted: boolean = false) {
const {
channels,
canPublishNow,
canSaveAndApprove,
contentType
} = await this.prePopulateContentInfo(options.contentTypeID, sectionId)
const formattedElementNames = this.util.getElementNames(contentType.contentTypeElements)
options.elements = this.util.lazyMap(options.elements, formattedElementNames)
if(!isFormatted) {
const formattedElementNames = this.util.getElementNames(contentType.contentTypeElements)
options.elements = this.util.lazyMap(options.elements, formattedElementNames)
}
const uploadData = contentUploadData({
channels,
canPublishNow,
Expand Down
15 changes: 15 additions & 0 deletions src/lib/List.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Client } from "./Client.js"
import { PredefinedListDTO } from "./utility/Global.js"

export const ListEndpoint = 'list'
export class List {
client: Client
constructor(client:Client) {
this.client = client
}

async get(listId: number, language: string = 'en'): Promise<PredefinedListDTO> {
const response = await this.client.call('GET', `${ListEndpoint}/${listId}/${language}`, null)
return await response.json()
}
}
78 changes: 78 additions & 0 deletions src/lib/utility/Global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,82 @@ export interface ServerSideLinkDTO extends ServerSideLinkData {
broken: boolean
}

export interface PredefinedListDTO {
id: number
language: string
name: string
description: string
isForcedLanguage: boolean
isDefaultLanguage: boolean
items: ListItem[]
duplicate: boolean
listEntriesWithListSubLists: any[]
cteWithListsAsElements: CteWithListsAsElement[]
formsUsingThisList: FormDTO[]
sortingEnabled: boolean
listOverriddenInAnotherLanguage: boolean
defaultLanguageSetInAnotherLanguage: boolean
sortType: number
editable: boolean
primaryGroup: ListPrimaryGroup
sharedGroups: any[]
sharedGroupCount: number
fullAccess: boolean
}

export interface ListItem {
name: string
value: string
sequence: number
id: number
isSelected: boolean
sublist: number
listId: number
}

export interface CteWithListsAsElement {
name: string
description: string
typeID: number
type: ListType
maxSize: number
compulsory: boolean
sequence: number
alias: string
show: boolean
id: number
contentType: number
listId: number
}

export interface ListType {
id: number
name: string
description: string
storageMethod: number
binary: boolean
elementClass: string
inputClass: string
extensionChecking: boolean
enabled: boolean
}

export interface ListPrimaryGroup {
group: Group
fullAccess: boolean
id: number
name: string
}

export interface Group {
id: number
name: string
description: string
emailAddress: string
createDate: number
enabled: boolean
ldap: boolean
defaultChannel: number
deleted: boolean
}

0 comments on commit 0870cb2

Please sign in to comment.