mominsamir / smDateTimeRangePicker

Angular Material Date Picker, DateTime Picker, Date Range Picker, Date Time range picker
http://mominsamir.github.io/smDateTimeRangePicker/
MIT License
130 stars 50 forks source link

feat(label): add customRangeLabel #123

Closed wesleifreitas closed 7 years ago

wesleifreitas commented 7 years ago

Hi @mominsamir

First of all, congratulations to the directive.

I am sending my translation option suggestion to the 'Custom Range' action.

pickerProvider.setCustomRangeLabel('Other Text');

I want to use your directive in my project, but this text needs to be translated into the language of my project (pt-br):

print

Yours sincerely.

mominsamir commented 7 years ago

I think you can do this without this commit, can you try PickerProvider to override text

wesleifreitas commented 7 years ago

I did it this way because the Custom Range button is with the fixed text

range-picker.html

<div  layout="column" class="pre-select"  role="button" ng-show="!vm.showCustom">
    <md-button
         aria-label="{{list.label}}"
         ng-click="vm.setNgModelValue(list.startDate,vm.divider,list.endDate)"
         ng-repeat="list in vm.rangeDefaultList | limitTo:6">{{list.label}}
     </md-button>
    <md-button aria-label="Custom Range"  ng-click="vm.showCustomView()">Custom Range</md-button>
</div>

In my application the only text that was not translated was this button

          pickerProvider.setOkLabel('Ok');
          pickerProvider.setCancelLabel('Fechar');
          pickerProvider.setClearLabel('Apagar');
          // Here
          pickerProvider.setCustomRangeLabel('Período'); // My sugestion

           pickerProvider.setRangeDefaultList([{
                label: 'Hoje',
                startDate: moment().startOf('day'),
                endDate: moment().endOf('day')
            },
            {
                label: 'Ultimos 7 dias',
                startDate: moment().subtract(7, 'd'),
                endDate: moment()
            },
            {
                label: 'Este mês',
                startDate: moment().startOf('month'),
                endDate: moment().endOf('month')
            },
            {
                label: 'Ultimo mês',
                startDate: moment().subtract(1, 'month').startOf('month'),
                endDate: moment()
            },
            {
                label: 'Este Ano',
                startDate: moment().startOf('year'),
                endDate: moment().endOf('year')
            }
        ]);
       // [...]