Giter Site home page Giter Site logo

md-date-range-picker's Introduction

md-date-range-picker - npm version bower version

A simple Angular Date range picker with material theme

ussage/code example

NPM

  • install using npm packages
  • npm install md-date-range-picker
  • install using bower
  • bower install md-date-range-picker

Live Demo and Examples

example: html directive

<body ng-app="demo.app" ng-cloak>
  <div ng-controller="ctrl">
    <md-date-range ng-model="pickerModel"></md-date-range>
  </div>
</body>

js adding dependencies

angular.module('demo.app', ['ngMaterial', 'ngMaterialDateRangePicker'])

dev tools

  • Clone Repo
  • npm install
  • npm start for dev serve
  • npm run build for build
  • npm run dist for dist serve

TODO:

  • Optimize code
  • Create unit tests
  • Standardize build script

md-date-range-picker's People

Contributors

andr3net0 avatar bsell93 avatar codefunta avatar davloperez avatar dependabot[bot] avatar fnnek avatar genghis-koen avatar hollyfang avatar jktu2870 avatar orlandovallejos avatar roelbarreto avatar yoni12ab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

md-date-range-picker's Issues

Remove This year and Last Year options

I'm using a custom template along with the given template. I'd like to have day, week, month and 6 months options. Is there any way I can hide/remove the Year button?

When we add custom templates, how can we get that selected by default ?

$rootScope.mdCustomTemplates = [
  {
    name: 'Last 30 Days',
    dateStart: new Date(tempDate),
    dateEnd : new Date()
  }
];

$rootScope.selectedRange = {
  selectedTemplate: 'TW',
  selectedTemplateName: 'Last 30 Days',
  dateStart: new Date(tempDate),
  dateEnd: new Date(),
  showTemplate: true,
  fullscreen: true,
  firstDayOfWeek: 0,
  customTemplates: $rootScope.mdCustomTemplates,
  isDisabledDate: $rootScope.isFutureDate
};

I want Last 30 Days to be selected by default.
Something like this:

$rootScope.selectedRange = {
  selectedTemplate: 'L30D',
  selectedTemplateName: 'Last 30 Days',
  dateStart: new Date(tempDate),
  dateEnd: new Date(),
  showTemplate: true,
  fullscreen: true,
  firstDayOfWeek: 0,
  customTemplates: $rootScope.mdCustomTemplates,
  isDisabledDate: $rootScope.isFutureDate
};

Feature request: user-specifiable highlighted dates

I want a set of days to be highlighted.

It would address my use case if md-date-range-picker took a callback isHighlightedDate (similar to isDisabledDate) and added a something-something__highlighted class to exactly those days for which isHighlightedDate returns true.

It would be much less useful for me if I have to specify the set of days as an argument to the <md-date-range-picker ...> tag, due to fetching the list of dates from muh server, asynhronously. I don't have a need for changing the set of highlighted dates once I know it, but others might find this useful.

Infinity loading when I add first-day-of-week arg

When I add first-day-of-week="0" or first-day-of-week="1" I get infinity loading on my page.
Here is the part of my HTML with datepicker:

                <div flex="100">
                    <md-date-range auto-confirm="true"
                                   first-day-of-week="0"
                                   show-template="false"
                                   one-panel="true"
                                   placeholder="{{ 'stages.DATE' | translate }}"
                                   format="stageCtrl.formatDate"
                                   md-on-select="stageCtrl.updateDateFilter()">
                    </md-date-range>
                </div>

And it works normally if I don't add this argument, like this code:

                <div flex="100">
                    <md-date-range auto-confirm="true"
                                   show-template="false"
                                   one-panel="true"
                                   placeholder="{{ 'stages.DATE' | translate }}"
                                   format="stageCtrl.formatDate"
                                   md-on-select="stageCtrl.updateDateFilter()">
                    </md-date-range>
                </div>

And one more question how to switch on "Clear" button inside of Datepicker? And if there any event or ay I can get after I press "Clear" button to update my data on the page?

Showing already selected dates

Is there any options to highlight currently selected multiple date range, if Calendar UI is opened in edit mode. So if user has selected some date ranges and saved it, opening the UI, should show the already selected date ranges in Calendar

calendarStartDate / calendarEndDate wrong calc

calendarStartDate / calendarEndDate wrong calc when month start on Sunday and should be the first day view on calendar

calendarStartDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1 - (monthStartDate.getDay() == 0 ? 6 : (monthStartDate.getDay() - getFirstDayOfWeek()))),

