<commit_before>import barangDialog from './barang.dialog.html';
import barangDialogJS from './barang.dialog';

export default class BarangController {

  constructor(BarangService, $mdDialog) {
    this._BarangService = BarangService;
    this._mdDialog = $mdDialog;

    this._paging = {
      page: 1
    };

    this._inputBarang = {};

    this.getBarang();

  }

  getBarang() {
    this._BarangService.getBarang(this._paging.page).success((data) => {
      this._barangs = data.docs;
      this._paging.totalPages = data.pagination.totalPages;
    });
  }

  //paging
  nextPage() {
    if (this._paging.page < this._paging.totalPages) {
      this._paging.page++;
      getBarang();
    }
  }

  hasNextPage() {
    if (this._paging.page < this._paging.totalPages) {
      return false;
    }
    return true;
  }

  previousPage() {
    if (this._paging.page > 1) {
      this._paging.page--;
      getBarang();
    }
  }

  hasPreviousPage() {
    if (this._paging.page > 1) {
      return false;
    }
    return true;
  }
  //end paging

  addBarang() {
    this._mdDialog.show({
      templateUrl: '../../barang/barang.component/barang.dialog.html',
      controller: barangDialogJS,
      controllerAs: 'barang',
      clickOutsideToClose: false,
      locals: {
        _inputBarang: null,
        _enable: false
      }
    })
      .then((answer) => {
        this.getBarang();
      }, () => {
        console.log('cancel');
      });
  }

  editBarang(b) {
    b.tanggalKadaluarsa = new Date(b.tanggalKadaluarsa);
    this._mdDialog.show({
      templateUrl: '../../barang/barang.component/barang.dialog.html',
      controller: barangDialogJS,
      controllerAs: 'barang',
      clickOutsideToClose: false,
      locals: {
        _inputBarang: b,
        _enable: true
      }
    })
      .then((answer) => {
        this.getBarang();
      }, () => {
        console.log('cancel');
      });
  }

}

BarangController.$inject = ['BarangService', '$mdDialog'];<commit_msg>tambah delete barang<commit_after>import barangDialog from './barang.dialog.html';
import barangDialogJS from './barang.dialog';

export default class BarangController {

  constructor(BarangService, $mdDialog) {
    this._BarangService = BarangService;
    this._mdDialog = $mdDialog;

    this._paging = {
      page: 1
    };

    this._inputBarang = {};

    this.getBarang();

  }

  getBarang() {
    this._BarangService.getBarang(this._paging.page).success((data) => {
      this._barangs = data.docs;
      this._paging.totalPages = data.pagination.totalPages;
    });
  }

  //paging
  nextPage() {
    if (this._paging.page < this._paging.totalPages) {
      this._paging.page++;
      getBarang();
    }
  }

  hasNextPage() {
    if (this._paging.page < this._paging.totalPages) {
      return false;
    }
    return true;
  }

  previousPage() {
    if (this._paging.page > 1) {
      this._paging.page--;
      getBarang();
    }
  }

  hasPreviousPage() {
    if (this._paging.page > 1) {
      return false;
    }
    return true;
  }
  //end paging

  addBarang() {
    this._mdDialog.show({
      templateUrl: '../../barang/barang.component/barang.dialog.html',
      controller: barangDialogJS,
      controllerAs: 'barang',
      clickOutsideToClose: false,
      locals: {
        _inputBarang: null,
        _enable: false
      }
    })
      .then((answer) => {
        this.getBarang();
      }, () => {
        console.log('cancel');
      });
  }

  editBarang(b) {
    b.tanggalKadaluarsa = new Date(b.tanggalKadaluarsa);
    this._mdDialog.show({
      templateUrl: '../../barang/barang.component/barang.dialog.html',
      controller: barangDialogJS,
      controllerAs: 'barang',
      clickOutsideToClose: false,
      locals: {
        _inputBarang: b,
        _enable: true
      }
    })
      .then((answer) => {
        this.getBarang();
      }, () => {
        console.log('cancel');
      });
  }

  deleteBarang(idBarang) {
    this._BarangService.deleteBarang(idBarang).success(() => {
      alert(data.info);
      this.getBarang();
    });
  }

}

BarangController.$inject = ['BarangService', '$mdDialog'];
{'fraction_non_alphanumeric': 0.1500965250965251, 'fraction_numerical': 0.0014478764478764478, 'mean_word_length': 2.263779527559055, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1688772', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1394, 'n_words': 209}