wip shopping dialog

This commit is contained in:
vabene1111
2024-12-22 18:36:56 +01:00
parent d611391bea
commit e0223e0c5c
13 changed files with 520 additions and 42 deletions

View File

@@ -133,6 +133,8 @@ models/ServerSettings.ts
models/ShareLink.ts
models/ShoppingListEntry.ts
models/ShoppingListEntryBulk.ts
models/ShoppingListEntryBulkCreate.ts
models/ShoppingListEntrySimpleCreate.ts
models/ShoppingListRecipe.ts
models/SourceImportDuplicate.ts
models/SourceImportFood.ts

View File

@@ -131,6 +131,7 @@ import type {
ShareLink,
ShoppingListEntry,
ShoppingListEntryBulk,
ShoppingListEntryBulkCreate,
ShoppingListRecipe,
Space,
Step,
@@ -381,6 +382,8 @@ import {
ShoppingListEntryToJSON,
ShoppingListEntryBulkFromJSON,
ShoppingListEntryBulkToJSON,
ShoppingListEntryBulkCreateFromJSON,
ShoppingListEntryBulkCreateToJSON,
ShoppingListRecipeFromJSON,
ShoppingListRecipeToJSON,
SpaceFromJSON,
@@ -1214,7 +1217,7 @@ export interface ApiRecipePartialUpdateRequest {
patchedRecipe?: Omit<PatchedRecipe, 'image'|'created_by'|'created_at'|'updated_at'|'food_properties'|'rating'|'last_cooked'>;
}
export interface ApiRecipeRelatedRetrieveRequest {
export interface ApiRecipeRelatedListRequest {
id: number;
}
@@ -1224,7 +1227,7 @@ export interface ApiRecipeRetrieveRequest {
export interface ApiRecipeShoppingUpdateRequest {
id: number;
recipeShoppingUpdate?: RecipeShoppingUpdate;
recipeShoppingUpdate: RecipeShoppingUpdate;
}
export interface ApiRecipeUpdateRequest {
@@ -1268,8 +1271,13 @@ export interface ApiShoppingListEntryUpdateRequest {
shoppingListEntry: Omit<ShoppingListEntry, 'recipe_mealplan'|'created_by'|'created_at'|'updated_at'>;
}
export interface ApiShoppingListRecipeBulkCreateEntriesCreateRequest {
id: number;
shoppingListEntryBulkCreate: ShoppingListEntryBulkCreate;
}
export interface ApiShoppingListRecipeCreateRequest {
shoppingListRecipe: Omit<ShoppingListRecipe, 'recipe_name'|'name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
shoppingListRecipe: Omit<ShoppingListRecipe, 'recipe_name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
}
export interface ApiShoppingListRecipeDestroyRequest {
@@ -1283,7 +1291,7 @@ export interface ApiShoppingListRecipeListRequest {
export interface ApiShoppingListRecipePartialUpdateRequest {
id: number;
patchedShoppingListRecipe?: Omit<PatchedShoppingListRecipe, 'recipe_name'|'name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
patchedShoppingListRecipe?: Omit<PatchedShoppingListRecipe, 'recipe_name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
}
export interface ApiShoppingListRecipeRetrieveRequest {
@@ -1292,7 +1300,7 @@ export interface ApiShoppingListRecipeRetrieveRequest {
export interface ApiShoppingListRecipeUpdateRequest {
id: number;
shoppingListRecipe: Omit<ShoppingListRecipe, 'recipe_name'|'name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
shoppingListRecipe: Omit<ShoppingListRecipe, 'recipe_name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'>;
}
export interface ApiSpaceListRequest {
@@ -8856,11 +8864,11 @@ export class ApiApi extends runtime.BaseAPI {
/**
* logs request counts to redis cache total/per user/
*/
async apiRecipeRelatedRetrieveRaw(requestParameters: ApiRecipeRelatedRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<RecipeSimple>> {
async apiRecipeRelatedListRaw(requestParameters: ApiRecipeRelatedListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<RecipeSimple>>> {
if (requestParameters['id'] == null) {
throw new runtime.RequiredError(
'id',
'Required parameter "id" was null or undefined when calling apiRecipeRelatedRetrieve().'
'Required parameter "id" was null or undefined when calling apiRecipeRelatedList().'
);
}
@@ -8879,14 +8887,14 @@ export class ApiApi extends runtime.BaseAPI {
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => RecipeSimpleFromJSON(jsonValue));
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(RecipeSimpleFromJSON));
}
/**
* logs request counts to redis cache total/per user/
*/
async apiRecipeRelatedRetrieve(requestParameters: ApiRecipeRelatedRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<RecipeSimple> {
const response = await this.apiRecipeRelatedRetrieveRaw(requestParameters, initOverrides);
async apiRecipeRelatedList(requestParameters: ApiRecipeRelatedListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<RecipeSimple>> {
const response = await this.apiRecipeRelatedListRaw(requestParameters, initOverrides);
return await response.value();
}
@@ -8938,6 +8946,13 @@ export class ApiApi extends runtime.BaseAPI {
);
}
if (requestParameters['recipeShoppingUpdate'] == null) {
throw new runtime.RequiredError(
'recipeShoppingUpdate',
'Required parameter "recipeShoppingUpdate" was null or undefined when calling apiRecipeShoppingUpdate().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
@@ -9388,6 +9403,53 @@ export class ApiApi extends runtime.BaseAPI {
return await response.value();
}
/**
* logs request counts to redis cache total/per user/
*/
async apiShoppingListRecipeBulkCreateEntriesCreateRaw(requestParameters: ApiShoppingListRecipeBulkCreateEntriesCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ShoppingListEntryBulkCreate>> {
if (requestParameters['id'] == null) {
throw new runtime.RequiredError(
'id',
'Required parameter "id" was null or undefined when calling apiShoppingListRecipeBulkCreateEntriesCreate().'
);
}
if (requestParameters['shoppingListEntryBulkCreate'] == null) {
throw new runtime.RequiredError(
'shoppingListEntryBulkCreate',
'Required parameter "shoppingListEntryBulkCreate" was null or undefined when calling apiShoppingListRecipeBulkCreateEntriesCreate().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // ApiKeyAuth authentication
}
const response = await this.request({
path: `/api/shopping-list-recipe/{id}/bulk_create_entries/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id']))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ShoppingListEntryBulkCreateToJSON(requestParameters['shoppingListEntryBulkCreate']),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => ShoppingListEntryBulkCreateFromJSON(jsonValue));
}
/**
* logs request counts to redis cache total/per user/
*/
async apiShoppingListRecipeBulkCreateEntriesCreate(requestParameters: ApiShoppingListRecipeBulkCreateEntriesCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ShoppingListEntryBulkCreate> {
const response = await this.apiShoppingListRecipeBulkCreateEntriesCreateRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* logs request counts to redis cache total/per user/
*/

View File

@@ -0,0 +1,99 @@
/* tslint:disable */
/* eslint-disable */
/**
* Tandoor
* Tandoor API Docs
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { RecipeSimple } from './RecipeSimple';
import {
RecipeSimpleFromJSON,
RecipeSimpleFromJSONTyped,
RecipeSimpleToJSON,
RecipeSimpleToJSONTyped,
} from './RecipeSimple';
/**
*
* @export
* @interface PaginatedRecipeSimpleList
*/
export interface PaginatedRecipeSimpleList {
/**
*
* @type {number}
* @memberof PaginatedRecipeSimpleList
*/
count: number;
/**
*
* @type {string}
* @memberof PaginatedRecipeSimpleList
*/
next?: string | null;
/**
*
* @type {string}
* @memberof PaginatedRecipeSimpleList
*/
previous?: string | null;
/**
*
* @type {Array<RecipeSimple>}
* @memberof PaginatedRecipeSimpleList
*/
results: Array<RecipeSimple>;
}
/**
* Check if a given object implements the PaginatedRecipeSimpleList interface.
*/
export function instanceOfPaginatedRecipeSimpleList(value: object): value is PaginatedRecipeSimpleList {
if (!('count' in value) || value['count'] === undefined) return false;
if (!('results' in value) || value['results'] === undefined) return false;
return true;
}
export function PaginatedRecipeSimpleListFromJSON(json: any): PaginatedRecipeSimpleList {
return PaginatedRecipeSimpleListFromJSONTyped(json, false);
}
export function PaginatedRecipeSimpleListFromJSONTyped(json: any, ignoreDiscriminator: boolean): PaginatedRecipeSimpleList {
if (json == null) {
return json;
}
return {
'count': json['count'],
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(RecipeSimpleFromJSON)),
};
}
export function PaginatedRecipeSimpleListToJSON(json: any): PaginatedRecipeSimpleList {
return PaginatedRecipeSimpleListToJSONTyped(json, false);
}
export function PaginatedRecipeSimpleListToJSONTyped(value?: PaginatedRecipeSimpleList | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'count': value['count'],
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(RecipeSimpleToJSON)),
};
}

View File

@@ -36,7 +36,7 @@ export interface PatchedShoppingListRecipe {
* @type {string}
* @memberof PatchedShoppingListRecipe
*/
readonly name?: string;
name?: string;
/**
*
* @type {number}
@@ -108,7 +108,7 @@ export function PatchedShoppingListRecipeToJSON(json: any): PatchedShoppingListR
return PatchedShoppingListRecipeToJSONTyped(json, false);
}
export function PatchedShoppingListRecipeToJSONTyped(value?: Omit<PatchedShoppingListRecipe, 'recipe_name'|'name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'> | null, ignoreDiscriminator: boolean = false): any {
export function PatchedShoppingListRecipeToJSONTyped(value?: Omit<PatchedShoppingListRecipe, 'recipe_name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'> | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
@@ -116,6 +116,7 @@ export function PatchedShoppingListRecipeToJSONTyped(value?: Omit<PatchedShoppin
return {
'id': value['id'],
'name': value['name'],
'recipe': value['recipe'],
'mealplan': value['mealplan'],
'servings': value['servings'],

View File

@@ -32,11 +32,11 @@ export interface RecipeShoppingUpdate {
*/
listRecipe?: number | null;
/**
* List of ingredient IDs from the recipe to add, if not provided all ingredients will be added.
* @type {number}
*
* @type {Array<number | null>}
* @memberof RecipeShoppingUpdate
*/
ingredients?: number | null;
ingredients: Array<number | null>;
/**
* Providing a list_recipe ID and servings of 0 will delete that shopping list.
* @type {number}
@@ -49,6 +49,7 @@ export interface RecipeShoppingUpdate {
* Check if a given object implements the RecipeShoppingUpdate interface.
*/
export function instanceOfRecipeShoppingUpdate(value: object): value is RecipeShoppingUpdate {
if (!('ingredients' in value) || value['ingredients'] === undefined) return false;
return true;
}
@@ -64,7 +65,7 @@ export function RecipeShoppingUpdateFromJSONTyped(json: any, ignoreDiscriminator
'id': json['id'] == null ? undefined : json['id'],
'listRecipe': json['list_recipe'] == null ? undefined : json['list_recipe'],
'ingredients': json['ingredients'] == null ? undefined : json['ingredients'],
'ingredients': json['ingredients'],
'servings': json['servings'] == null ? undefined : json['servings'],
};
}

View File

@@ -0,0 +1,74 @@
/* tslint:disable */
/* eslint-disable */
/**
* Tandoor
* Tandoor API Docs
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
import type { ShoppingListEntrySimpleCreate } from './ShoppingListEntrySimpleCreate';
import {
ShoppingListEntrySimpleCreateFromJSON,
ShoppingListEntrySimpleCreateFromJSONTyped,
ShoppingListEntrySimpleCreateToJSON,
ShoppingListEntrySimpleCreateToJSONTyped,
} from './ShoppingListEntrySimpleCreate';
/**
*
* @export
* @interface ShoppingListEntryBulkCreate
*/
export interface ShoppingListEntryBulkCreate {
/**
*
* @type {Array<ShoppingListEntrySimpleCreate>}
* @memberof ShoppingListEntryBulkCreate
*/
entries: Array<ShoppingListEntrySimpleCreate>;
}
/**
* Check if a given object implements the ShoppingListEntryBulkCreate interface.
*/
export function instanceOfShoppingListEntryBulkCreate(value: object): value is ShoppingListEntryBulkCreate {
if (!('entries' in value) || value['entries'] === undefined) return false;
return true;
}
export function ShoppingListEntryBulkCreateFromJSON(json: any): ShoppingListEntryBulkCreate {
return ShoppingListEntryBulkCreateFromJSONTyped(json, false);
}
export function ShoppingListEntryBulkCreateFromJSONTyped(json: any, ignoreDiscriminator: boolean): ShoppingListEntryBulkCreate {
if (json == null) {
return json;
}
return {
'entries': ((json['entries'] as Array<any>).map(ShoppingListEntrySimpleCreateFromJSON)),
};
}
export function ShoppingListEntryBulkCreateToJSON(json: any): ShoppingListEntryBulkCreate {
return ShoppingListEntryBulkCreateToJSONTyped(json, false);
}
export function ShoppingListEntryBulkCreateToJSONTyped(value?: ShoppingListEntryBulkCreate | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'entries': ((value['entries'] as Array<any>).map(ShoppingListEntrySimpleCreateToJSON)),
};
}

View File

@@ -0,0 +1,84 @@
/* tslint:disable */
/* eslint-disable */
/**
* Tandoor
* Tandoor API Docs
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ShoppingListEntrySimpleCreate
*/
export interface ShoppingListEntrySimpleCreate {
/**
*
* @type {number}
* @memberof ShoppingListEntrySimpleCreate
*/
amount: number;
/**
*
* @type {number}
* @memberof ShoppingListEntrySimpleCreate
*/
unitId: number | null;
/**
*
* @type {number}
* @memberof ShoppingListEntrySimpleCreate
*/
foodId: number | null;
}
/**
* Check if a given object implements the ShoppingListEntrySimpleCreate interface.
*/
export function instanceOfShoppingListEntrySimpleCreate(value: object): value is ShoppingListEntrySimpleCreate {
if (!('amount' in value) || value['amount'] === undefined) return false;
if (!('unitId' in value) || value['unitId'] === undefined) return false;
if (!('foodId' in value) || value['foodId'] === undefined) return false;
return true;
}
export function ShoppingListEntrySimpleCreateFromJSON(json: any): ShoppingListEntrySimpleCreate {
return ShoppingListEntrySimpleCreateFromJSONTyped(json, false);
}
export function ShoppingListEntrySimpleCreateFromJSONTyped(json: any, ignoreDiscriminator: boolean): ShoppingListEntrySimpleCreate {
if (json == null) {
return json;
}
return {
'amount': json['amount'],
'unitId': json['unit_id'],
'foodId': json['food_id'],
};
}
export function ShoppingListEntrySimpleCreateToJSON(json: any): ShoppingListEntrySimpleCreate {
return ShoppingListEntrySimpleCreateToJSONTyped(json, false);
}
export function ShoppingListEntrySimpleCreateToJSONTyped(value?: ShoppingListEntrySimpleCreate | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'amount': value['amount'],
'unit_id': value['unitId'],
'food_id': value['foodId'],
};
}

View File

@@ -36,7 +36,7 @@ export interface ShoppingListRecipe {
* @type {string}
* @memberof ShoppingListRecipe
*/
readonly name: string;
name?: string;
/**
*
* @type {number}
@@ -80,7 +80,6 @@ export interface ShoppingListRecipe {
*/
export function instanceOfShoppingListRecipe(value: object): value is ShoppingListRecipe {
if (!('recipeName' in value) || value['recipeName'] === undefined) return false;
if (!('name' in value) || value['name'] === undefined) return false;
if (!('servings' in value) || value['servings'] === undefined) return false;
if (!('mealplanNote' in value) || value['mealplanNote'] === undefined) return false;
if (!('mealplanFromDate' in value) || value['mealplanFromDate'] === undefined) return false;
@@ -100,7 +99,7 @@ export function ShoppingListRecipeFromJSONTyped(json: any, ignoreDiscriminator:
'id': json['id'] == null ? undefined : json['id'],
'recipeName': json['recipe_name'],
'name': json['name'],
'name': json['name'] == null ? undefined : json['name'],
'recipe': json['recipe'] == null ? undefined : json['recipe'],
'mealplan': json['mealplan'] == null ? undefined : json['mealplan'],
'servings': json['servings'],
@@ -114,7 +113,7 @@ export function ShoppingListRecipeToJSON(json: any): ShoppingListRecipe {
return ShoppingListRecipeToJSONTyped(json, false);
}
export function ShoppingListRecipeToJSONTyped(value?: Omit<ShoppingListRecipe, 'recipe_name'|'name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'> | null, ignoreDiscriminator: boolean = false): any {
export function ShoppingListRecipeToJSONTyped(value?: Omit<ShoppingListRecipe, 'recipe_name'|'mealplan_note'|'mealplan_from_date'|'mealplan_type'> | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
@@ -122,6 +121,7 @@ export function ShoppingListRecipeToJSONTyped(value?: Omit<ShoppingListRecipe, '
return {
'id': value['id'],
'name': value['name'],
'recipe': value['recipe'],
'mealplan': value['mealplan'],
'servings': value['servings'],

View File

@@ -130,6 +130,8 @@ export * from './ServerSettings';
export * from './ShareLink';
export * from './ShoppingListEntry';
export * from './ShoppingListEntryBulk';
export * from './ShoppingListEntryBulkCreate';
export * from './ShoppingListEntrySimpleCreate';
export * from './ShoppingListRecipe';
export * from './SourceImportDuplicate';
export * from './SourceImportFood';