the ? 6 should be set to 0 and not 6.
same as calendarEndDate

Setting start date time to end of day

Line 150, there's $scope.dateEnd && $scope.dateStart.setHours(23, 59, 59, 999);
instead of $scope.dateEnd && $scope.dateEnd.setHours(23, 59, 59, 999);

It couses troubles when you want to set start date at start.

Angular 4 Integration

Hey,
It is possible to change all templateUrls to inline templates? This will make the Angular 4 integration way easier. I upgraded the component and all is fine beside this templateUrl thing.

Thank you.

firstDayOfWeek option doesn't work

I could not get the firstDayOfWeek option to work. Modifying START_OF_WEEK on md-date-range-picker.js,128 does work, so it looks like there's a bug in the assignment when the directive is set up. Am I missing something?

is func inCurrentMonth missing years?

I believe there is a comparison missing for years in this particular function.
Because months can be the same, but not the year, and that should trigger the focus method.

This is what I'm talking about:

function inCurrentMonth(date, isSecondMonth) {
  return !isSecondMonth ?
     date.getMonth() === $scope.activeMonth && date.getFullYear() === $scope.activeYear:
     date.getMonth() === $scope.activeMonth2 && date.getFullYear() === $scope.activeYear2;
}

Customisation of selected date

Hi there,
I am trying to use the date picker and I would like to have a different format when range is selected. (My users do not want to see english). I would like to have something like '05/11/2018 - 26/12/2018'.

I cannot see how i could customize it that way , i have been able to translate most of the calendar with the localizationMap but I cannot get this to work.

Could you tell me how to achieve this?

Code is pretty simple so far:

       <md-date-range
                ng-model="vm.filters.appointmentDateRange" localization-map="vm.localizationMap" >
            </md-date-range>

and

vm.localizationMap = {
			'Mon': 'Lu',
			'Tue': 'Ma',
			'Wed': 'Me',
			'Thu': 'Je',
			'Fri': 'Ve',
			'Sat': 'Sa',
			'Sun':'Dim',
			'This Week': 'Settimana corrente',
			"January": "Janvier",
			"February": "Février",
			"March": "Mars",
			"April": "Avril",
			"May": "Mai",
			"June": "Juin",
			"July": "Juillet",
			"August": "Aout",
			"September": "Septembre",
			"October": "Octobre",
			"November": "November",
			"December": "Decembre"
		};

		vm.filters =
		{
			appointmentDateRange: {
				//selectedTemplate: 'TY',
				//selectedTemplateName: 'Anno corrente',
				dateStart: new Date(),
				dateEnd: new Date(),
			}
		};

date 1
date 2

Thanks for the help and for the good work :)

Illegal Invocation Typeerror

screen shot 2017-11-21 at 4 40 23 pm

$scope.pick = function($event, showTemplate) {
            console.log('Button Fired!');
            $scope.selectedRange.showTemplate = showTemplate;
            $mdDateRangePicker.show({
                targetEvent: $event,
                model: $scope.selectedRange
            }).then(function(result) {
                if (result) $scope.selectedRange = result;
            })
        };

I think you should remove the property targetEvent: $event from the object, it worked for me.

IE11 not registring all clicks on dates

When the user opens the menu to select a date. He/she cannot click on the date itself. They will need to click on the circle around the date.

image

image

This is because the date itself is a new element. And the onclick event cant reach the event-id on the surrounding element. In chrome this works perfectly. In IE11 it (ofcourse) does not.
In the code it is written like this
<div class="md-date-range-picker__calendar"> <span ng-repeat="date in dates" event-key="date1" event-param="{{$index}}"> <span class="md-date-range-picker__calendar__selection" ng-bind={{::date.getDate()}}></span> </span> </div>

Customisation

Hi,

First of all thanks for the good work.

I have some question :

  • How to change the local ? I see the localmap but what is the format of this input.
  • How I can change the color of the selected range ?

Thanks you

Add the possibility to use different languages

Hi how that's going?
I'm using the md-date-range-picker component. I'm wondering if is possible to use different languages. Is there a workaround to do this? I think that set the lang as some param is not the unique way, could be great, at least, set the month names, week day names and filtering options (such as "last month", "this year", etc..) verbiages settable. I'll appreciate an answer.
Kind regards.

customTemplates in model dont show

I'm trying to add some custom templates and they don't seem to be showing when the calendar is instantiated, only the default templates are. Here's my code:

angular
.module('core')
.controller('baseCtrl', baseCtrl);

