multiapi_cli 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f7df3e65178366a1b9ec58f83af286d436bc443b6bf26f032b6ae6cff6b0e70
4
- data.tar.gz: 4b6e8800edc639c99e6e21d4a5a7a7e4e3b9e6c8fbc02e7afbe704ac34c8df74
3
+ metadata.gz: 60babc8bb42e044305e43ca13f459d2702f0e81a6a43cec0aab0e32b28cb647b
4
+ data.tar.gz: 075b335a3b4ae45f4e63f7795ce51b9abe4714917c21b1178f70f905415d2413
5
5
  SHA512:
6
- metadata.gz: 542b7ae1fcadeb3d9d9413b488f30a4f4a61f6c791873dcdab9129f3d3356bbe54977319676b145206791ce283ec1d509f67f82ab5e4b73ba1a5a21af743e9e5
7
- data.tar.gz: ed45d1beff89fec0b23ddc07d201aa0dd2e39b9a0ebaf809643782875f704ada55416dd80ee8524173be97996fb718c43bd7caf59a49e5f54a74cce52f2d0e4f
6
+ metadata.gz: 808379a977b8f45b6b4afddcebc044724735383d775a44ab2e33a5c265100d7a6c90d7d9f688243757b0b88000c484ef265a31f6aec0a0284e320777cfe3a208
7
+ data.tar.gz: e493a1a5096750c1f5402f37e6617720ba7b20f6187996af20f2d542acc778c9d7ad584d58be2707d95bdc6c9b2a74dcf3153a02c0f08c94c9bc0200481e62b6
@@ -1,3 +1,3 @@
1
1
  module MultiapiCli
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/multiapi_cli.rb CHANGED
@@ -986,10 +986,17 @@ module MultiapiCli
986
986
  id: string | number
987
987
  }>()
988
988
 
989
+ console.log('[Edit] Componente inicializado com ID:', props.id)
990
+
991
+ const emit = defineEmits(['success', 'cancel'])
992
+
989
993
  const store = use#{plural_name.camelize}Store()
990
994
  const isSubmitting = ref(false)
991
995
  const isLoading = ref(true)
992
- const formData = ref({})
996
+ const formData = ref({
997
+ id: null,
998
+ #{fields.map { |f| "#{f[:name]}: ''" }.join(",\n ")}
999
+ })
993
1000
 
994
1001
  const fields = [
995
1002
  #{field_definitions}
@@ -1001,25 +1008,58 @@ module MultiapiCli
1001
1008
  })
1002
1009
  )
1003
1010
 
1004
- onMounted(async () => {
1005
- try {
1006
- const data = await store.fetch#{singular_name.camelize}(props.id)
1007
- formData.value = data
1008
- } catch (error) {
1009
- console.error('Erro ao carregar #{singular_name}:', error)
1010
- } finally {
1011
+ const loadData = () => {
1012
+ console.log('[Edit] ============ CICLO DE CARREGAMENTO ============')
1013
+ console.log('[Edit] Estado atual:', {
1014
+ id: props.id,
1015
+ channels: store.get#{plural_name.camelize}.length
1016
+ })
1017
+
1018
+ if (!props.id) {
1019
+ console.log('[Edit] Nenhum ID fornecido, interrompendo ciclo')
1011
1020
  isLoading.value = false
1021
+ return
1012
1022
  }
1023
+
1024
+ // Buscar o registro diretamente do array no store
1025
+ const item = store.get#{plural_name.camelize}.find(c => c.id === props.id)
1026
+
1027
+ if (!item) {
1028
+ console.error('[Edit] Item não encontrado no store')
1029
+ isLoading.value = false
1030
+ return
1031
+ }
1032
+
1033
+ console.log('[Edit] Item encontrado no store:', item)
1034
+
1035
+ const formattedData = {
1036
+ id: item.id,
1037
+ #{fields.map { |f| "#{f[:name]}: String(item.#{f[:name]} || '')" }.join(",\n ")}
1038
+ }
1039
+
1040
+ console.log('[Edit] Atualizando formData:', formattedData)
1041
+ formData.value = formattedData
1042
+ isLoading.value = false
1043
+ }
1044
+
1045
+ onMounted(() => {
1046
+ console.log('[Edit] Componente montado, carregando dados do store')
1047
+ loadData()
1013
1048
  })
1014
1049
 
1015
1050
  const onSubmit = async (values) => {
1051
+ if (!props.id) return
1052
+
1016
1053
  try {
1054
+ console.log('[Edit] Iniciando submissão do formulário com valores:', values)
1017
1055
  isSubmitting.value = true
1018
1056
  await store.update#{singular_name.camelize}(props.id, values)
1019
- $emit('success')
1057
+ console.log('[Edit] Item atualizado com sucesso')
1058
+ emit('success')
1020
1059
  } catch (error) {
1021
- console.error('Erro ao atualizar #{singular_name}:', error)
1060
+ console.error('[Edit] Erro ao atualizar item:', error)
1022
1061
  } finally {
1062
+ console.log('[Edit] Finalizando submissão do formulário')
1023
1063
  isSubmitting.value = false
1024
1064
  }
1025
1065
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiapi_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seu Nome