re-wire count for pagination - refactor

This commit is contained in:
Regis 2016-11-10 12:46:29 -07:00
parent 1a5027a03d
commit 38bb34889c
7 changed files with 11 additions and 9 deletions

View file

@ -10,7 +10,7 @@
], ],
computed: { computed: {
last() { last() {
return Math.ceil(+this.count / 5); return Math.ceil(+this.count / 30);
}, },
getItems() { getItems() {
const total = +this.last; const total = +this.last;

View file

@ -9,7 +9,7 @@
return `mailto:${this.pipeline.commit.author_email}`; return `mailto:${this.pipeline.commit.author_email}`;
}, },
alt() { alt() {
return `${this.pipeline.commit.author_name}'s avatar` return `${this.pipeline.commit.author_name}'s avatar`;
}, },
}, },
template: ` template: `

View file

@ -25,7 +25,6 @@
el: '.vue-pipelines-index', el: '.vue-pipelines-index',
data: { data: {
scope: project.dataset.url, scope: project.dataset.url,
count: project.dataset.count,
store: new gl.PipelineStore(), store: new gl.PipelineStore(),
}, },
components: { components: {
@ -36,7 +35,6 @@
<vue-pipelines <vue-pipelines
:scope='scope' :scope='scope'
:store='store' :store='store'
:count='count'
> >
</vue-pipelines> </vue-pipelines>
</div> </div>

View file

@ -20,12 +20,15 @@
currentPage: '', currentPage: '',
intervalId: '', intervalId: '',
pagenum: 1, pagenum: 1,
count: {
all: 0,
running_or_pending: 0,
},
}; };
}, },
props: [ props: [
'scope', 'scope',
'store', 'store',
'count',
], ],
created() { created() {
const url = window.location.toString(); const url = window.location.toString();
@ -65,9 +68,10 @@
</table> </table>
</div> </div>
<vue-gl-pagination <vue-gl-pagination
v-if='count.all > 0'
:pagenum='pagenum' :pagenum='pagenum'
:changepage='changepage' :changepage='changepage'
:count='count' :count='count.all'
> >
</vue-gl-pagination> </vue-gl-pagination>
</div> </div>

View file

@ -8,8 +8,8 @@
this.$http.get(`${url}?page=${pageNum}`) this.$http.get(`${url}?page=${pageNum}`)
.then((response) => { .then((response) => {
const res = JSON.parse(response.body); const res = JSON.parse(response.body);
debugger
Vue.set(this, 'pipelines', res.pipelines); Vue.set(this, 'pipelines', res.pipelines);
Vue.set(this, 'count', res.count);
}, () => new Flash( }, () => new Flash(
'Something went wrong on our end.' 'Something went wrong on our end.'
)); ));

View file

@ -20,4 +20,4 @@
</td> </td>
`, `,
}); });
})(window.gl || (window.gl = {})); })(window.gl || (window.gl = {}));

View file

@ -35,7 +35,7 @@
= link_to ci_lint_path, class: 'btn btn-default' do = link_to ci_lint_path, class: 'btn btn-default' do
%span CI Lint %span CI Lint
%div.content-list.pipelines{data: {url: namespace_project_pipelines_path(@project.namespace, @project, format: :json), "data-count": "#{@pipelines_count}"}} %div.content-list.pipelines{data: {url: namespace_project_pipelines_path(@project.namespace, @project, format: :json)}}
- if @pipelines.blank? - if @pipelines.blank?
%div %div
.nothing-here-block No pipelines to show .nothing-here-block No pipelines to show