Skip to content

Commit f70c501

Browse files
author
kaptron
committed
fixes for rendering SubmissionBox / splitLevel collections
1 parent ce93df9 commit f70c501

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

app/controllers/api/v1/collections_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def index
2323
before_action :check_cache, only: %i[show]
2424
def show
2525
check_getting_started_shell
26-
check_4wfc_migration
2726

2827
include = Collection.default_relationships_for_api
2928
if @collection.collection_type_challenge?
@@ -346,6 +345,7 @@ def check_getting_started_shell
346345
@collection.reload
347346
end
348347

348+
# no longer used (used to be a fallback check in collections#show)
349349
def check_4wfc_migration
350350
return if @collection.board_collection?
351351

app/javascript/stores/jsonApi/Collection.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class Collection extends SharedRecordMixin(BaseRecord) {
7676
tempTextCard = null
7777
@observable
7878
newPersistedTextCard = null
79+
@observable
80+
lastInsertedRow = 0
7981

8082
attributesForAPI = [
8183
'name',
@@ -2002,6 +2004,14 @@ class Collection extends SharedRecordMixin(BaseRecord) {
20022004
this.applyRowUpdate({ row, action })
20032005
uiStore.update('isTransparentLoading', false)
20042006

2007+
if (this.isSplitLevel) {
2008+
runInAction(() => {
2009+
// this is used to adjust the splitLevel top row height in FoamcoreGrid
2010+
const incr = action === ROW_ACTIONS.INSERT ? 1 : -1
2011+
this.lastInsertedRow = row + incr
2012+
})
2013+
}
2014+
20052015
if (!pushUndo) {
20062016
return
20072017
}

app/javascript/ui/grid/FoamcoreGrid.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,31 @@ class FoamcoreGrid extends React.Component {
265265
const { gridW, gridH, gutter } = this.gridSettings
266266
const { relativeZoomLevel } = this
267267
const { collection, uiStore } = this.props
268+
const { lastInsertedRow } = collection
268269
const maxCols = uiStore.maxCols(collection)
269270
// Max rows is the max row of any current cards (max_row_index)
270271
// + 1, since it is zero-indexed,
271272
const visRows = _.get(uiStore, 'visibleRows.num', 1)
272273
let maxRows = (
273-
_.maxBy(collection.collection_cards, 'maxRow') || { maxRow: 1 }
274+
_.maxBy(collection.collection_cards, 'maxRow') || { maxRow: 0 }
274275
).maxRow
276+
275277
if (collection.isSplitLevelBottom) {
276278
maxRows += 1
277-
} else if (!collection.isSplitLevel) {
279+
} else if (collection.isSplitLevel) {
280+
if (collection.canEdit) {
281+
maxRows = lastInsertedRow > maxRows ? lastInsertedRow : maxRows
282+
}
283+
maxRows += 1
284+
} else {
278285
// + 2x the visible number of rows
279286
// for padding to allow scrolling beyond the current cards
280287
maxRows += visRows * 2
281288
if (collection.canEdit) {
282289
maxRows += 1
283290
}
284291
}
292+
285293
const height = ((gridH + gutter) * maxRows) / relativeZoomLevel
286294
const width = ((gridW + gutter) * maxCols) / relativeZoomLevel
287295
return {

spec/requests/api/v1/collections_controller_spec.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,6 @@
147147
end
148148
end
149149

150-
context 'with a normal collection in need of 4WFC migration' do
151-
let(:collection) { create(:collection, num_cards: 2, num_columns: nil, add_viewers: [user]) }
152-
153-
it 'calls BoardMigrator service' do
154-
expect(CollectionGrid::BoardMigrator).to receive(:call).with(
155-
collection: an_instance_of(Collection),
156-
async: true,
157-
)
158-
get(path)
159-
end
160-
end
161-
162150
it 'has no editors' do
163151
get(path)
164152
roles = json['data']['relationships']['roles']['data']

0 commit comments

Comments
 (0)