func PropertyTypeWritePolicyRule() privacy.MutationRule {
	return privacy.PropertyTypeMutationRuleFunc(func(ctx context.Context, m *ent.PropertyTypeMutation) error {
		propertyTypeID, exists := m.ID()
		if !exists {
			return privacy.Skip
		}
		propType, err := m.Client().PropertyType.Query().
			Where(propertytype.ID(propertyTypeID)).
			WithLocationType().
			WithEquipmentType().
			WithEquipmentPortType().
			WithLinkEquipmentPortType().
			WithServiceType().
			WithWorkOrderType().
			WithWorkOrderTemplate().
			WithProjectType().
			Only(ctx)

		if err != nil {
			if !ent.IsNotFound(err) {
				return privacy.Denyf("failed to fetch property type: %w", err)
			}
			return privacy.Skip
		}
		p := FromContext(ctx)
		switch {
		case propType.Edges.LocationType != nil:
			return allowOrSkip(p.InventoryPolicy.LocationType.Update)
		case propType.Edges.EquipmentType != nil:
			return allowOrSkip(p.InventoryPolicy.EquipmentType.Update)
		case propType.Edges.EquipmentPortType != nil:
			return allowOrSkip(p.InventoryPolicy.PortType.Update)
		case propType.Edges.LinkEquipmentPortType != nil:
			return allowOrSkip(p.InventoryPolicy.PortType.Update)
		case propType.Edges.ServiceType != nil:
			return allowOrSkip(p.InventoryPolicy.ServiceType.Update)
		case propType.Edges.WorkOrderType != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		case propType.Edges.WorkOrderTemplate != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		case propType.Edges.ProjectType != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		}
		return privacy.Skip
	})
}
// PropertyTypeWritePolicyRule grants write permission to property type based on policy.
// nolint: dupl
PropertyTypeWritePolicyRule grants write permission to property type based on policy.
nolint: dupl
// PropertyTypeWritePolicyRule grants write permission to property type based on policy . // nolint : dupl
func PropertyTypeWritePolicyRule() privacy.MutationRule {
	return privacy.PropertyTypeMutationRuleFunc(func(ctx context.Context, m *ent.PropertyTypeMutation) error {
		propertyTypeID, exists := m.ID()
		if !exists {
			return privacy.Skip
		}
		propType, err := m.Client().PropertyType.Query().
			Where(propertytype.ID(propertyTypeID)).
			WithLocationType().
			WithEquipmentType().
			WithEquipmentPortType().
			WithLinkEquipmentPortType().
			WithServiceType().
			WithWorkOrderType().
			WithWorkOrderTemplate().
			WithProjectType().
			Only(ctx)
		if err != nil {
			if !ent.IsNotFound(err) {
				return privacy.Denyf("failed to fetch property type: %w", err)
			}
			return privacy.Skip
		}
		p := FromContext(ctx)
		switch {
		case propType.Edges.LocationType != nil:
			return allowOrSkip(p.InventoryPolicy.LocationType.Update)
		case propType.Edges.EquipmentType != nil:
			return allowOrSkip(p.InventoryPolicy.EquipmentType.Update)
		case propType.Edges.EquipmentPortType != nil:
			return allowOrSkip(p.InventoryPolicy.PortType.Update)
		case propType.Edges.LinkEquipmentPortType != nil:
			return allowOrSkip(p.InventoryPolicy.PortType.Update)
		case propType.Edges.ServiceType != nil:
			return allowOrSkip(p.InventoryPolicy.ServiceType.Update)
		case propType.Edges.WorkOrderType != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		case propType.Edges.WorkOrderTemplate != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		case propType.Edges.ProjectType != nil:
			return allowOrSkip(p.WorkforcePolicy.Templates.Update)
		}
		return privacy.Skip
	})
}
func PropertyTypeWritePolicyRule ( ) privacy . MutationRule { return privacy . PropertyTypeMutationRuleFunc ( func ( ctx context . Context , m * ent . PropertyTypeMutation ) error { propertyTypeID , exists := m . ID ( ) if ! exists { return privacy . Skip } propType , err := m . Client ( ) . PropertyType . Query ( ) . Where ( propertytype . ID ( propertyTypeID ) ) . WithLocationType ( ) . WithEquipmentType ( ) . WithEquipmentPortType ( ) . WithLinkEquipmentPortType ( ) . WithServiceType ( ) . WithWorkOrderType ( ) . WithWorkOrderTemplate ( ) . WithProjectType ( ) . Only ( ctx ) if err != nil { if ! ent . IsNotFound ( err ) { return privacy . Denyf ( " " , err ) } return privacy . Skip } p := FromContext ( ctx ) switch { case propType . Edges . LocationType != nil : return allowOrSkip ( p . InventoryPolicy . LocationType . Update ) case propType . Edges . EquipmentType != nil : return allowOrSkip ( p . InventoryPolicy . EquipmentType . Update ) case propType . Edges . EquipmentPortType != nil : return allowOrSkip ( p . InventoryPolicy . PortType . Update ) case propType . Edges . LinkEquipmentPortType != nil : return allowOrSkip ( p . InventoryPolicy . PortType . Update ) case propType . Edges . ServiceType != nil : return allowOrSkip ( p . InventoryPolicy . ServiceType . Update ) case propType . Edges . WorkOrderType != nil : return allowOrSkip ( p . WorkforcePolicy . Templates . Update ) case propType . Edges . WorkOrderTemplate != nil : return allowOrSkip ( p . WorkforcePolicy . Templates . Update ) case propType . Edges . ProjectType != nil : return allowOrSkip ( p . WorkforcePolicy . Templates . Update ) } return privacy . Skip } ) }
PropertyTypeWritePolicyRule grants write permission to property type based on policy.
PropertyTypeWritePolicyRule grants write permission to property type based on policy .