Railsのindexページで更新日時(updated_at)を昇降順にしたいです。
昇順には反応するのですが、降順がどうしても反応しません。
他のカラムは昇降順ともにソート可能です。
アドバイスあれば教えていただきたいです。
よろしくお願いいたします。
ruby
1 2// index.html.slim 3 4 thead.thead-default 5 tr 6 th.col-short 7 = t('.id') 8 i#clients-id [ 9 :class="sort('id')" 10 @click="columnSort('id')" 11 ] 12 th 13 = t('.name') 14 i#clients-name [ 15 :class="sort('name')" 16 @click="columnSort('name')" 17 ] 18 th 19 = t('.updated_at') 20 i#clients-updated_at [ 21 :class="sort('updated_at')" 22 @click="columnSort('updated_at')" 23 ] 24 25 tbody 26 - @clients.items.each do |client| 27 tr 28 td.text-sm-center 29 | #{ client.id } 30 td 31 | #{ client.name } 32 td.text-sm-center 33 = client.updated_at.in_time_zone(operator.time_zone).strftime(t('time.formats.zelda_default')) 34 35
javascript
1 methods: { 2 3 columnSort: function(column) { 4 var target = 'i#clients-' + column; 5 this.bridgeConfig.$options.orderBy = column; 6 if ($(target).hasClass('i-bottom')) { 7 bridgeConfig.$options.direction = 'asc'; 8 } else { 9 bridgeConfig.$options.direction = 'desc'; 10 } 11 this.reload(); 12 }, 13 14 sort: function(column) { 15 return this.form.direction === 'asc' && this.form.order_by === column ? 'i-top' : 'i-bottom'; 16 } 17 } 18
あなたの回答
tips
プレビュー