baseCtrl.$inject = ['$scope', '$mdDateRangePicker'];

function baseCtrl($scope, $datePicker) {
	var vm = $scope;

	vm.date = {
		showTemplate: true,
		customTemplates: [
			{
				name:"Last 3 Months",
				dateStart: new Date((new Date()).setMonth((new Date()).getMonth() - 3)),
				dateEnd : new Date()
			},{
				name:"Last 6 Months",
				dateStart: new Date((new Date()).setMonth((new Date()).getMonth() - 6)),
				dateEnd : new Date()
			}
		]
	}
	vm.showDate = function($event, showTemplate){
		$datePicker.show({targetEvent:$event, model:vm.date} ).then(function(result){
			if(result) vm.date = result;
		})
	}
}

Also, is there a way for this to work and is there a way for me to disable the default templates?

License?

Do you plan to add a license for this plugin?

Rendering issue??

Hello,

Love the concept and am hoping to use your library in my project. One issue I'm having is that it's not rendering like your demos. I'm using the md-date-range directive. I have attached a screenshot of what it looks like for me:

screen shot 2017-02-06 at 6 32 42 pm

Notice how the navigation (back, month, year, forward) seems to be rendered incorrectly. Have you seen this before?

I'm using latest (master) version of Angular Material however switching versions appeared to make no difference.

EDIT: I should also add that I have show-templates=true and I'm not seeing the templates either.

Thanks,
Dinko

open mdDateRange instead of mdDateRangePicker

Is there a way to open "mdDateRange" on button click or any other event (the one that opens in md-menu). instead of "mdDateRangePicker" (this one open in md-dialog)?

the documentation only has work around for "mdDateRangePicker"

$scope.selectDateRange = function () {
  $mdDateRangePicker.show({
    model: $scope.serviceModel,
  }).then(function (result) {
    $scope.serviceModel = result;
  }).catch(function () {
    console.log('Cancelled');
  }
}
this on opens in dialog box...

but i want the one that opens in md-menu to open on my event

md-dialog
md-menu

Please help..
Thanks in advance

Auto Confirm using Service

Is it possible that using auto confirm can be added to the service configuration?

$mdDateRangePicker.show({
    autoConfirm: true,
    targetEvent: $event,
    model: {}
})

I browsed through the source and it doesn't appear to be an option.

Thanks!

RangeError: Maximum call stack size exceeded

Hi,
I am getting this error after adding this library:

at Date.setMonth (<anonymous>:1024:39)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)
at Date.setMonth (<anonymous>:1025:132)

How I can fix this error.

Focus on same start and end date

I know this is a range picker, but I use it as a regular calendar because I prefer it over the Material Design option.
Because of this, I set the start and end date with the same variable.
Everything works fine, except when I want to see the date and see it focused.

This is what I guess it's causing this specific problem:

image

As in my case, both, start and end date are the same.

Is there any solution for this?

Any help would be appreciated! 😄

Throwing error of Can't copy

angular.min.js:117 Error: [ng:cpws] http://errors.angularjs.org/1.5.5/ng/cpws
at angular.min.js:6
at c (angular.min.js:12)
at d (angular.min.js:12)
at c (angular.min.js:12)
at d (angular.min.js:12)
at c (angular.min.js:12)
at Object.qa [as copy] (angular.min.js:14)
at mdDateRangePickerService.show (md-date-range-picker.js:734)
at n.$scope.selectDateRange (?hcode=10)
at fn (eval at compile (angular.min.js:230), :4:351)

Show only 1 calendar

Is it possible to show only 1 calendar ant not 2 like default?
How could I implement this changes?

Thank you!

Can we disable future dates from the controller?

Like this

$rootScope.selectedRange = {

     selectedTemplate:'L30D',
      selectedTemplateName: 'Last 30 Days',
      dateStart: new Date(tempDate),
      dateEnd: new Date(),
      showTemplate: true,
      fullscreen: true,
      firstDayOfWeek: 0,
      isDisabledDate: '$rootScope.isFutureDate($date)'

};

$rootScope.isFutureDate = function ($date) {

      return $date.getTime() < new Date().getTime();

};

npm start errors...

Hi There :)
Thx for this plugin ! it really looks great and has all the features im looking for ...
I just cloned this project and tried to npm start it but it show some errors ...
I did try to make my own project by using your example but for some reason some widgets are missing ( probably CSS issues ) ...
Am I missing something ? or its a known issue ?
thanks alot again
Etay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.