2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { useContext } from "@nuxtjs/composition-api";
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { fieldTypes } from "../forms";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { AutoFormItems } from "~/types/auto-forms";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export const useUserForm = () => {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const { i18n } = useContext();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const userForm: AutoFormItems = [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      section: i18n.tc("user.user-details"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.user-name"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "username",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.TEXT,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.full-name"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "fullName",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.TEXT,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.email"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "email",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.TEXT,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.password"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "password",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      disableUpdate: true,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.PASSWORD,
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-13 21:38:26 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      rules: ["required", "minLength:8"],
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.authentication-method"),
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      varName: "authMethod",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.SELECT,
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      hint: i18n.tc("user.authentication-method-hint"),
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      disableCreate: true,
							 | 
						
					
						
							
								
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      options: [{ text: "Mealie" }, { text: "LDAP" }, { text: "OIDC" }],
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-26 13:12:16 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      section: i18n.tc("user.permissions"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.administrator"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "admin",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.user-can-invite-other-to-group"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "canInvite",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.user-can-manage-group"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "canManage",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.user-can-organize-group-data"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "canOrganize",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-17 10:48:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.user-can-manage-household"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "canManageHousehold",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-21 20:45:27 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      label: i18n.tc("user.enable-advanced-features"),
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:57:24 -09:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      varName: "advanced",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      type: fieldTypes.BOOLEAN,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      rules: ["required"],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  ];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    userForm,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 |