Skip to content

Beautiful Open-Source Form Builder

Google Sheet integration fix (#493)

Chirag Chhatralaa2c175781535
diff --git a/app/Integrations/Google/Sheets/SpreadsheetManager.php b/app/Integrations/Google/Sheets/SpreadsheetManager.php
index 6c7a99286..5c674ad8d 100644
--- a/app/Integrations/Google/Sheets/SpreadsheetManager.php
+++ b/app/Integrations/Google/Sheets/SpreadsheetManager.php
@@ -12,6 +12,7 @@ use Google\Service\Sheets\BatchUpdateValuesRequest;
use Google\Service\Sheets\Spreadsheet;
use Google\Service\Sheets\ValueRange;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
class SpreadsheetManager
{
@@ -30,19 +31,12 @@ class SpreadsheetManager
url: $this->integration->data->url,
spreadsheet_id: $this->integration->data->spreadsheet_id,
columns: array_map(
- fn ($column) => (array) $column,
+ fn ($column) => (array)$column,
$this->integration->data->columns
)
);
}
- protected function convertToArray(mixed $object): array
- {
- return is_scalar($object) || is_null($object)
- ? $object
- : $this->convertToArray((array) $object);
- }
-
public function get(string $id): Spreadsheet
{
$spreadsheet = $this->driver
@@ -73,9 +67,12 @@ class SpreadsheetManager
public function buildColumns(): array
{
- $properties = $this->integration->form->properties;
+ collect($this->integration->form->properties)->each(function ($property) {
+ // Skip custom blocks
+ if (Str::of($property['type'])->startsWith('nf-')) {
+ return;
+ }
- foreach ($properties as $property) {
$key = Arr::first(
array_keys($this->data->columns),
fn (int $key) => $this->data->columns[$key]['id'] === $property['id']
@@ -88,12 +85,11 @@ class SpreadsheetManager
} else {
$this->data->columns[] = $column;
}
- }
+ });
$this->integration->update([
'data' => $this->data,
]);
-
return $this->data->columns;
}
@@ -184,6 +180,20 @@ class SpreadsheetManager
protected function buildRange(array $values): string
{
- return "A1:" . chr(64 + count($values)) . "1";
+ $columnsCount = count($values);
+ $endColumn = $this->getColumnLetter($columnsCount);
+ return "A1:{$endColumn}1";
+ }
+
+
+ protected function getColumnLetter(int $columnIndex): string
+ {
+ $columnLetter = '';
+ while ($columnIndex > 0) {
+ $columnIndex--;
+ $columnLetter = chr(65 + ($columnIndex % 26)) . $columnLetter;
+ $columnIndex = (int)($columnIndex / 26);
+ }
+ return $columnLetter;
}
}
diff --git a/client/components/forms/RichTextAreaInput.client.vue b/client/components/forms/RichTextAreaInput.client.vue
index 4deb3fc1e..26143045c 100644
--- a/client/components/forms/RichTextAreaInput.client.vue
+++ b/client/components/forms/RichTextAreaInput.client.vue
@@ -1,10 +1,10 @@
<template>
- <input-wrapper v-bind="inputWrapperProps">
+ <InputWrapper v-bind="inputWrapperProps">
<template #label>
<slot name="label" />
</template>
- <vue-editor
+ <VueEditor
:id="id ? id : name"
ref="editor"
v-model="compVal"
@@ -18,6 +18,7 @@
theme.RichTextAreaInput.input,
theme.RichTextAreaInput.borderRadius,
]"
+ :editor-options="editorOptions"
:editor-toolbar="editorToolbar"
class="rich-editor resize-y"
:style="inputStyle"
@@ -29,40 +30,58 @@
<template #error>
<slot name="error" />
</template>
- </input-wrapper>
+ </InputWrapper>
</template>
<script>
-import { inputProps, useFormInput } from "./useFormInput.js"
-import InputWrapper from "./components/InputWrapper.vue"
-import { VueEditor, Quill } from "vue3-editor"
+import { Quill, VueEditor } from 'vue3-editor'
+import { inputProps, useFormInput } from './useFormInput.js'
+import InputWrapper from './components/InputWrapper.vue'
-Quill.imports["formats/link"].PROTOCOL_WHITELIST.push("notion")
+Quill.imports['formats/link'].PROTOCOL_WHITELIST.push('notion')
export default {
- name: "RichTextAreaInput",
+ name: 'RichTextAreaInput',
components: { InputWrapper, VueEditor },
props: {
...inputProps,
+ editorOptions: {
+ type: Object,
+ default: () => {
+ return {
+ formats: [
+ 'bold',
+ 'color',
+ 'font',
+ 'italic',
+ 'link',
+ 'underline',
+ 'header',
+ 'indent',
+ 'list'
+ ]
+ }
+ }
+ },
editorToolbar: {
type: Array,
default: () => {
return [
[{ header: 1 }, { header: 2 }],
- ["bold", "italic", "underline", "link"],
- [{ list: "ordered" }, { list: "bullet" }],
- [{ color: [] }],
+ ['bold', 'italic', 'underline', 'link'],
+ [{ list: 'ordered' }, { list: 'bullet' }],
+ [{ color: [] }]
]
- },
- },
+ }
+ }
},
- setup(props, context) {
+ setup (props, context) {
return {
- ...useFormInput(props, context),
+ ...useFormInput(props, context)
}
- },
+ }
}
</script>
diff --git a/client/components/forms/SelectInput.vue b/client/components/forms/SelectInput.vue
index 97ec49f31..56b5a2f00 100644
--- a/client/components/forms/SelectInput.vue
+++ b/client/components/forms/SelectInput.vue
@@ -74,7 +74,7 @@
theme.SelectInput.fontSize,
]"
>
- {{ option.name }}
+ {{ getOptionName(option) }}
</p>
<span
v-if="selected"
@@ -157,7 +157,8 @@ export default {
methods: {
getOptionName(val) {
const option = this.finalOptions.find((optionCandidate) => {
- return optionCandidate[this.optionKey] === val
+ return optionCandidate[this.optionKey] === val ||
+ (typeof val === 'object' && optionCandidate[this.optionKey] === val[this.optionKey])
})
if (option) return option[this.displayKey]
return null
diff --git a/client/components/open/forms/OpenFormField.vue b/client/components/open/forms/OpenFormField.vue
index 6741f3b00..73bb639b1 100644
--- a/client/components/open/forms/OpenFormField.vue
+++ b/client/components/open/forms/OpenFormField.vue
@@ -91,6 +91,7 @@
:alt="field.name"
:src="field.image_block"
class="max-w-full"
+ :class="theme.default.borderRadius"
>
</div>
</template>
diff --git a/client/components/open/forms/fields/components/FieldOptions.vue b/client/components/open/forms/fields/components/FieldOptions.vue
index 16dc42a04..248a463e7 100644
--- a/client/components/open/forms/fields/components/FieldOptions.vue
+++ b/client/components/open/forms/fields/components/FieldOptions.vue
@@ -517,6 +517,17 @@
:form="field"
:editor-toolbar="editorToolbarCustom"
label="Field Help"
+ :editor-options="{
+ formats: [
+ 'bold',
+ 'color',
+ 'font',
+ 'italic',
+ 'link',
+ 'underline',
+ 'list'
+ ]
+ }"
help="Your field help will be shown below/above the field, just like this text."
:help-position="field.help_position"
/>
diff --git a/client/components/open/integrations/GoogleSheetsIntegration.vue b/client/components/open/integrations/GoogleSheetsIntegration.vue
index 0ddb78f2c..51d66722c 100644
--- a/client/components/open/integrations/GoogleSheetsIntegration.vue
+++ b/client/components/open/integrations/GoogleSheetsIntegration.vue
@@ -10,6 +10,7 @@
v-model="integrationData.oauth_id"
name="provider"
:options="providers"
+ display-key="email"
option-key="id"
emit-key="id"
:required="true"
@@ -43,19 +44,19 @@
</template>
<script setup>
-import IntegrationWrapper from "./components/IntegrationWrapper.vue"
+import IntegrationWrapper from './components/IntegrationWrapper.vue'
const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
- formIntegrationId: { type: Number, required: false, default: null },
+ formIntegrationId: { type: Number, required: false, default: null }
})
const providersStore = useOAuthProvidersStore()
const providers = computed(() => providersStore.getAll.filter(provider => provider.provider == 'google'))
-function connect() {
+function connect () {
providersStore.connect('google', true)
}
</script>
diff --git a/client/data/forms/integrations.json b/client/data/forms/integrations.json
index e193ad157..a1232bc2e 100644
--- a/client/data/forms/integrations.json
+++ b/client/data/forms/integrations.json
@@ -49,6 +49,7 @@
"section_name": "Databases",
"file_name": "GoogleSheetsIntegration",
"actions_file_name": "GoogleSheetsIntegrationActions",
- "is_pro": false
+ "is_pro": false,
+ "crisp_help_page_slug": "how-do-i-integrate-google-sheets-for-my-database-goefny"
}
}
diff --git a/resources/data/forms/integrations.json b/resources/data/forms/integrations.json
index e193ad157..a1232bc2e 100644
--- a/resources/data/forms/integrations.json
+++ b/resources/data/forms/integrations.json
@@ -49,6 +49,7 @@
"section_name": "Databases",
"file_name": "GoogleSheetsIntegration",
"actions_file_name": "GoogleSheetsIntegrationActions",
- "is_pro": false
+ "is_pro": false,
+ "crisp_help_page_slug": "how-do-i-integrate-google-sheets-for-my-database-goefny"
}
}
diff --git a/tests/Feature/Integrations/Google/Sheets/SpreadsheetManagerTest.php b/tests/Feature/Integrations/Google/Sheets/SpreadsheetManagerTest.php
index 42b0c9732..4e8692d1d 100644
--- a/tests/Feature/Integrations/Google/Sheets/SpreadsheetManagerTest.php
+++ b/tests/Feature/Integrations/Google/Sheets/SpreadsheetManagerTest.php
@@ -45,7 +45,7 @@ test('build columns', function () {
assertCount(14, $columns);
- foreach($columns as $key => $column) {
+ foreach ($columns as $key => $column) {
assertEquals($form->properties[$key]['id'], $column['id']);
assertEquals($form->properties[$key]['name'], $column['name']);
}
@@ -63,8 +63,8 @@ test('update columns', function () {
$form->update([
'properties' => [
- ['id' => '000', 'name' => 'First'],
- ['id' => '001', 'name' => 'Second'],
+ ['id' => '000', 'name' => 'First', 'type' => 'text'],
+ ['id' => '001', 'name' => 'Second', 'type' => 'text'],
]
]);
@@ -82,8 +82,8 @@ test('update columns', function () {
url: 'https://google.com',
spreadsheet_id: 'sp_test',
columns: [
- ['id' => '000', 'name' => 'First'],
- ['id' => '001', 'name' => 'Second'],
+ ['id' => '000', 'name' => 'First', 'type' => 'text'],
+ ['id' => '001', 'name' => 'Second', 'type' => 'text'],
]
)
]);
@@ -96,8 +96,8 @@ test('update columns', function () {
$form->update([
'properties' => [
- ['id' => '000', 'name' => 'First name'],
- ['id' => '002', 'name' => 'Email'],
+ ['id' => '000', 'name' => 'First name', 'type' => 'text'],
+ ['id' => '002', 'name' => 'Email', 'type' => 'text'],
]
]);