ExtendedRecipeMixin

This commit is contained in:
smilerz
2021-10-05 06:28:25 -05:00
parent 2fc27d7c36
commit 613b618533
20 changed files with 249 additions and 205 deletions

View File

@ -252,6 +252,7 @@ export default {
},
getItems: function (params, col) {
let column = col || 'left'
params.options = {'query':{'extended': 1}} // returns extended values in API response
this.genericAPI(this.this_model, this.Actions.LIST, params).then((result) => {
let results = result.data?.results ?? result.data
@ -399,11 +400,13 @@ export default {
},
getChildren: function (col, item) {
let parent = {}
let options = {
let params = {
'root': item.id,
'pageSize': 200
'pageSize': 200,
'query': {'extended': 1},
'options': {'query':{'extended': 1}}
}
this.genericAPI(this.this_model, this.Actions.LIST, options).then((result) => {
this.genericAPI(this.this_model, this.Actions.LIST, params).then((result) => {
parent = this.findCard(item.id, this['items_' + col])
if (parent) {
Vue.set(parent, 'children', result.data.results)
@ -418,10 +421,10 @@ export default {
getRecipes: function (col, item) {
let parent = {}
// TODO: make this generic
let options = {'pageSize': 200}
options[this.this_recipe_param] = item.id
let params = {'pageSize': 50}
params[this.this_recipe_param] = item.id
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, options).then((result) => {
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params).then((result) => {
parent = this.findCard(item.id, this['items_' + col])
if (parent) {
Vue.set(parent, 'recipes', result.data.results)

View File

@ -13,7 +13,7 @@ export class Models {
// MODEL_TYPES - inherited by MODELS, inherits and takes precedence over ACTIONS
static TREE = {
'list': {
'params': ['query', 'root', 'tree', 'page', 'pageSize'],
'params': ['query', 'root', 'tree', 'page', 'pageSize', 'options'],
'config': {
'root': {
'default': {
@ -471,7 +471,7 @@ export class Actions {
static LIST = {
"function": "list",
"suffix": "s",
"params": ['query', 'page', 'pageSize'],
"params": ['query', 'page', 'pageSize', 'options'],
"config": {
'query': {'default': undefined},
'page': {'default': 1},

View File

@ -159,7 +159,7 @@ export function roundDecimals(num) {
/*
* Utility functions to use OpenAPIs generically
* */
import {ApiApiFactory} from "@/utils/openapi/api.ts"; // TODO: is it possible to only import inside the Mixin?
import {ApiApiFactory} from "@/utils/openapi/api.ts";
import axios from "axios";
axios.defaults.xsrfCookieName = 'csrftoken'