|
|
@ -18,29 +18,7 @@ import { |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
const groupingUidt = [ |
|
|
|
const excludedGroupingUidt = [UITypes.Attachment] |
|
|
|
UITypes.SingleSelect, |
|
|
|
|
|
|
|
UITypes.MultiSelect, |
|
|
|
|
|
|
|
UITypes.Checkbox, |
|
|
|
|
|
|
|
UITypes.Date, |
|
|
|
|
|
|
|
UITypes.SingleLineText, |
|
|
|
|
|
|
|
UITypes.Number, |
|
|
|
|
|
|
|
UITypes.Rollup, |
|
|
|
|
|
|
|
UITypes.Lookup, |
|
|
|
|
|
|
|
UITypes.Links, |
|
|
|
|
|
|
|
UITypes.Formula, |
|
|
|
|
|
|
|
UITypes.Email, |
|
|
|
|
|
|
|
UITypes.URL, |
|
|
|
|
|
|
|
UITypes.PhoneNumber, |
|
|
|
|
|
|
|
UITypes.Decimal, |
|
|
|
|
|
|
|
UITypes.Currency, |
|
|
|
|
|
|
|
UITypes.Percent, |
|
|
|
|
|
|
|
UITypes.Duration, |
|
|
|
|
|
|
|
UITypes.Rating, |
|
|
|
|
|
|
|
UITypes.Year, |
|
|
|
|
|
|
|
UITypes.DateTime, |
|
|
|
|
|
|
|
UITypes.Time, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj, ref()) |
|
|
|
const meta = inject(MetaInj, ref()) |
|
|
|
const view = inject(ActiveViewInj, ref()) |
|
|
|
const view = inject(ActiveViewInj, ref()) |
|
|
@ -74,17 +52,17 @@ const groupedByColumnIds = computed(() => groupBy.value.map((g) => g.fk_column_i |
|
|
|
const { eventBus } = useSmartsheetStoreOrThrow() |
|
|
|
const { eventBus } = useSmartsheetStoreOrThrow() |
|
|
|
|
|
|
|
|
|
|
|
const { isMobileMode } = useGlobal() |
|
|
|
const { isMobileMode } = useGlobal() |
|
|
|
const btLookups = ref([]) |
|
|
|
const supportedLookups = ref([]) |
|
|
|
|
|
|
|
|
|
|
|
const fieldsToGroupBy = computed(() => { |
|
|
|
const fieldsToGroupBy = computed(() => { |
|
|
|
const fields = meta.value?.columns || [] |
|
|
|
const fields = meta.value?.columns || [] |
|
|
|
|
|
|
|
|
|
|
|
return fields.filter((field) => { |
|
|
|
return fields.filter((field) => { |
|
|
|
// if (!groupingUidt.includes(field.uidt as UITypes)) return false |
|
|
|
if (excludedGroupingUidt.includes(field.uidt as UITypes)) return false |
|
|
|
// |
|
|
|
|
|
|
|
// if (field.uidt === UITypes.Lookup) { |
|
|
|
if (field.uidt === UITypes.Lookup) { |
|
|
|
// return btLookups.value.includes(field.id) |
|
|
|
return supportedLookups.value.includes(field.id) |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true |
|
|
|
return true |
|
|
|
}) |
|
|
|
}) |
|
|
@ -173,23 +151,20 @@ watch(open, () => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const loadBtLookups = async () => { |
|
|
|
const loadAllowedLookups = async () => { |
|
|
|
const filteredLookupCols = [] |
|
|
|
const filteredLookupCols = [] |
|
|
|
try { |
|
|
|
try { |
|
|
|
for (const col of meta.value?.columns || []) { |
|
|
|
for (const col of meta.value?.columns || []) { |
|
|
|
if (col.uidt !== UITypes.Lookup) continue |
|
|
|
if (col.uidt !== UITypes.Lookup) continue |
|
|
|
|
|
|
|
|
|
|
|
let nextCol = col |
|
|
|
let nextCol = col |
|
|
|
let btLookup = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check all the relation of nested lookup columns is bt or not |
|
|
|
// check the lookup column is supported type or not |
|
|
|
// include the column only if all only if all relations are bt |
|
|
|
|
|
|
|
while (btLookup && nextCol && nextCol.uidt === UITypes.Lookup) { |
|
|
|
while (btLookup && nextCol && nextCol.uidt === UITypes.Lookup) { |
|
|
|
const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find( |
|
|
|
const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find( |
|
|
|
(c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id, |
|
|
|
(c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id, |
|
|
|
) |
|
|
|
) |
|
|
|
if ((lookupRelation.colOptions as LinkToAnotherRecordType).type !== RelationTypes.BELONGS_TO) { |
|
|
|
if ((lookupRelation.colOptions as LinkToAnotherRecordType).type !== RelationTypes.BELONGS_TO) { |
|
|
|
btLookup = false |
|
|
|
|
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -202,26 +177,25 @@ const loadBtLookups = async () => { |
|
|
|
// if next column is same as root lookup column then break the loop |
|
|
|
// if next column is same as root lookup column then break the loop |
|
|
|
// since it's going to be a circular loop, and ignore the column |
|
|
|
// since it's going to be a circular loop, and ignore the column |
|
|
|
if (nextCol.id === col.id) { |
|
|
|
if (nextCol.id === col.id) { |
|
|
|
btLookup = false |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (btLookup) filteredLookupCols.push(col.id) |
|
|
|
if (nextCol.uidt !== UITypes.Attachment) filteredLookupCols.push(col.id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
btLookups.value = filteredLookupCols |
|
|
|
supportedLookups.value = filteredLookupCols |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.error(e) |
|
|
|
console.error(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
onMounted(async () => { |
|
|
|
await loadBtLookups() |
|
|
|
await loadAllowedLookups() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
watch(meta, async () => { |
|
|
|
watch(meta, async () => { |
|
|
|
await loadBtLookups() |
|
|
|
await loadAllowedLookups() |
|
|
|
}) |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
@ -258,9 +232,7 @@ watch(meta, async () => { |
|
|
|
<LazySmartsheetToolbarFieldListAutoCompleteDropdown |
|
|
|
<LazySmartsheetToolbarFieldListAutoCompleteDropdown |
|
|
|
v-model="group.fk_column_id" |
|
|
|
v-model="group.fk_column_id" |
|
|
|
class="caption nc-sort-field-select" |
|
|
|
class="caption nc-sort-field-select" |
|
|
|
:columns=" |
|
|
|
:columns="fieldsToGroupBy" |
|
|
|
fieldsToGroupBy |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
:allow-empty="true" |
|
|
|
:allow-empty="true" |
|
|
|
@change="saveGroupBy" |
|
|
|
@change="saveGroupBy" |
|
|
|
@click.stop |
|
|
|
@click.stop |
|
|
|