|
|
|
@ -18,29 +18,7 @@ import {
|
|
|
|
|
watch, |
|
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
const groupingUidt = [ |
|
|
|
|
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 excludedGroupingUidt = [UITypes.Attachment] |
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj, 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 { isMobileMode } = useGlobal() |
|
|
|
|
const btLookups = ref([]) |
|
|
|
|
const supportedLookups = ref([]) |
|
|
|
|
|
|
|
|
|
const fieldsToGroupBy = computed(() => { |
|
|
|
|
const fields = meta.value?.columns || [] |
|
|
|
|
|
|
|
|
|
return fields.filter((field) => { |
|
|
|
|
// if (!groupingUidt.includes(field.uidt as UITypes)) return false |
|
|
|
|
// |
|
|
|
|
// if (field.uidt === UITypes.Lookup) { |
|
|
|
|
// return btLookups.value.includes(field.id) |
|
|
|
|
// } |
|
|
|
|
if (excludedGroupingUidt.includes(field.uidt as UITypes)) return false |
|
|
|
|
|
|
|
|
|
if (field.uidt === UITypes.Lookup) { |
|
|
|
|
return supportedLookups.value.includes(field.id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
}) |
|
|
|
@ -173,23 +151,20 @@ watch(open, () => {
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const loadBtLookups = async () => { |
|
|
|
|
const loadAllowedLookups = async () => { |
|
|
|
|
const filteredLookupCols = [] |
|
|
|
|
try { |
|
|
|
|
for (const col of meta.value?.columns || []) { |
|
|
|
|
if (col.uidt !== UITypes.Lookup) continue |
|
|
|
|
|
|
|
|
|
let nextCol = col |
|
|
|
|
let btLookup = true |
|
|
|
|
|
|
|
|
|
// check all the relation of nested lookup columns is bt or not |
|
|
|
|
// include the column only if all only if all relations are bt |
|
|
|
|
// check the lookup column is supported type or not |
|
|
|
|
while (btLookup && nextCol && nextCol.uidt === UITypes.Lookup) { |
|
|
|
|
const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find( |
|
|
|
|
(c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id, |
|
|
|
|
) |
|
|
|
|
if ((lookupRelation.colOptions as LinkToAnotherRecordType).type !== RelationTypes.BELONGS_TO) { |
|
|
|
|
btLookup = false |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -202,26 +177,25 @@ const loadBtLookups = async () => {
|
|
|
|
|
// 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 |
|
|
|
|
if (nextCol.id === col.id) { |
|
|
|
|
btLookup = false |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (btLookup) filteredLookupCols.push(col.id) |
|
|
|
|
if (nextCol.uidt !== UITypes.Attachment) filteredLookupCols.push(col.id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
btLookups.value = filteredLookupCols |
|
|
|
|
supportedLookups.value = filteredLookupCols |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
|
await loadBtLookups() |
|
|
|
|
await loadAllowedLookups() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
watch(meta, async () => { |
|
|
|
|
await loadBtLookups() |
|
|
|
|
await loadAllowedLookups() |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
@ -258,9 +232,7 @@ watch(meta, async () => {
|
|
|
|
|
<LazySmartsheetToolbarFieldListAutoCompleteDropdown |
|
|
|
|
v-model="group.fk_column_id" |
|
|
|
|
class="caption nc-sort-field-select" |
|
|
|
|
:columns=" |
|
|
|
|
fieldsToGroupBy |
|
|
|
|
" |
|
|
|
|
:columns="fieldsToGroupBy" |
|
|
|
|
:allow-empty="true" |
|
|
|
|
@change="saveGroupBy" |
|
|
|
|
@click.stop |
|
|
|
|